Commit 23bdc6f8 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

feat: add heading component + update ecs rules to fix views

parent a50abc13
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
/// <reference types="vite/client" />
declare module "*";
+38 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace App\Views\Components;

use Exception;
use ViewComponents\Component;

class Heading extends Component
{
    protected string $level = '';

    /**
     * @var "small"|"base"|"large"
     */
    protected string $size = 'base';

    public function render(): string
    {
        if ($this->level === '') {
            throw new Exception('level property must be set for Heading component.');
        }

        $sizeClasses = [
            'small' => 'tracking-wide text-base',
            'base' => 'text-xl',
            'large' => 'text-3xl',
        ];

        $class = 'relative z-10 font-bold text-pine-800 font-display before:w-full before:absolute before:h-1/2 before:left-0 before:bottom-0 before:rounded-full before:bg-pine-100 before:-z-10 ' . $sizeClasses[$this->size];
        $level = $this->level;

        return <<<HTML
            <h{$level} class="{$class}">{$this->slot}</h{$level}>
        HTML;
    }
}
+3 −1
Original line number Diff line number Diff line
<?php if (session()->has('message')): ?>
<?php declare(strict_types=1);

if (session()->has('message')): ?>
    <div class="px-4 py-2 mb-4 font-semibold text-green-900 bg-green-200 border border-green-700">
        <?= session('message') ?>
    </div>
+2 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

use CodeIgniter\CLI\CLI;

CLI::error('ERROR: ' . $code);
+8 −14
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

use CodeIgniter\CLI\CLI;

// The main Exception
CLI::newLine();
CLI::write('[' . $exception::class . ']', 'light_gray', 'red');
CLI::newLine();
CLI::write($message);
CLI::newLine();
CLI::write(
    'at ' .
        CLI::color(
            clean_path($exception->getFile()) . ':' . $exception->getLine(),
            'green',
        ),
);
CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green', ), );
CLI::newLine();
// The backtrace
if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
@@ -24,8 +21,7 @@ if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
    }

    foreach ($backtraces as $i => $error) {
        $padFile = '    '; // 4 spaces
        $padClass = '       '; // 7 spaces
        $padFile = '    ';
        $c = str_pad($i + 1, 3, ' ', STR_PAD_LEFT);

        if (isset($error['file'])) {
@@ -33,9 +29,7 @@ if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {

            CLI::write($c . $padFile . CLI::color($filepath, 'yellow'));
        } else {
            CLI::write(
                $c . $padFile . CLI::color('[internal function]', 'yellow'),
            );
            CLI::write($c . $padFile . CLI::color('[internal function]', 'yellow'), );
        }

        $function = '';
@@ -57,7 +51,7 @@ if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
                return match (true) {
                    is_object($value) => 'Object(' . $value::class . ')',
                    is_array($value) => $value !== [] ? '[...]' : '[]',
                    is_null($value) => 'null',
                    $value === null => 'null',
                    default => var_export($value, true),
                };
            }, array_values($error['args'] ?? [])),
Loading