Files
Toiminnanohjaus/resources/views/components/tabs.blade.php
T
petriandClaude Opus 5.5 f4b58f6b1d Darken the dark canvas, add customer colours, the ongoing status and the board model
- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 /
  primary-100 and TallStackUI's dark labels, hints and checkbox labels are
  lightened so everything stays at 4.5:1.
- Shared HexColor picks white or black text by the higher WCAG contrast; a
  native-dialog colour picker and a large work dialog component.
- Customers get a header colour (customers.header_color), set on the
  customer page.
- New job status Jatkuvat / Kausi (ongoing): open, never late, billed
  monthly like running jobs.
- Kanban model: board columns and views, urgent threshold, per-user board
  preferences (density, column colours and sort), card positions, tasks of
  continuing jobs pinned to the board, MoveBoardCard and board queries with
  logged hours from TimeTracking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 06:11:49 +02:00

67 lines
2.5 KiB
PHP

{{--
Tabs after the WAI-ARIA tabs pattern, because TallStackUI's <x-tab> ties its
panels to ids that do not exist and has no arrow keys. Only the selected tab
is in the tab order; arrow keys, Home and End move between the tabs and
select them. Panels are <x-tabs.panel> children with the same id.
$tabs: ['key' => 'title', ...] in display order.
--}}
@props([
'id',
'label',
'tabs',
'selected' => null,
])
@php
$selected ??= array_key_first($tabs);
@endphp
<div
{{ $attributes->class('space-y-3') }}
x-data="{
selected: @js($selected),
select(key) {
this.selected = key;
this.$nextTick(() => document.getElementById(@js($id) + '-tab-' + key)?.focus());
},
move(event) {
const keys = @js(array_keys($tabs));
const index = keys.indexOf(this.selected);
const next = { ArrowRight: index + 1, ArrowLeft: index - 1, Home: 0, End: keys.length - 1 }[event.key];
if (next === undefined) {
return;
}
event.preventDefault();
this.select(keys[(next + keys.length) % keys.length]);
},
}"
>
<div
role="tablist"
aria-label="{{ $label }}"
x-on:keydown="move($event)"
class="flex flex-wrap gap-x-4 gap-y-1 border-b border-zinc-200 dark:border-zinc-700"
>
@foreach ($tabs as $key => $title)
<button
type="button"
role="tab"
id="{{ $id }}-tab-{{ $key }}"
aria-controls="{{ $id }}-panel-{{ $key }}"
aria-selected="{{ $key === $selected ? 'true' : 'false' }}"
tabindex="{{ $key === $selected ? '0' : '-1' }}"
x-bind:aria-selected="(selected === @js($key)).toString()"
x-bind:tabindex="selected === @js($key) ? 0 : -1"
x-on:click="select(@js($key))"
x-bind:class="selected === @js($key)
? 'border-primary-700 font-semibold text-zinc-900 dark:border-primary-400 dark:text-white'
: 'border-transparent text-zinc-700 hover:border-zinc-400 dark:text-zinc-200'"
class="-mb-px min-h-6 rounded-t-md border-b-2 px-1 py-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300"
>{{ $title }}</button>
@endforeach
</div>
{{ $slot }}
</div>