Files
Toiminnanohjaus/resources/views/components/color-picker.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

135 lines
6.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{--
One colour picker dialog per page (native <dialog> + showModal(), like
<x-confirm-dialog>): quick colours, the browser's colour input and R/G/B
fields 0–255 kept in step. Any button opens it with
x-on:click="$dispatch('color-picker:open', { id: 'colour-picker', title: '…', color: '#1d4ed8', method: 'setColumnColor', args: ['order'] })"
"Use colour" calls the Livewire method with the args and the chosen
#rrggbb; "Restore default colour" (when `resettable` is true in the
event) calls it with null. Closing returns focus to the opening button.
--}}
@props([
'id' => 'colour-picker',
'presets' => ['#1d4ed8', '#23476a', '#0f5c63', '#14532d', '#047857', '#3b2d5e', '#7c2d2d', '#b91c1c', '#9a3412', '#78350f', '#b45309', '#374151'],
])
<dialog
id="{{ $id }}"
aria-labelledby="{{ $id }}-title"
wire:ignore
x-data="{
title: '',
hex: '#1d4ed8',
r: 29, g: 78, b: 216,
method: null,
args: [],
resettable: false,
open(detail) {
if (detail.id !== '{{ $id }}') { return; }
this.title = detail.title ?? '';
this.method = detail.method;
this.args = detail.args ?? [];
this.resettable = detail.resettable ?? false;
this.setHex(detail.color ?? '#1d4ed8');
this.$el.showModal();
},
setHex(value) {
if (! /^#[0-9a-fA-F]{6}$/.test(value)) { return; }
this.hex = value.toLowerCase();
const n = parseInt(this.hex.slice(1), 16);
this.r = (n >> 16) & 255; this.g = (n >> 8) & 255; this.b = n & 255;
},
fromRgb() {
const c = (v) => Math.max(0, Math.min(255, Math.round(Number(v) || 0))).toString(16).padStart(2, '0');
this.hex = '#' + c(this.r) + c(this.g) + c(this.b);
},
apply(color) {
if (this.method) { $wire.call(this.method, ...this.args, color); }
this.$el.close();
},
}"
x-on:color-picker:open.window="open($event.detail)"
class="m-auto w-[calc(100%-2rem)] max-w-xs rounded-xl border border-neutral-300 bg-white p-4 text-neutral-900 shadow-2xl backdrop:bg-black/60 dark:border-[#3e4249] dark:bg-[#282a2e] dark:text-neutral-100"
>
<div class="flex items-center justify-between gap-2">
<h2 id="{{ $id }}-title" class="text-sm font-bold" x-text="title"></h2>
<button
type="button"
x-on:click="$el.closest('dialog').close()"
aria-label="{{ __('layout.close') }}"
class="inline-flex size-7 items-center justify-center rounded-md text-neutral-600 hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-neutral-200 dark:hover:bg-white/10 dark:focus-visible:outline-primary-300"
>
<x-icon name="x-mark" class="size-4" aria-hidden="true" />
</button>
</div>
<fieldset class="mt-3">
<legend class="mb-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-200">{{ __('layout.color_picker.presets') }}</legend>
<div class="grid grid-cols-6 gap-1.5">
@foreach ($presets as $preset)
<button
type="button"
x-on:click="setHex('{{ $preset }}')"
x-bind:aria-pressed="(hex === '{{ $preset }}').toString()"
aria-label="{{ __('layout.color_picker.preset', ['color' => $preset]) }}"
style="background-color: {{ $preset }}"
class="h-7 w-full rounded-md border border-black/40 transition hover:scale-105 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 aria-pressed:ring-2 aria-pressed:ring-neutral-900 aria-pressed:ring-offset-1 dark:border-white/40 dark:focus-visible:outline-primary-300 dark:aria-pressed:ring-white dark:aria-pressed:ring-offset-[#282a2e]"
></button>
@endforeach
</div>
</fieldset>
<div class="mt-3 space-y-2.5 border-t border-neutral-200 pt-3 dark:border-[#36393f]">
<div class="flex items-center justify-between gap-2">
<label for="{{ $id }}-native" class="text-xs font-medium text-neutral-700 dark:text-neutral-200">{{ __('layout.color_picker.free') }}</label>
<div class="flex items-center gap-2">
<span class="font-mono text-xs uppercase text-neutral-700 dark:text-neutral-200" x-text="hex"></span>
<input
type="color"
id="{{ $id }}-native"
x-bind:value="hex"
x-on:input="setHex($event.target.value)"
class="h-8 w-9 cursor-pointer rounded border border-neutral-400 bg-transparent p-0 dark:border-[#6b7079]"
/>
</div>
</div>
<div class="grid grid-cols-3 gap-2">
@foreach (['r' => 'red', 'g' => 'green', 'b' => 'blue'] as $channel => $key)
<div>
<label for="{{ $id }}-{{ $channel }}" class="mb-0.5 block text-[11px] font-bold text-neutral-700 dark:text-neutral-200">{{ __('layout.color_picker.'.$key) }}</label>
<input
type="number"
id="{{ $id }}-{{ $channel }}"
min="0"
max="255"
x-model.number="{{ $channel }}"
x-on:input="fromRgb()"
class="w-full rounded-md border border-neutral-400 bg-neutral-50 px-2 py-1 font-mono text-xs text-neutral-900 dark:border-[#6b7079] dark:bg-[#18191b] dark:text-white"
/>
</div>
@endforeach
</div>
<p class="flex items-center gap-2 text-xs text-neutral-700 dark:text-neutral-200">
<span>{{ __('layout.color_picker.preview') }}:</span>
<span class="inline-block h-5 w-12 rounded border border-black/40 dark:border-white/40" x-bind:style="'background-color: ' + hex" aria-hidden="true"></span>
</p>
</div>
<div class="mt-4 flex flex-wrap justify-end gap-2">
<x-button
x-show="resettable"
x-cloak
subtle
color="black"
sm
:text="__('layout.color_picker.reset')"
x-on:click="apply(null)"
/>
<x-button subtle color="black" sm :text="__('layout.cancel')" x-on:click="$el.closest('dialog').close()" />
<x-button sm :text="__('layout.color_picker.apply')" x-on:click="apply(hex)" />
</div>
</dialog>