<?php

namespace App\View\Ui;

use Illuminate\View\Component;

class Box extends Component
{

    public function __construct(
        public string $containerClass = '',
        public bool $second = false,
        public string $title = '',
        public string $inTitle = '',
    ) {
    }

    public function render()
    {
        return <<<'HTML'
            <section {!! $attributes
                ->mergeWhen($second, 'class', 'bg-gray-700 group-[.is-popup]:bg-zinc-600')
                ->mergeWhen(!$second, 'class', 'bg-gray-800 group-[.is-popup]:bg-zinc-700')
                ->mergeWhen(true, 'class', 'p-3 rounded-lg flex flex-col')
            !!}>
                <div class="flex items-center">
                    @if($title)
                    <div class="col-span-full font-semibold text-gray-300 group-[.is-popup]:text-zinc-300">{{$title}}</div>
                    @endif
                    {{$inTitle}}
                </div>
                <main class="{{ $title ? 'mt-2' : '' }} {{ $containerClass }}">
                    {{ $slot }}
                </main>
            </section>
        HTML;
    }
}
