feat(ui): @xenia/ui design tokens, Tailwind preset and base components

Platform-v2 step 2.3 (APPS_PLATFORM D-15 §9):
- tokens.css: --x- prefixed colours (light/dark/system + 5 venue accent themes),
  spacing, radius, type scale, shadows, motion, z-index; variables only
- components.css: .x-* classes only, no element selectors (new rule CS-16)
- Button, IconButton, Dialog, Sheet, Toast, PinPad, InfoTip, EmptyState,
  Spinner, Field/Input/Textarea/Select, Switch (accessible: focus trap and
  restore, ARIA wiring, 44px targets)
- tailwind-preset.js (adds names only); manager uses it + styles.css, the
  waiter imports tokens.css; existing screens unchanged
- dev-only /ui-gallery in the manager; e2e suite tests/e2e/ui.mjs; unit tests
  for PIN rules and WCAG AA contrast of every token pair, both in run-all

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 19:33:58 +02:00
co-authored by Claude Opus 5.5
parent c7102f1c89
commit 3580f2815c
36 changed files with 1920 additions and 8 deletions
+62
View File
@@ -0,0 +1,62 @@
// Tailwind 3 preset that maps the @xenia/ui tokens (src/tokens.css) to utilities.
//
// // tailwind.config.js
// import xenia from '@xenia/ui/tailwind-preset'
// export default { presets: [xenia], ... }
//
// It only ADDS names that Tailwind doesn't have (bg-surface, text-ink-2, rounded-control,
// shadow-overlay, text-body…), so an app's existing classes keep their meaning. Spacing
// needs nothing: --x-space-N equals Tailwind's default N (4 px steps).
// The app must also load the tokens: import '@xenia/ui/tokens.css' (or styles.css).
const c = name => `rgb(var(--x-${name}-rgb) / <alpha-value>)`
const tone = name => ({ DEFAULT: c(name), fg: c(`${name}-fg`), soft: c(`${name}-soft`), ink: c(`${name}-ink`) })
/** @type {import('tailwindcss').Config} */
export default {
// `dark:` follows the same attribute as the tokens: data-theme="dark", or "system" + OS dark mode
darkMode: ['variant', [
'&:is([data-theme="dark"] *)',
'@media (prefers-color-scheme: dark) { &:is([data-theme="system"] *) }',
]],
theme: {
extend: {
colors: {
canvas: c('canvas'),
surface: { DEFAULT: c('surface'), 2: c('surface-2'), 3: c('surface-3') },
line: { DEFAULT: c('line'), strong: c('line-strong') },
ink: { DEFAULT: c('ink'), 2: c('ink-2'), 3: c('ink-3') },
accent: { DEFAULT: c('accent'), strong: c('accent-strong'), fg: c('accent-fg'), soft: c('accent-soft'), ink: c('accent-ink') },
success: tone('success'),
warning: tone('warning'),
danger: tone('danger'),
info: tone('info'),
},
fontSize: {
caption: ['var(--x-text-caption)', { lineHeight: 'var(--x-leading-caption)' }],
label: ['var(--x-text-label)', { lineHeight: 'var(--x-leading-label)' }],
body: ['var(--x-text-body)', { lineHeight: 'var(--x-leading-body)' }],
'body-lg': ['var(--x-text-body-lg)', { lineHeight: 'var(--x-leading-body-lg)' }],
title: ['var(--x-text-title)', { lineHeight: 'var(--x-leading-title)' }],
heading: ['var(--x-text-heading)', { lineHeight: 'var(--x-leading-heading)' }],
display: ['var(--x-text-display)', { lineHeight: 'var(--x-leading-display)' }],
},
borderRadius: {
control: 'var(--x-radius-control)',
card: 'var(--x-radius-card)',
dialog: 'var(--x-radius-dialog)',
},
boxShadow: {
raised: 'var(--x-shadow-raised)',
popover: 'var(--x-shadow-popover)',
overlay: 'var(--x-shadow-overlay)',
focus: 'var(--x-focus-ring)',
},
minHeight: { control: 'var(--x-control-md)' },
height: { 'control-sm': 'var(--x-control-sm)', control: 'var(--x-control-md)', 'control-lg': 'var(--x-control-lg)' },
transitionDuration: { fast: 'var(--x-duration-fast)', base: 'var(--x-duration-base)' },
transitionTimingFunction: { xenia: 'var(--x-ease)' },
zIndex: { overlay: 'var(--x-z-overlay)', toast: 'var(--x-z-toast)', popover: 'var(--x-z-popover)' },
},
},
}