Show the Kanban columns as a carousel on phones, enlarge time sheet text

Below lg the board's columns form a snapping carousel with a strip of the
neighbouring columns on both sides, previous/next stage buttons and a
"Vaihe 2/7" status. A card dragged to the carousel's edge turns it to the
next column in that direction, and on while held there; Sortable's own
auto-scroll stays on only on desktop.

In the weekly time sheet the hour fields use a 14 px normal-weight font
and customer names are text-sm instead of text-xs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-30 19:42:02 +02:00
co-authored by Claude Opus 5.5
parent 8be732ada8
commit f16ad3c15b
6 changed files with 147 additions and 10 deletions
@@ -689,14 +689,111 @@ new class extends Component
<p role="status" aria-live="polite" class="mt-1 min-h-4 text-xs font-medium text-neutral-800 dark:text-neutral-100">{{ $statusMessage }}</p>
</section>
{{-- Columns: side by side from lg up (horizontal scroll), stacked on phones --}}
{{--
Columns side by side. From lg up the board scrolls sideways; below lg
it is a carousel: one column at a time snapped to the centre, with a
strip of the neighbours on both sides. A card dragged by its handle
to the carousel's edge scrolls it (Sortable's auto-scroll), and the
previous/next buttons move between columns with the keyboard.
--}}
<div
class="flex flex-1 flex-col"
x-data="{
index: 0,
count: 0,
template: {{ Js::from(__('jobs.board.column_position')) }},
position: '',
columns() { return this.$refs.track ? [...this.$refs.track.children].filter((el) => el.tagName === 'SECTION') : [] },
sync() {
const box = this.$refs.scroller.getBoundingClientRect();
const centre = box.left + box.width / 2;
const cols = this.columns();
let best = 0, bestDistance = Infinity;
cols.forEach((col, i) => {
const r = col.getBoundingClientRect();
const distance = Math.abs(r.left + r.width / 2 - centre);
if (distance < bestDistance) { best = i; bestDistance = distance; }
});
this.index = best;
this.count = cols.length;
const name = cols[best]?.querySelector('h2')?.textContent.trim() ?? '';
this.position = this.template.replace(':current', best + 1).replace(':total', cols.length).replace(':name', name);
},
go(step) {
const cols = this.columns();
const next = Math.max(0, Math.min(cols.length - 1, this.index + step));
this.index = next;
cols[next]?.scrollIntoView({ behavior: 'smooth', inline: 'center', block: 'nearest' });
},
edgeDirection: 0,
edgeTimer: null,
{{-- A dragged card held at the carousel's edge turns it to the neighbouring column, and on to the next while held --}}
edge(x) {
if (x === undefined || ! document.body.classList.contains('sorting') || window.matchMedia('(min-width: 64rem)').matches) {
return this.stopEdge();
}
const box = this.$refs.scroller.getBoundingClientRect();
const zone = Math.max(40, box.width * 0.15);
const direction = x < box.left + zone ? -1 : (x > box.right - zone ? 1 : 0);
if (direction === this.edgeDirection) {
return;
}
this.stopEdge();
this.edgeDirection = direction;
if (direction !== 0) {
this.edgeTimer = setTimeout(() => this.edgeStep(), 350);
}
},
edgeStep() {
this.go(this.edgeDirection);
this.edgeTimer = setTimeout(() => this.edgeStep(), 800);
},
stopEdge() {
clearTimeout(this.edgeTimer);
this.edgeTimer = null;
this.edgeDirection = 0;
},
}"
x-init="$nextTick(() => { sync(); new MutationObserver(() => sync()).observe($refs.track, { childList: true }) })"
x-on:pointermove.document="edge($event.clientX)"
x-on:touchmove.document.passive="edge($event.touches[0]?.clientX)"
x-on:dragover.document="edge($event.clientX)"
x-on:pointerup.document="stopEdge()"
x-on:touchend.document="stopEdge()"
x-on:dragend.document="stopEdge()"
x-on:drop.document="stopEdge()"
>
<div class="flex items-center justify-between gap-2 px-3 pt-2 sm:px-4 lg:hidden">
<button
type="button"
x-on:click="go(-1)"
x-bind:disabled="index === 0"
class="inline-flex min-h-8 items-center gap-1 rounded-lg border border-neutral-400 bg-neutral-50 px-2.5 text-xs font-semibold text-neutral-800 transition hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-primary-600 disabled:opacity-50 dark:border-[#6b7079] dark:bg-[#18191b] dark:text-neutral-100 dark:hover:bg-[#2c2f34] dark:focus-visible:outline-primary-300"
>
<x-icon name="chevron-left" class="size-4" aria-hidden="true" />
<span>{{ __('jobs.board.prev_column') }}</span>
</button>
<p role="status" class="min-w-0 truncate text-center text-xs font-semibold text-zinc-900 dark:text-zinc-100" x-text="position"></p>
<button
type="button"
x-on:click="go(1)"
x-bind:disabled="count > 0 && index >= count - 1"
class="inline-flex min-h-8 items-center gap-1 rounded-lg border border-neutral-400 bg-neutral-50 px-2.5 text-xs font-semibold text-neutral-800 transition hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-primary-600 disabled:opacity-50 dark:border-[#6b7079] dark:bg-[#18191b] dark:text-neutral-100 dark:hover:bg-[#2c2f34] dark:focus-visible:outline-primary-300"
>
<span>{{ __('jobs.board.next_column') }}</span>
<x-icon name="chevron-right" class="size-4" aria-hidden="true" />
</button>
</div>
<div
role="region"
aria-label="{{ __('jobs.board.columns') }}"
tabindex="0"
class="kanban-scroll flex-1 p-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-600 sm:p-4 lg:overflow-x-auto dark:focus-visible:outline-primary-300"
x-ref="scroller"
x-on:scroll.debounce.100ms="sync()"
class="kanban-scroll flex-1 snap-x snap-mandatory overflow-x-auto py-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-600 sm:py-4 lg:snap-none lg:p-4 dark:focus-visible:outline-primary-300"
>
<div class="flex flex-col gap-2.5 pb-6 lg:min-h-[calc(100vh-12rem)] lg:flex-row lg:items-start">
<div x-ref="track" class="flex w-max flex-row items-start gap-2.5 px-3 pb-6 sm:px-4 lg:min-h-[calc(100vh-12rem)] lg:px-0">
@foreach ($this->columns as $columnValue => $cards)
@php
$column = BoardColumn::from($columnValue);
@@ -710,7 +807,7 @@ new class extends Component
wire:key="column-{{ $columnValue }}"
aria-labelledby="column-{{ $columnValue }}-heading"
style="--col-body: {{ $style['body'] }}; --col-body-dark: {{ $style['bodyDark'] }}; --col-border: {{ $style['border'] }}; --col-border-dark: {{ $style['borderDark'] }}"
class="relative flex w-full shrink-0 flex-col rounded-xl border border-(--col-border) bg-(--col-body) shadow-md transition-colors dark:border-(--col-border-dark) dark:bg-(--col-body-dark) {{ $width }}"
class="relative flex w-[85vw] shrink-0 snap-center flex-col rounded-xl sm:w-[320px] border border-(--col-border) bg-(--col-body) shadow-md transition-colors dark:border-(--col-border-dark) dark:bg-(--col-body-dark) {{ $width }}"
>
<div
style="background-color: {{ $style['header'] }}; color: {{ $style['text'] }}"
@@ -777,6 +874,7 @@ new class extends Component
wire:sort="moveDropped"
wire:sort:group="board"
wire:sort:group-id="{{ $columnValue }}"
wire:sort:config="{ scroll: window.matchMedia('(min-width: 64rem)').matches }"
@endif
@class(['flex min-h-[120px] flex-1 flex-col', 'gap-1.5 p-1.5' => $compact, 'gap-2 p-2' => ! $compact])
>
@@ -815,6 +913,7 @@ new class extends Component
@endforeach
</div>
</div>
</div>
<livewire:jobs::job-editor />
@@ -924,7 +924,7 @@ new class extends Component
$color = new \App\Modules\Shared\Domain\ValueObjects\HexColor($customer->headerColor ?? '#374151');
@endphp
<div class="overflow-hidden rounded-lg border border-zinc-200 dark:border-zinc-700">
<p style="background-color: {{ $color->value }}; color: {{ $color->textColor() }}" class="px-3 py-1.5 text-xs font-bold">{{ $customer->name }}</p>
<p style="background-color: {{ $color->value }}; color: {{ $color->textColor() }}" class="px-3 py-1.5 text-sm font-bold">{{ $customer->name }}</p>
<ul class="divide-y divide-zinc-200 dark:divide-zinc-700">
@foreach ($customer->jobs as $job)
@foreach ($job->rows as $row)