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]>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Domain\Exceptions;
|
||||
|
||||
final class InvalidHexColor extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The colour must be a hex colour like #1d4ed8.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Shared\Domain\ValueObjects;
|
||||
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidHexColor;
|
||||
|
||||
/**
|
||||
* An sRGB colour as #rrggbb (lower case), e.g. a customer's card header
|
||||
* colour or a Kanban column colour.
|
||||
*
|
||||
* Text on a coloured surface is dark or white, whichever has the higher
|
||||
* WCAG contrast. The Kanban design (docs/ui-kanban-board.md 1.2) names a
|
||||
* luminance limit of 0.36, but that leaves white text below 4.5:1 on mid
|
||||
* tones; the crossover of the two contrasts (about 0.18) keeps every colour
|
||||
* at 4.5:1 or more.
|
||||
*/
|
||||
final readonly class HexColor
|
||||
{
|
||||
public const string DARK_TEXT = '#000000';
|
||||
|
||||
public const string LIGHT_TEXT = '#ffffff';
|
||||
|
||||
public string $value;
|
||||
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$value = strtolower(trim($value));
|
||||
|
||||
if (preg_match('/^#[0-9a-f]{3}$/', $value) === 1) {
|
||||
$value = '#'.$value[1].$value[1].$value[2].$value[2].$value[3].$value[3];
|
||||
}
|
||||
|
||||
if (preg_match('/^#[0-9a-f]{6}$/', $value) !== 1) {
|
||||
throw new InvalidHexColor;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public static function fromRgb(int $red, int $green, int $blue): self
|
||||
{
|
||||
$channel = static fn (int $value): string => str_pad(dechex(max(0, min(255, $value))), 2, '0', STR_PAD_LEFT);
|
||||
|
||||
return new self('#'.$channel($red).$channel($green).$channel($blue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: int, 1: int, 2: int}
|
||||
*/
|
||||
public function rgb(): array
|
||||
{
|
||||
return [
|
||||
(int) hexdec(substr($this->value, 1, 2)),
|
||||
(int) hexdec(substr($this->value, 3, 2)),
|
||||
(int) hexdec(substr($this->value, 5, 2)),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* WCAG relative luminance, 0 (black) to 1 (white).
|
||||
*/
|
||||
public function luminance(): float
|
||||
{
|
||||
[$red, $green, $blue] = array_map(static function (int $value): float {
|
||||
$channel = $value / 255;
|
||||
|
||||
return $channel <= 0.03928 ? $channel / 12.92 : (($channel + 0.055) / 1.055) ** 2.4;
|
||||
}, $this->rgb());
|
||||
|
||||
return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue;
|
||||
}
|
||||
|
||||
public function isLight(): bool
|
||||
{
|
||||
$dark = new self(self::DARK_TEXT);
|
||||
$light = new self(self::LIGHT_TEXT);
|
||||
|
||||
return $this->contrastWith($dark) > $this->contrastWith($light);
|
||||
}
|
||||
|
||||
/**
|
||||
* The text colour for a surface of this colour.
|
||||
*/
|
||||
public function textColor(): string
|
||||
{
|
||||
return $this->isLight() ? self::DARK_TEXT : self::LIGHT_TEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* WCAG contrast ratio against another colour, 1 to 21.
|
||||
*/
|
||||
public function contrastWith(self $other): float
|
||||
{
|
||||
$lighter = max($this->luminance(), $other->luminance());
|
||||
$darker = min($this->luminance(), $other->luminance());
|
||||
|
||||
return ($lighter + 0.05) / ($darker + 0.05);
|
||||
}
|
||||
|
||||
/**
|
||||
* This colour mixed into $base: $share of this colour, the rest of $base.
|
||||
*/
|
||||
public function mixedInto(self $base, float $share): self
|
||||
{
|
||||
$share = max(0.0, min(1.0, $share));
|
||||
[$red, $green, $blue] = $this->rgb();
|
||||
[$baseRed, $baseGreen, $baseBlue] = $base->rgb();
|
||||
|
||||
return self::fromRgb(
|
||||
(int) round($baseRed * (1 - $share) + $red * $share),
|
||||
(int) round($baseGreen * (1 - $share) + $green * $share),
|
||||
(int) round($baseBlue * (1 - $share) + $blue * $share),
|
||||
);
|
||||
}
|
||||
|
||||
public function equals(self $other): bool
|
||||
{
|
||||
return $this->value === $other->value;
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-lg space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="building-office">{{ __('company.title') }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('company.intro') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('company.intro') }}</p>
|
||||
</div>
|
||||
|
||||
<p role="status" aria-live="polite" class="text-sm font-medium">{{ $statusMessage }}</p>
|
||||
|
||||
@@ -162,7 +162,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-4xl space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="sun">{{ __('holidays.title') }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('holidays.intro') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('holidays.intro') }}</p>
|
||||
<p class="text-sm"><x-link :href="route('settings.company')" navigate>{{ __('company.title') }}</x-link></p>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user