<?php

namespace App\View\Ui;

use Illuminate\View\Component;

class Menulist extends Component
{

    public function __construct(public array $entries)
    {
    }

    public function activeClass($entry): string
    {
        return $entry['is_active'] ? 'bg-gray-600' : '';
    }

    public function render()
    {
        return <<<'HTML'
            <div class="p-6 bg-gray-700 border-r border-gray-600 flex-none w-maxc flex flex-col justify-between">
                <div class="grid gap-1">
                    @foreach($entries as $entry)
                    <a href="{{$entry['url']}}" class="rounded py-1 px-3 text-gray-400 duration-200 hover:bg-gray-600 {{$activeClass($entry)}}" @if($entry['is_active']) data-active @endif>
                        {{$entry['title']}}
                    </a>
                    @endforeach
                </div>
                <slot name="bottom"></slot>
            </div>
        HTML;
    }
}
