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:
@@ -0,0 +1,46 @@
|
||||
import { cx } from '../internal/cx.js'
|
||||
import { Spinner } from './Spinner.jsx'
|
||||
|
||||
/**
|
||||
* variant: 'primary' | 'secondary' | 'ghost' | 'danger'
|
||||
* size: 'sm' (36px) | 'md' (44px, the touch minimum) | 'lg' (52px)
|
||||
* loading: shows a spinner, disables the button and sets aria-busy
|
||||
* icon / iconEnd: an element (e.g. a lucide icon) before / after the label
|
||||
*/
|
||||
export function Button({
|
||||
variant = 'primary', size = 'md', loading = false, block = false,
|
||||
icon, iconEnd, type = 'button', disabled, className, children, ref, ...rest
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
type={type}
|
||||
className={cx('x-btn', `x-btn--${variant}`, `x-btn--${size}`, block && 'x-btn--block', className)}
|
||||
disabled={disabled || loading}
|
||||
aria-busy={loading || undefined}
|
||||
{...rest}
|
||||
>
|
||||
{loading ? <Spinner size="sm" label={null} /> : icon}
|
||||
{children != null && children !== false && <span className="x-btn__label">{children}</span>}
|
||||
{iconEnd}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/** A square button with only an icon. `label` is required: it becomes aria-label and the tooltip. */
|
||||
export function IconButton({
|
||||
label, variant = 'ghost', size = 'md', type = 'button', className, children, ref, ...rest
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
type={type}
|
||||
aria-label={label}
|
||||
title={label}
|
||||
className={cx('x-btn', 'x-btn--icon', `x-btn--${variant}`, `x-btn--${size}`, className)}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user