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:
@@ -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>
|
<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>
|
</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
|
<div
|
||||||
role="region"
|
role="region"
|
||||||
aria-label="{{ __('jobs.board.columns') }}"
|
aria-label="{{ __('jobs.board.columns') }}"
|
||||||
tabindex="0"
|
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)
|
@foreach ($this->columns as $columnValue => $cards)
|
||||||
@php
|
@php
|
||||||
$column = BoardColumn::from($columnValue);
|
$column = BoardColumn::from($columnValue);
|
||||||
@@ -710,7 +807,7 @@ new class extends Component
|
|||||||
wire:key="column-{{ $columnValue }}"
|
wire:key="column-{{ $columnValue }}"
|
||||||
aria-labelledby="column-{{ $columnValue }}-heading"
|
aria-labelledby="column-{{ $columnValue }}-heading"
|
||||||
style="--col-body: {{ $style['body'] }}; --col-body-dark: {{ $style['bodyDark'] }}; --col-border: {{ $style['border'] }}; --col-border-dark: {{ $style['borderDark'] }}"
|
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
|
<div
|
||||||
style="background-color: {{ $style['header'] }}; color: {{ $style['text'] }}"
|
style="background-color: {{ $style['header'] }}; color: {{ $style['text'] }}"
|
||||||
@@ -777,6 +874,7 @@ new class extends Component
|
|||||||
wire:sort="moveDropped"
|
wire:sort="moveDropped"
|
||||||
wire:sort:group="board"
|
wire:sort:group="board"
|
||||||
wire:sort:group-id="{{ $columnValue }}"
|
wire:sort:group-id="{{ $columnValue }}"
|
||||||
|
wire:sort:config="{ scroll: window.matchMedia('(min-width: 64rem)').matches }"
|
||||||
@endif
|
@endif
|
||||||
@class(['flex min-h-[120px] flex-1 flex-col', 'gap-1.5 p-1.5' => $compact, 'gap-2 p-2' => ! $compact])
|
@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
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<livewire:jobs::job-editor />
|
<livewire:jobs::job-editor />
|
||||||
|
|
||||||
|
|||||||
@@ -924,7 +924,7 @@ new class extends Component
|
|||||||
$color = new \App\Modules\Shared\Domain\ValueObjects\HexColor($customer->headerColor ?? '#374151');
|
$color = new \App\Modules\Shared\Domain\ValueObjects\HexColor($customer->headerColor ?? '#374151');
|
||||||
@endphp
|
@endphp
|
||||||
<div class="overflow-hidden rounded-lg border border-zinc-200 dark:border-zinc-700">
|
<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">
|
<ul class="divide-y divide-zinc-200 dark:divide-zinc-700">
|
||||||
@foreach ($customer->jobs as $job)
|
@foreach ($customer->jobs as $job)
|
||||||
@foreach ($job->rows as $row)
|
@foreach ($job->rows as $row)
|
||||||
|
|||||||
@@ -204,6 +204,9 @@ return [
|
|||||||
'link' => 'Show as a board',
|
'link' => 'Show as a board',
|
||||||
'show_list' => 'Show as a list',
|
'show_list' => 'Show as a list',
|
||||||
'columns' => 'Kanban columns',
|
'columns' => 'Kanban columns',
|
||||||
|
'prev_column' => 'Previous stage',
|
||||||
|
'next_column' => 'Next stage',
|
||||||
|
'column_position' => 'Stage :current/:total: :name',
|
||||||
'count' => '{0} no jobs|{1} :count job|[2,*] :count jobs',
|
'count' => '{0} no jobs|{1} :count job|[2,*] :count jobs',
|
||||||
'card_count' => '{0} no cards|{1} :count card|[2,*] :count cards',
|
'card_count' => '{0} no cards|{1} :count card|[2,*] :count cards',
|
||||||
'empty' => 'No cards',
|
'empty' => 'No cards',
|
||||||
|
|||||||
@@ -204,6 +204,9 @@ return [
|
|||||||
'link' => 'Näytä Kanban-näkymänä',
|
'link' => 'Näytä Kanban-näkymänä',
|
||||||
'show_list' => 'Näytä listana',
|
'show_list' => 'Näytä listana',
|
||||||
'columns' => 'Kanban-sarakkeet',
|
'columns' => 'Kanban-sarakkeet',
|
||||||
|
'prev_column' => 'Edellinen vaihe',
|
||||||
|
'next_column' => 'Seuraava vaihe',
|
||||||
|
'column_position' => 'Vaihe :current/:total: :name',
|
||||||
'count' => '{0} ei töitä|{1} :count työ|[2,*] :count työtä',
|
'count' => '{0} ei töitä|{1} :count työ|[2,*] :count työtä',
|
||||||
'card_count' => '{0} ei kortteja|{1} :count kortti|[2,*] :count korttia',
|
'card_count' => '{0} ei kortteja|{1} :count kortti|[2,*] :count korttia',
|
||||||
'empty' => 'Ei kortteja',
|
'empty' => 'Ei kortteja',
|
||||||
|
|||||||
@@ -131,8 +131,8 @@
|
|||||||
<tr wire:key="{{ $section }}-customer-{{ $customer->customerId }}">
|
<tr wire:key="{{ $section }}-customer-{{ $customer->customerId }}">
|
||||||
<td colspan="{{ $columnCount }}" class="p-0">
|
<td colspan="{{ $columnCount }}" class="p-0">
|
||||||
<div style="background-color: {{ $color->value }}; color: {{ $color->textColor() }}" class="flex items-center justify-between gap-3 px-3 py-1.5">
|
<div style="background-color: {{ $color->value }}; color: {{ $color->textColor() }}" class="flex items-center justify-between gap-3 px-3 py-1.5">
|
||||||
<span class="flex items-center gap-2 text-xs font-bold tracking-wide">
|
<span class="flex items-center gap-2 text-sm font-bold tracking-wide">
|
||||||
<x-icon name="building-office" class="size-3.5 shrink-0" aria-hidden="true" />
|
<x-icon name="building-office" class="size-4 shrink-0" aria-hidden="true" />
|
||||||
<span>{{ $customer->name }}</span>
|
<span>{{ $customer->name }}</span>
|
||||||
<span class="rounded bg-black/15 px-1.5 text-[10px] font-medium">{{ __('time.sheet.customer') }}</span>
|
<span class="rounded bg-black/15 px-1.5 text-[10px] font-medium">{{ __('time.sheet.customer') }}</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -254,8 +254,8 @@
|
|||||||
wire:change="saveCell({{ $taskId }}, '{{ $day }}', $event.target.value)"
|
wire:change="saveCell({{ $taskId }}, '{{ $day }}', $event.target.value)"
|
||||||
@error($errorKey) aria-invalid="true" aria-describedby="{{ $fieldId }}-error" @enderror
|
@error($errorKey) aria-invalid="true" aria-describedby="{{ $fieldId }}-error" @enderror
|
||||||
@class([
|
@class([
|
||||||
'h-6 w-12 rounded border px-0.5 text-center font-mono text-[11px] tabular-nums focus-visible:outline-2 focus-visible:outline-primary-600 aria-invalid:border-red-700 dark:focus-visible:outline-primary-300 dark:aria-invalid:border-red-300',
|
'h-7 w-14 rounded border px-0.5 text-center font-mono text-sm font-normal tabular-nums focus-visible:outline-2 focus-visible:outline-primary-600 aria-invalid:border-red-700 dark:focus-visible:outline-primary-300 dark:aria-invalid:border-red-300',
|
||||||
'border-emerald-600 bg-emerald-50 font-semibold text-emerald-900 dark:border-emerald-500/50 dark:bg-emerald-950/50 dark:text-emerald-100' => $quarters > 0,
|
'border-emerald-600 bg-emerald-50 text-emerald-900 dark:border-emerald-500/50 dark:bg-emerald-950/50 dark:text-emerald-100' => $quarters > 0,
|
||||||
'border-slate-400 bg-slate-50 text-slate-700 dark:border-[#5a5e66] dark:bg-[#1b1d20] dark:text-zinc-200' => $quarters === 0,
|
'border-slate-400 bg-slate-50 text-slate-700 dark:border-[#5a5e66] dark:bg-[#1b1d20] dark:text-zinc-200' => $quarters === 0,
|
||||||
])
|
])
|
||||||
/>
|
/>
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
class="flex h-6 w-6 items-center justify-center rounded border border-slate-400 bg-slate-100 text-xs font-bold text-slate-800 transition select-none hover:bg-emerald-100 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#5a5e66] dark:bg-[#1b1d20] dark:text-zinc-100 dark:hover:bg-emerald-500/25 dark:focus-visible:outline-primary-300"
|
class="flex h-6 w-6 items-center justify-center rounded border border-slate-400 bg-slate-100 text-xs font-bold text-slate-800 transition select-none hover:bg-emerald-100 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#5a5e66] dark:bg-[#1b1d20] dark:text-zinc-100 dark:hover:bg-emerald-500/25 dark:focus-visible:outline-primary-300"
|
||||||
>+</button>
|
>+</button>
|
||||||
@else
|
@else
|
||||||
<span class="font-mono text-[11px]">{{ WorkedHours::formatClock($quarters) }}</span>
|
<span class="font-mono text-sm">{{ WorkedHours::formatClock($quarters) }}</span>
|
||||||
@if ($cell?->approved)
|
@if ($cell?->approved)
|
||||||
<x-icon name="check-circle" class="size-3.5" aria-hidden="true" />
|
<x-icon name="check-circle" class="size-3.5" aria-hidden="true" />
|
||||||
<span class="sr-only">{{ __('time.approval.cell_approved') }}</span>
|
<span class="sr-only">{{ __('time.approval.cell_approved') }}</span>
|
||||||
|
|||||||
@@ -134,6 +134,38 @@ it('has no accessibility issues on the Kanban board and no sideways scrolling on
|
|||||||
'mobile, dark' => ['mobile', 'dark'],
|
'mobile, dark' => ['mobile', 'dark'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
it('shows the columns as a carousel on a phone, moved with the stage buttons', function () {
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->on()->mobile()
|
||||||
|
->assertSee('Vaihe 1/')
|
||||||
|
->click('Seuraava vaihe')
|
||||||
|
->wait(1)
|
||||||
|
->assertSee('Vaihe 2/')
|
||||||
|
->assertScript('document.querySelector(".kanban-scroll").scrollLeft > 0', true)
|
||||||
|
->assertScript('document.documentElement.scrollWidth <= window.innerWidth', true)
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('turns the phone carousel towards the edge a card is dragged to', function () {
|
||||||
|
$moveTo = fn (string $edge): string => '(() => { const box = document.querySelector(".kanban-scroll").getBoundingClientRect(); '
|
||||||
|
.'document.dispatchEvent(new PointerEvent("pointermove", { clientX: '.['right' => 'box.right - 5', 'left' => 'box.left + 5', 'centre' => 'box.left + box.width / 2'][$edge].', clientY: box.top + 100 })); return true; })()';
|
||||||
|
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->on()->mobile()
|
||||||
|
->assertSee('Vaihe 1/')
|
||||||
|
->assertScript('(() => { document.body.classList.add("sorting"); return true; })()', true)
|
||||||
|
->assertScript($moveTo('right'), true)
|
||||||
|
->wait(0.6)
|
||||||
|
->assertScript($moveTo('centre'), true)
|
||||||
|
->wait(0.6)
|
||||||
|
->assertSee('Vaihe 2/')
|
||||||
|
->assertScript($moveTo('left'), true)
|
||||||
|
->wait(0.6)
|
||||||
|
->assertScript($moveTo('centre'), true)
|
||||||
|
->wait(0.6)
|
||||||
|
->assertSee('Vaihe 1/');
|
||||||
|
});
|
||||||
|
|
||||||
it('moves a card to another column with the keyboard through the job editor', function () {
|
it('moves a card to another column with the keyboard through the job editor', function () {
|
||||||
visit(route('jobs.board'))
|
visit(route('jobs.board'))
|
||||||
->assertScript('document.querySelector("#column-quotes").textContent.includes("Messuvideo")', true)
|
->assertScript('document.querySelector("#column-quotes").textContent.includes("Messuvideo")', true)
|
||||||
|
|||||||
Reference in New Issue
Block a user