Replace the flat link row with disclosure groups (Työt, Oma kirjaus, Asiakkaat ja myynti, Hallinto, Ylläpito) built by App\View\MainMenu from Gate abilities, and add menu links for new job, quick sales list and workflow templates. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
60 lines
2.8 KiB
PHP
60 lines
2.8 KiB
PHP
@props(['group'])
|
|
|
|
{{--
|
|
A main menu group: a disclosure button that opens a panel of links (WAI-ARIA disclosure navigation, not role="menu").
|
|
Escape and a click outside close it, and so does moving focus out of the group. The current section is
|
|
marked with an underline and hidden text, not colour alone, and the current link has aria-current="page".
|
|
--}}
|
|
<div
|
|
class="relative"
|
|
x-data="{ open: false }"
|
|
x-on:nav-group-opened.window="if ($event.detail !== '{{ $group['key'] }}') open = false"
|
|
x-on:keydown.escape="if (open) { open = false; $refs.trigger.focus() }"
|
|
x-on:click.outside="open = false"
|
|
x-on:focusout="if (open && ! $el.contains($event.relatedTarget)) open = false"
|
|
>
|
|
<button
|
|
type="button"
|
|
x-ref="trigger"
|
|
x-on:click="open = ! open; if (open) $dispatch('nav-group-opened', '{{ $group['key'] }}')"
|
|
x-bind:aria-expanded="open.toString()"
|
|
aria-expanded="false"
|
|
aria-controls="nav-group-{{ $group['key'] }}"
|
|
@class([
|
|
'flex items-center gap-1 rounded-md px-3 py-2 text-sm font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700',
|
|
'text-zinc-900 underline decoration-2 underline-offset-8 dark:text-white' => $group['current'],
|
|
'text-zinc-600 hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:hover:text-white' => ! $group['current'],
|
|
])
|
|
>
|
|
{{ $group['label'] }}
|
|
@if ($group['current'])
|
|
<span class="sr-only">{{ __('layout.current_section') }}</span>
|
|
@endif
|
|
<x-icon name="chevron-down" class="size-4 transition-transform" x-bind:class="{ 'rotate-180': open }" aria-hidden="true" />
|
|
</button>
|
|
|
|
<ul
|
|
id="nav-group-{{ $group['key'] }}"
|
|
x-show="open"
|
|
x-cloak
|
|
class="z-40 mt-1 min-w-56 rounded-md border border-zinc-200 bg-white p-1 shadow-lg sm:absolute sm:start-0 dark:border-zinc-600 dark:bg-zinc-800"
|
|
>
|
|
@foreach ($group['items'] as $item)
|
|
<li>
|
|
<a
|
|
href="{{ route($item['route']) }}"
|
|
wire:navigate
|
|
@if ($item['current']) aria-current="page" @endif
|
|
@class([
|
|
'block rounded-md px-3 py-2 text-sm font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700',
|
|
'bg-zinc-100 text-zinc-900 underline decoration-2 underline-offset-4 dark:bg-zinc-700 dark:text-white' => $item['current'],
|
|
'text-zinc-700 hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-200 dark:hover:bg-zinc-700 dark:hover:text-white' => ! $item['current'],
|
|
])
|
|
>
|
|
{{ $item['label'] }}
|
|
</a>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|