meetContrastRequirements(); $this->styleTables(); } /** * Tables as cards: a white (dark: zinc-900) surface with a soft shadow, an indigo-tinted header row and a * row hover. Cell text is zinc-700 / zinc-200 (well over 4.5:1) instead of the package's gray-500. */ private function styleTables(): void { TallStackUi::customize() ->table() ->block('wrapper', 'overflow-hidden rounded-xl bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-900 dark:ring-zinc-700') ->block('table.wrapper', 'relative soft-scrollbar overflow-auto bg-white dark:bg-zinc-900') ->block('table.base', 'min-w-full divide-y divide-zinc-200 dark:divide-zinc-700') ->block('table.th', 'px-3 py-3 text-xs font-semibold tracking-wide text-primary-900 dark:text-primary-100') ->block('table.th-compact', 'px-3 py-2 text-xs font-semibold tracking-wide text-primary-900 dark:text-primary-100') ->block('table.thead.normal', 'bg-primary-50 dark:bg-primary-950/70') ->block('table.tbody', 'divide-y divide-zinc-200 bg-white dark:divide-zinc-700/70 dark:bg-zinc-900') ->block('table.tr', 'transition-colors hover:bg-primary-50/50 dark:hover:bg-white/5') ->block('table.td', 'whitespace-nowrap px-3 py-3 text-sm text-zinc-700 dark:text-zinc-200') ->block('table.td-compact', 'whitespace-nowrap px-3 py-2 text-sm text-zinc-700 dark:text-zinc-200') ->block('empty', 'col-span-full whitespace-nowrap px-3 py-4 text-sm text-zinc-700 dark:text-zinc-200'); } /** * TallStackUI uses red-500 for error text, which is 3.8:1 on white and * below the 4.5:1 WCAG 2.2 AA requires. Darker red in light mode, lighter * red in dark mode. The typed value of a field in error is red-600, which is * 3.8:1 on the dark input background, so inputs and selects change too. */ private function meetContrastRequirements(): void { TallStackUi::customize() ->form('error') ->block('text') ->replace('text-red-500', 'text-red-700 dark:text-red-400'); TallStackUi::customize() ->form('label') ->block('error') ->replace(['text-red-600' => 'text-red-700', 'dark:text-red-500' => 'dark:text-red-400']); TallStackUi::customize() ->form('label') ->block('asterisk') ->replace('text-red-500', 'text-red-700 dark:text-red-400'); TallStackUi::customize() ->form('input') ->block('error') ->replace('text-red-600!', 'text-red-700! dark:!text-red-400'); TallStackUi::customize() ->form('hint') ->block('text') ->replace(['text-gray-500' => 'text-gray-600', 'dark:text-dark-400' => 'dark:text-dark-200']); // Checkbox, radio and toggle labels are dark-400 (#999) in dark mode: 2.3:1 on the dark canvas. TallStackUi::customize() ->wrapper('radio') ->block('label.text') ->replace('dark:text-dark-400', 'dark:text-dark-200'); foreach (['radio.group', 'checkbox.group'] as $selectionGroup) { foreach (['content.description', 'content.aside'] as $block) { TallStackUi::customize() ->form($selectionGroup) ->block($block) ->replace('text-gray-500', 'text-gray-600'); } } TallStackUi::customize() ->select('native') ->block('error') ->replace('text-red-600!', 'text-red-700! dark:!text-red-400'); // Chart axis captions are gray-500 at 10 px, 4.4:1 on the page background. foreach (['axis.y.label', 'axis.y.right.label', 'axis.x.label'] as $block) { TallStackUi::customize('chart') ->block($block) ->replace(['text-gray-500' => 'text-gray-700', 'dark:text-dark-400' => 'dark:text-dark-200', 'text-[0.65rem]' => 'text-xs']); } } }