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:
+5
-1
@@ -49,6 +49,7 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r
|
|||||||
| `install.sh` | Site installer. **Writes its own copy of the proxy config.** |
|
| `install.sh` | Site installer. **Writes its own copy of the proxy config.** |
|
||||||
| `docker-compose.yml` / `docker-compose.dev.yml` | Prod (pull images) / dev override (build + expose ports) |
|
| `docker-compose.yml` / `docker-compose.dev.yml` | Prod (pull images) / dev override (build + expose ports) |
|
||||||
| `package.json`, `package-lock.json`, `packages/` | **npm workspace** for the frontends (D-15): `waiter_pwa`, `manager_dashboard` and the shared `packages/{ui,i18n,api,access}` (imported from source, no build step). One lockfile at this root; the apps have none of their own. |
|
| `package.json`, `package-lock.json`, `packages/` | **npm workspace** for the frontends (D-15): `waiter_pwa`, `manager_dashboard` and the shared `packages/{ui,i18n,api,access}` (imported from source, no build step). One lockfile at this root; the apps have none of their own. |
|
||||||
|
| `packages/ui/` | Shared design tokens, Tailwind preset and base components (CS-16). Visual check: `npm run dev:manager` → `/ui-gallery` |
|
||||||
| `.dockerignore` | The frontend images build with **`client-services/` as context** (`-f waiter_pwa/Dockerfile .`), so this file decides what Docker sees. The backend still builds from `local_backend/`. |
|
| `.dockerignore` | The frontend images build with **`client-services/` as context** (`-f waiter_pwa/Dockerfile .`), so this file decides what Docker sees. The backend still builds from `local_backend/`. |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -144,7 +145,7 @@ The native plugins (`@capacitor/*`, `@capgo/*`) are pinned to **exact** versions
|
|||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
Automated tests cover the native-app/LAN work and licensing. See **[tests/e2e/README.md](../tests/e2e/README.md)**.
|
Automated tests cover the native-app/LAN work and licensing. See **[tests/e2e/README.md](../tests/e2e/README.md)**.
|
||||||
- **Unit (seconds):** `python -m pytest tests -q` in `local_backend/`, and `npm test` in `waiter_pwa/`.
|
- **Unit (seconds):** `python -m pytest tests -q` in `local_backend/`, `npm test` in `waiter_pwa/`, and `npm test -w @xenia/ui` at the workspace root.
|
||||||
- **End-to-end:** `node run-all.mjs` in `tests/e2e/`. That covers install.sh, licensing with a real cloud, browser modes, and the Android emulator suites. `--no-android` skips the emulator.
|
- **End-to-end:** `node run-all.mjs` in `tests/e2e/`. That covers install.sh, licensing with a real cloud, browser modes, and the Android emulator suites. `--no-android` skips the emulator.
|
||||||
|
|
||||||
**CS-11. Tests follow the code.** When you change something a test covers (licensing, LAN IP, TLS, pairing, rediscovery, bundles, install.sh, the proxy config), run its suite and update the test in the same commit. Run `node run-all.mjs` before every release.
|
**CS-11. Tests follow the code.** When you change something a test covers (licensing, LAN IP, TLS, pairing, rediscovery, bundles, install.sh, the proxy config), run its suite and update the test in the same commit. Run `node run-all.mjs` before every release.
|
||||||
@@ -160,6 +161,9 @@ Use `core.access.deps.require("<module>.<area>.<action>")` (or `require_any`, `p
|
|||||||
Paired devices (D-8, `routers/devices.py`, `core/access/context.py`) send `X-Xenia-Device: <token>`; a device may only use keys matching its app's `DeviceApp.scope` (plus `<app>.*`) and only reach routes of those modules. A new device app with user logins must declare `<app>.access`. Device-only endpoints use `require_device("<app>")`; users log in on a device with `POST /api/auth/login {client: "terminal"}`, and that session only works together with the device's header.
|
Paired devices (D-8, `routers/devices.py`, `core/access/context.py`) send `X-Xenia-Device: <token>`; a device may only use keys matching its app's `DeviceApp.scope` (plus `<app>.*`) and only reach routes of those modules. A new device app with user logins must declare `<app>.access`. Device-only endpoints use `require_device("<app>")`; users log in on a device with `POST /api/auth/login {client: "terminal"}`, and that session only works together with the device's header.
|
||||||
Manager override (D-10, `core/access/override.py`): mark a key `Perm(..., overridable=True)` and a user without it gets `access.override_possible`; the client gets a manager's one-time token from `POST /api/access/override {key, username, pin}` and retries with `X-Xenia-Override`. `require()` routes handle it in `check()`; an endpoint with its own rule calls `require_override(request, db, key, target="order:12")` where the rule says no, **after** its other checks (a used token is spent).
|
Manager override (D-10, `core/access/override.py`): mark a key `Perm(..., overridable=True)` and a user without it gets `access.override_possible`; the client gets a manager's one-time token from `POST /api/access/override {key, username, pin}` and retries with `X-Xenia-Override`. `require()` routes handle it in `check()`; an endpoint with its own rule calls `require_override(request, db, key, target="order:12")` where the rule says no, **after** its other checks (a used token is spent).
|
||||||
|
|
||||||
|
**CS-16. Shared UI lives in `packages/ui` and never restyles an app** (branch `platform-v2`, D-15, §9).
|
||||||
|
Design tokens are CSS variables prefixed `--x-` (`packages/ui/src/tokens.css`), components use `.x-*` classes (`src/components.css`); neither file has element selectors, resets or anything that applies outside `.x-*` (the waiter keeps its own `--bg`/`--text`…; the manager's Tailwind classes keep their meaning). Theme comes from `data-theme` (`light`/`dark`/`system`) and `data-venue-theme` on `<html>`. Tailwind apps use `@xenia/ui/tailwind-preset` (adds `bg-surface`, `text-ink-2`, `rounded-control`… only). A colour change must pass `npm test -w @xenia/ui` (WCAG AA for every pair the components use, every venue theme, light and dark). Components take their visible text as props with English defaults until `@xenia/i18n` (2.4). New components get a section in `packages/ui/gallery/Gallery.jsx` (dev-only `/ui-gallery` in the manager) and checks in `tests/e2e/ui.mjs`.
|
||||||
|
|
||||||
**CS-15. Support access is a challenge code, never a password** (branch `platform-v2`, D-16).
|
**CS-15. Support access is a challenge code, never a password** (branch `platform-v2`, D-16).
|
||||||
There is no master account. A site's `SUPPORT_SECRET` (env only) comes from `tools/support_code.py --site-secret <SITE_ID>`, derived from the builder's master key in `%USERPROFILE%\.xenia\support_master_key.txt` (outside the repo, back it up). The derivation lives in `local_backend/core/support_codes.py` (stdlib only, the tool loads it by path) and is re-implemented for the e2e suites in `tests/e2e/lib/support.mjs`; `tests/test_support.py` pins a vector both must match. The e2e backends log in through support access (`login()` in `lib/proc.mjs`).
|
There is no master account. A site's `SUPPORT_SECRET` (env only) comes from `tools/support_code.py --site-secret <SITE_ID>`, derived from the builder's master key in `%USERPROFILE%\.xenia\support_master_key.txt` (outside the repo, back it up). The derivation lives in `local_backend/core/support_codes.py` (stdlib only, the tool loads it by path) and is re-implemented for the e2e suites in `tests/e2e/lib/support.mjs`; `tests/test_support.py` pins a vector both must match. The e2e backends log in through support access (`login()` in `lib/proc.mjs`).
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.62.0",
|
"@tanstack/react-query": "^5.62.0",
|
||||||
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"lucide-react": "^1.14.0",
|
"lucide-react": "^1.14.0",
|
||||||
"qrcode.react": "^4.2.0",
|
"qrcode.react": "^4.2.0",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { lazy, Suspense, useEffect, useState } from 'react'
|
||||||
import { BrowserRouter, Routes, Route, Navigate, useNavigate } from 'react-router-dom'
|
import { BrowserRouter, Routes, Route, Navigate, useNavigate } from 'react-router-dom'
|
||||||
import useAuthStore from './store/authStore'
|
import useAuthStore from './store/authStore'
|
||||||
import AppLayout from './layouts/AppLayout'
|
import AppLayout from './layouts/AppLayout'
|
||||||
@@ -54,6 +54,9 @@ import SettingsPage from './pages/Settings/SettingsPage'
|
|||||||
import NotesPage from './pages/NotesPage'
|
import NotesPage from './pages/NotesPage'
|
||||||
import PermissionGuard from './components/PermissionGuard'
|
import PermissionGuard from './components/PermissionGuard'
|
||||||
|
|
||||||
|
// @xenia/ui visual check page, dev builds only (left out of production bundles)
|
||||||
|
const UiGallery = import.meta.env.DEV ? lazy(() => import('@xenia/ui/gallery')) : null
|
||||||
|
|
||||||
function Spinner() {
|
function Spinner() {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-slate-50 flex items-center justify-center">
|
<div className="min-h-screen bg-slate-50 flex items-center justify-center">
|
||||||
@@ -109,6 +112,7 @@ export default function App() {
|
|||||||
<AuthRehydrator>
|
<AuthRehydrator>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/setup" element={<SetupWizard />} />
|
<Route path="/setup" element={<SetupWizard />} />
|
||||||
|
{UiGallery && <Route path="/ui-gallery" element={<Suspense fallback={null}><UiGallery /></Suspense>} />}
|
||||||
<Route path="/login" element={<SetupGuard><LoginPage /></SetupGuard>} />
|
<Route path="/login" element={<SetupGuard><LoginPage /></SetupGuard>} />
|
||||||
<Route path="/kds" element={<RequireAuth><KdsPage /></RequireAuth>} />
|
<Route path="/kds" element={<RequireAuth><KdsPage /></RequireAuth>} />
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client'
|
|||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||||
import { Toaster } from 'react-hot-toast'
|
import { Toaster } from 'react-hot-toast'
|
||||||
import App from './App.jsx'
|
import App from './App.jsx'
|
||||||
|
import '@xenia/ui/styles.css' // shared tokens + component styles (.x-*), no global rules
|
||||||
import './index.css'
|
import './index.css'
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient({
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
import xenia from '@xenia/ui/tailwind-preset'
|
||||||
|
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
export default {
|
export default {
|
||||||
|
// Shared design tokens (bg-surface, text-ink-2, rounded-control…); adds names only
|
||||||
|
presets: [xenia],
|
||||||
content: ['./index.html', './src/**/*.{js,jsx}'],
|
content: ['./index.html', './src/**/*.{js,jsx}'],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
|
|||||||
Generated
+7
-1
@@ -16,6 +16,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.62.0",
|
"@tanstack/react-query": "^5.62.0",
|
||||||
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"lucide-react": "^1.14.0",
|
"lucide-react": "^1.14.0",
|
||||||
"qrcode.react": "^4.2.0",
|
"qrcode.react": "^4.2.0",
|
||||||
@@ -2880,7 +2881,11 @@
|
|||||||
},
|
},
|
||||||
"packages/ui": {
|
"packages/ui": {
|
||||||
"name": "@xenia/ui",
|
"name": "@xenia/ui",
|
||||||
"version": "0.0.0"
|
"version": "0.0.0",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19.0.0",
|
||||||
|
"react-dom": "^19.0.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"waiter_pwa": {
|
"waiter_pwa": {
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
@@ -2890,6 +2895,7 @@
|
|||||||
"@capacitor/core": "8.5.2",
|
"@capacitor/core": "8.5.2",
|
||||||
"@capgo/capacitor-updater": "8.51.25",
|
"@capgo/capacitor-updater": "8.51.25",
|
||||||
"@tanstack/react-query": "^5.100.11",
|
"@tanstack/react-query": "^5.100.11",
|
||||||
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.15.1",
|
"axios": "^1.15.1",
|
||||||
"dexie": "^4.4.2",
|
"dexie": "^4.4.2",
|
||||||
"qr-scanner": "^1.4.2",
|
"qr-scanner": "^1.4.2",
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
// Visual check page for @xenia/ui (plan step 2.3). Dev builds only: the manager mounts
|
||||||
|
// it at /ui-gallery under `import.meta.env.DEV` (moves to the terminal dev build in 3.1).
|
||||||
|
// Sets data-theme / data-venue-theme on <html> while open and restores them on leave.
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import {
|
||||||
|
Button, Dialog, EmptyState, Field, IconButton, InfoTip, Input, PinPad, Select, Sheet,
|
||||||
|
Spinner, Switch, Textarea, ToastProvider, useToast,
|
||||||
|
} from '../src/index.js'
|
||||||
|
import '../src/styles.css'
|
||||||
|
|
||||||
|
const THEMES = ['light', 'dark', 'system']
|
||||||
|
const VENUES = ['teal', 'amber', 'blue', 'violet', 'rose']
|
||||||
|
|
||||||
|
const Plus = () => (
|
||||||
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14" /></svg>
|
||||||
|
)
|
||||||
|
const Trash = () => (
|
||||||
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14" /></svg>
|
||||||
|
)
|
||||||
|
const Inbox = () => (
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M22 12h-6l-2 3h-4l-2-3H2" /><path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" /></svg>
|
||||||
|
)
|
||||||
|
|
||||||
|
const page = {
|
||||||
|
minHeight: '100vh', background: 'var(--x-canvas)', color: 'var(--x-ink)',
|
||||||
|
fontFamily: 'var(--x-font-sans)', fontSize: 'var(--x-text-body)', padding: 'var(--x-space-6)',
|
||||||
|
}
|
||||||
|
const card = {
|
||||||
|
background: 'var(--x-surface)', border: '1px solid var(--x-line)', borderRadius: 'var(--x-radius-card)',
|
||||||
|
boxShadow: 'var(--x-shadow-raised)', padding: 'var(--x-space-6)', marginBottom: 'var(--x-space-6)',
|
||||||
|
}
|
||||||
|
const row = { display: 'flex', flexWrap: 'wrap', gap: 'var(--x-space-3)', alignItems: 'center' }
|
||||||
|
const h2 = { margin: '0 0 var(--x-space-4)', fontSize: 'var(--x-text-title)', fontWeight: 600 }
|
||||||
|
|
||||||
|
function Section({ title, children }) {
|
||||||
|
return <section style={card} data-section={title}><h2 style={h2}>{title}</h2>{children}</section>
|
||||||
|
}
|
||||||
|
|
||||||
|
function Demo() {
|
||||||
|
const toast = useToast()
|
||||||
|
const [theme, setTheme] = useState('light')
|
||||||
|
const [venue, setVenue] = useState('teal')
|
||||||
|
const [dialog, setDialog] = useState(false)
|
||||||
|
const [locked, setLocked] = useState(false)
|
||||||
|
const [sheet, setSheet] = useState(null)
|
||||||
|
const [on, setOn] = useState(true)
|
||||||
|
const [off, setOff] = useState(false)
|
||||||
|
const [name, setName] = useState('')
|
||||||
|
const [lang, setLang] = useState('el')
|
||||||
|
const [pinError, setPinError] = useState('')
|
||||||
|
const [unlocked, setUnlocked] = useState('')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const html = document.documentElement
|
||||||
|
const before = [html.getAttribute('data-theme'), html.getAttribute('data-venue-theme')]
|
||||||
|
html.setAttribute('data-theme', theme)
|
||||||
|
html.setAttribute('data-venue-theme', venue)
|
||||||
|
return () => {
|
||||||
|
before[0] == null ? html.removeAttribute('data-theme') : html.setAttribute('data-theme', before[0])
|
||||||
|
before[1] == null ? html.removeAttribute('data-venue-theme') : html.setAttribute('data-venue-theme', before[1])
|
||||||
|
}
|
||||||
|
}, [theme, venue])
|
||||||
|
|
||||||
|
const checkPin = pin => new Promise((resolve, reject) => setTimeout(() => {
|
||||||
|
if (pin === '1234') { setPinError(''); setUnlocked(`Unlocked at ${new Date().toLocaleTimeString()}`); resolve() }
|
||||||
|
else { setPinError('Wrong PIN'); reject(new Error('wrong')) }
|
||||||
|
}, 500))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={page}>
|
||||||
|
<div style={{ ...row, justifyContent: 'space-between', marginBottom: 'var(--x-space-6)' }}>
|
||||||
|
<h1 style={{ margin: 0, fontSize: 'var(--x-text-heading)', fontWeight: 700 }}>@xenia/ui gallery</h1>
|
||||||
|
<div style={row}>
|
||||||
|
<Select aria-label="Theme" size="sm" value={theme} onChange={e => setTheme(e.target.value)} options={THEMES.map(t => ({ value: t, label: `Theme: ${t}` }))} />
|
||||||
|
<Select aria-label="Venue theme" size="sm" value={venue} onChange={e => setVenue(e.target.value)} options={VENUES.map(v => ({ value: v, label: `Venue: ${v}` }))} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Section title="Buttons">
|
||||||
|
<div style={row}>
|
||||||
|
<Button>Primary</Button>
|
||||||
|
<Button variant="secondary">Secondary</Button>
|
||||||
|
<Button variant="ghost">Ghost</Button>
|
||||||
|
<Button variant="danger" icon={<Trash />}>Delete</Button>
|
||||||
|
<Button loading>Saving</Button>
|
||||||
|
<Button disabled>Disabled</Button>
|
||||||
|
<Button size="sm" icon={<Plus />}>Small</Button>
|
||||||
|
<Button size="lg">Large</Button>
|
||||||
|
<IconButton label="Add"><Plus /></IconButton>
|
||||||
|
<IconButton label="Delete" variant="danger"><Trash /></IconButton>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section title="Dialog, Sheet, Toast">
|
||||||
|
<div style={row}>
|
||||||
|
<Button variant="secondary" onClick={() => setDialog(true)}>Open dialog</Button>
|
||||||
|
<Button variant="secondary" onClick={() => setLocked(true)}>Non-dismissible dialog</Button>
|
||||||
|
<Button variant="secondary" onClick={() => setSheet('bottom')}>Bottom sheet</Button>
|
||||||
|
<Button variant="secondary" onClick={() => setSheet('right')}>Side sheet</Button>
|
||||||
|
<Button variant="ghost" onClick={() => toast.success('Saved', { description: 'Product updated' })}>Toast: success</Button>
|
||||||
|
<Button variant="ghost" onClick={() => toast.error('Printer offline', { description: 'Bar printer did not answer' })}>Toast: danger</Button>
|
||||||
|
<Button variant="ghost" onClick={() => toast.show({ title: 'Order moved to table 4', action: { label: 'Undo', onClick: () => toast.info('Undone') } })}>Toast: action</Button>
|
||||||
|
</div>
|
||||||
|
<Dialog
|
||||||
|
open={dialog} onClose={() => setDialog(false)} title="Delete product?"
|
||||||
|
description="Freddo espresso will be removed from every category."
|
||||||
|
footer={<><Button variant="secondary" onClick={() => setDialog(false)}>Cancel</Button><Button variant="danger" onClick={() => { setDialog(false); toast.success('Deleted') }}>Delete</Button></>}
|
||||||
|
>
|
||||||
|
<Field label="Type DELETE to confirm"><Input placeholder="DELETE" /></Field>
|
||||||
|
</Dialog>
|
||||||
|
<Dialog
|
||||||
|
open={locked} dismissible={false} title="Finish the close of day" size="sm"
|
||||||
|
footer={<Button onClick={() => setLocked(false)}>Done</Button>}
|
||||||
|
>
|
||||||
|
Escape and the backdrop don't close this one.
|
||||||
|
</Dialog>
|
||||||
|
<Sheet
|
||||||
|
open={!!sheet} side={sheet || 'bottom'} onClose={() => setSheet(null)} title="Move order"
|
||||||
|
footer={<Button block onClick={() => setSheet(null)}>Move</Button>}
|
||||||
|
>
|
||||||
|
<Field label="To table"><Select placeholder="Choose…" defaultValue="" options={[1, 2, 3, 4].map(n => ({ value: String(n), label: `Table ${n}` }))} /></Field>
|
||||||
|
</Sheet>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section title="Fields">
|
||||||
|
<div style={{ display: 'grid', gap: 'var(--x-space-4)', gridTemplateColumns: 'repeat(auto-fit, minmax(260px, 1fr))' }}>
|
||||||
|
<Field label="Product name" hint="Shown on tickets and the QR menu" required>
|
||||||
|
<Input value={name} onChange={e => setName(e.target.value)} placeholder="e.g. Freddo espresso" />
|
||||||
|
</Field>
|
||||||
|
<Field label="Price" error="Enter a price, e.g. 3,50">
|
||||||
|
<Input inputMode="decimal" defaultValue="3,5x" />
|
||||||
|
</Field>
|
||||||
|
<Field label="Language" info={<InfoTip>The language staff screens start in. Each person can change their own.</InfoTip>}>
|
||||||
|
<Select value={lang} onChange={e => setLang(e.target.value)} options={[{ value: 'el', label: 'Ελληνικά' }, { value: 'en', label: 'English' }]} />
|
||||||
|
</Field>
|
||||||
|
<Field label="Notes"><Textarea placeholder="Allergies, preparation…" /></Field>
|
||||||
|
<Field label="Disabled"><Input disabled value="Read only" /></Field>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section title="Switch + InfoTip">
|
||||||
|
<div style={{ display: 'grid', gap: 'var(--x-space-4)', maxWidth: 520 }}>
|
||||||
|
<Switch checked={on} onChange={setOn} label="Print kitchen tickets" description="Send new items to the kitchen printer." />
|
||||||
|
<Switch checked={off} onChange={setOff} label="Alert after print failures" />
|
||||||
|
<Switch checked disabled label="Disabled (on)" />
|
||||||
|
<div style={row}>Alert after <InfoTip side="bottom">How many failed print attempts before managers are notified. 0 turns the alert off.</InfoTip></div>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section title="PinPad (1234 unlocks)">
|
||||||
|
<div style={{ ...row, alignItems: 'flex-start', gap: 'var(--x-space-12)' }}>
|
||||||
|
<PinPad title="Enter PIN" onComplete={checkPin} error={pinError} />
|
||||||
|
<div style={{ color: 'var(--x-ink-2)' }} data-testid="pin-result">{unlocked}</div>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section title="Spinner + EmptyState">
|
||||||
|
<div style={row}><Spinner size="sm" /><Spinner /><Spinner size="lg" /></div>
|
||||||
|
<EmptyState icon={<Inbox />} title="No online orders yet" description="New orders from the QR menu appear here." action={<Button variant="secondary">Menu settings</Button>} />
|
||||||
|
</Section>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Gallery() {
|
||||||
|
return <ToastProvider><Demo /></ToastProvider>
|
||||||
|
}
|
||||||
@@ -6,6 +6,20 @@
|
|||||||
"description": "Design tokens (CSS variables), the Tailwind preset and base components (plan step 2.3).",
|
"description": "Design tokens (CSS variables), the Tailwind preset and base components (plan step 2.3).",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.js"
|
".": "./src/index.js",
|
||||||
|
"./tokens.css": "./src/tokens.css",
|
||||||
|
"./styles.css": "./src/styles.css",
|
||||||
|
"./tailwind-preset": "./tailwind-preset.js",
|
||||||
|
"./gallery": "./gallery/Gallery.jsx"
|
||||||
|
},
|
||||||
|
"sideEffects": [
|
||||||
|
"*.css"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "node --test \"tests/*.test.mjs\""
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19.0.0",
|
||||||
|
"react-dom": "^19.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,297 @@
|
|||||||
|
/*
|
||||||
|
* @xenia/ui component styles. Uses only the tokens (tokens.css) and .x-* classes:
|
||||||
|
* no element selectors and no resets, so loading it never restyles an app's own screens.
|
||||||
|
* Text inherits the app's font; sizes and colours come from the tokens.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.x-visually-hidden {
|
||||||
|
position: absolute !important;
|
||||||
|
width: 1px; height: 1px; padding: 0; margin: -1px;
|
||||||
|
overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.x-dialog, .x-sheet, .x-toast, .x-input, .x-select__control { color-scheme: var(--x-color-scheme); }
|
||||||
|
|
||||||
|
/* ── Spinner ─────────────────────────────────────────────────────────────── */
|
||||||
|
.x-spinner { display: inline-flex; flex-shrink: 0; color: currentColor; }
|
||||||
|
.x-spinner svg { width: 100%; height: 100%; animation: x-spin 0.8s linear infinite; }
|
||||||
|
.x-spinner--sm { width: 16px; height: 16px; }
|
||||||
|
.x-spinner--md { width: 24px; height: 24px; }
|
||||||
|
.x-spinner--lg { width: 40px; height: 40px; }
|
||||||
|
@keyframes x-spin { to { transform: rotate(360deg); } }
|
||||||
|
@media (prefers-reduced-motion: reduce) { .x-spinner svg { animation-duration: 2.4s; } }
|
||||||
|
|
||||||
|
/* ── Button ──────────────────────────────────────────────────────────────── */
|
||||||
|
.x-btn {
|
||||||
|
display: inline-flex; align-items: center; justify-content: center; gap: var(--x-space-2);
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-height: var(--x-control-md); padding: 0 var(--x-space-4);
|
||||||
|
border: 1px solid transparent; border-radius: var(--x-radius-control);
|
||||||
|
font: inherit; font-size: var(--x-text-body); line-height: var(--x-leading-body); font-weight: var(--x-weight-semibold);
|
||||||
|
white-space: nowrap; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
|
||||||
|
transition: background-color var(--x-duration-fast) var(--x-ease), border-color var(--x-duration-fast) var(--x-ease),
|
||||||
|
color var(--x-duration-fast) var(--x-ease), transform var(--x-duration-fast) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-btn:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||||
|
.x-btn:active:not(:disabled) { transform: scale(0.98); }
|
||||||
|
.x-btn:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||||
|
.x-btn[aria-busy="true"] { opacity: 0.8; cursor: progress; }
|
||||||
|
.x-btn > svg { flex-shrink: 0; }
|
||||||
|
|
||||||
|
.x-btn--sm { min-height: var(--x-control-sm); padding: 0 var(--x-space-3); font-size: var(--x-text-label); }
|
||||||
|
.x-btn--lg { min-height: var(--x-control-lg); padding: 0 var(--x-space-6); font-size: var(--x-text-body-lg); }
|
||||||
|
.x-btn--block { display: flex; width: 100%; }
|
||||||
|
|
||||||
|
.x-btn--primary { background: var(--x-accent); color: var(--x-accent-fg); }
|
||||||
|
.x-btn--primary:hover:not(:disabled) { background: var(--x-accent-strong); }
|
||||||
|
.x-btn--secondary { background: var(--x-surface); color: var(--x-ink); border-color: var(--x-line-strong); }
|
||||||
|
.x-btn--secondary:hover:not(:disabled) { background: var(--x-surface-2); }
|
||||||
|
.x-btn--ghost { background: transparent; color: var(--x-ink-2); }
|
||||||
|
.x-btn--ghost:hover:not(:disabled) { background: var(--x-surface-2); color: var(--x-ink); }
|
||||||
|
.x-btn--danger { background: var(--x-danger); color: var(--x-danger-fg); }
|
||||||
|
.x-btn--danger:hover:not(:disabled) { background: rgb(var(--x-danger-rgb) / 0.88); }
|
||||||
|
|
||||||
|
.x-btn--icon { padding: 0; width: var(--x-control-md); }
|
||||||
|
.x-btn--icon.x-btn--sm { width: var(--x-control-sm); }
|
||||||
|
.x-btn--icon.x-btn--lg { width: var(--x-control-lg); }
|
||||||
|
|
||||||
|
/* ── Overlay, Dialog, Sheet ──────────────────────────────────────────────── */
|
||||||
|
.x-overlay {
|
||||||
|
position: fixed; inset: 0; z-index: var(--x-z-overlay);
|
||||||
|
display: flex; align-items: center; justify-content: center;
|
||||||
|
padding: var(--x-space-4);
|
||||||
|
background: rgb(var(--x-scrim-rgb) / 0.5);
|
||||||
|
animation: x-fade-in var(--x-duration-base) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-overlay--bottom { align-items: flex-end; padding: 0; }
|
||||||
|
.x-overlay--right { justify-content: flex-end; align-items: stretch; padding: 0; }
|
||||||
|
|
||||||
|
.x-dialog, .x-sheet {
|
||||||
|
display: flex; flex-direction: column;
|
||||||
|
box-sizing: border-box; max-height: 100%;
|
||||||
|
background: var(--x-surface); color: var(--x-ink);
|
||||||
|
box-shadow: var(--x-shadow-overlay);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.x-dialog {
|
||||||
|
width: 100%; max-height: calc(100vh - 2 * var(--x-space-4));
|
||||||
|
border-radius: var(--x-radius-dialog);
|
||||||
|
animation: x-pop-in var(--x-duration-base) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-dialog--sm { max-width: 400px; }
|
||||||
|
.x-dialog--md { max-width: 520px; }
|
||||||
|
.x-dialog--lg { max-width: 720px; }
|
||||||
|
|
||||||
|
.x-sheet--bottom {
|
||||||
|
width: 100%; max-width: 640px; max-height: 90vh;
|
||||||
|
border-radius: var(--x-radius-dialog) var(--x-radius-dialog) 0 0;
|
||||||
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
|
animation: x-slide-up var(--x-duration-base) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-sheet--right {
|
||||||
|
width: min(480px, 100vw); height: 100%;
|
||||||
|
border-radius: var(--x-radius-dialog) 0 0 var(--x-radius-dialog);
|
||||||
|
animation: x-slide-left var(--x-duration-base) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-sheet__grip {
|
||||||
|
width: 40px; height: 4px; margin: var(--x-space-2) auto 0;
|
||||||
|
border-radius: var(--x-radius-full); background: var(--x-line-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.x-modal__header {
|
||||||
|
display: flex; align-items: flex-start; gap: var(--x-space-3);
|
||||||
|
padding: var(--x-space-5) var(--x-space-5) var(--x-space-2) var(--x-space-6);
|
||||||
|
}
|
||||||
|
.x-modal__titles { flex: 1; min-width: 0; padding-top: var(--x-space-1-5); }
|
||||||
|
.x-modal__title { margin: 0; font-size: var(--x-text-title); line-height: var(--x-leading-title); font-weight: var(--x-weight-semibold); }
|
||||||
|
.x-modal__description { margin: var(--x-space-1) 0 0; font-size: var(--x-text-body); line-height: var(--x-leading-body); color: var(--x-ink-2); }
|
||||||
|
.x-modal__close { margin: calc(-1 * var(--x-space-1)) calc(-1 * var(--x-space-1)) 0 0; }
|
||||||
|
.x-modal__body {
|
||||||
|
flex: 1; min-height: 0; overflow-y: auto;
|
||||||
|
padding: var(--x-space-2) var(--x-space-6) var(--x-space-6);
|
||||||
|
font-size: var(--x-text-body); line-height: var(--x-leading-body); color: var(--x-ink-2);
|
||||||
|
}
|
||||||
|
.x-modal__footer {
|
||||||
|
display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--x-space-2);
|
||||||
|
padding: var(--x-space-4) var(--x-space-6);
|
||||||
|
border-top: 1px solid var(--x-line);
|
||||||
|
}
|
||||||
|
.x-modal__header + .x-modal__footer { border-top: 0; }
|
||||||
|
|
||||||
|
@keyframes x-fade-in { from { opacity: 0; } }
|
||||||
|
@keyframes x-pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
|
||||||
|
@keyframes x-slide-up { from { transform: translateY(100%); } }
|
||||||
|
@keyframes x-slide-left { from { transform: translateX(100%); } }
|
||||||
|
|
||||||
|
/* ── Toast ───────────────────────────────────────────────────────────────── */
|
||||||
|
.x-toasts {
|
||||||
|
position: fixed; z-index: var(--x-z-toast);
|
||||||
|
display: flex; flex-direction: column; gap: var(--x-space-2);
|
||||||
|
width: min(380px, calc(100vw - 2 * var(--x-space-4)));
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.x-toasts--top-right { top: var(--x-space-4); right: var(--x-space-4); }
|
||||||
|
.x-toasts--top-center { top: var(--x-space-4); left: 50%; transform: translateX(-50%); }
|
||||||
|
.x-toasts--bottom-center {
|
||||||
|
bottom: calc(var(--x-space-4) + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
}
|
||||||
|
.x-toast {
|
||||||
|
position: relative; overflow: hidden;
|
||||||
|
display: flex; align-items: flex-start; gap: var(--x-space-3);
|
||||||
|
padding: var(--x-space-3) var(--x-space-2) var(--x-space-3) var(--x-space-4);
|
||||||
|
background: var(--x-surface); color: var(--x-ink);
|
||||||
|
border: 1px solid var(--x-line); border-radius: var(--x-radius-card);
|
||||||
|
box-shadow: var(--x-shadow-popover);
|
||||||
|
pointer-events: auto;
|
||||||
|
animation: x-pop-in var(--x-duration-base) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-toast__bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--x-ink-3); }
|
||||||
|
.x-toast--success .x-toast__bar { background: var(--x-success); }
|
||||||
|
.x-toast--warning .x-toast__bar { background: var(--x-warning); }
|
||||||
|
.x-toast--danger .x-toast__bar { background: var(--x-danger); }
|
||||||
|
.x-toast--info .x-toast__bar { background: var(--x-info); }
|
||||||
|
.x-toast__text { flex: 1; min-width: 0; padding: var(--x-space-0-5) 0; }
|
||||||
|
.x-toast__title { font-size: var(--x-text-body); line-height: var(--x-leading-body); font-weight: var(--x-weight-semibold); }
|
||||||
|
.x-toast__description { margin-top: var(--x-space-0-5); font-size: var(--x-text-label); line-height: var(--x-leading-label); color: var(--x-ink-2); }
|
||||||
|
.x-toast__action, .x-toast__close {
|
||||||
|
flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
|
||||||
|
min-height: 32px; border: 0; border-radius: var(--x-radius-sm); background: transparent;
|
||||||
|
font: inherit; cursor: pointer;
|
||||||
|
}
|
||||||
|
.x-toast__action { padding: 0 var(--x-space-2); font-size: var(--x-text-label); font-weight: var(--x-weight-semibold); color: var(--x-accent-ink); }
|
||||||
|
.x-toast__action:hover { background: var(--x-accent-soft); }
|
||||||
|
.x-toast__close { width: 32px; color: var(--x-ink-3); }
|
||||||
|
.x-toast__close:hover { background: var(--x-surface-2); color: var(--x-ink); }
|
||||||
|
.x-toast__action:focus-visible, .x-toast__close:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||||
|
|
||||||
|
/* ── PinPad ──────────────────────────────────────────────────────────────── */
|
||||||
|
.x-pinpad { display: flex; flex-direction: column; align-items: center; gap: var(--x-space-4); color: var(--x-ink); }
|
||||||
|
.x-pinpad__title { font-size: var(--x-text-body-lg); line-height: var(--x-leading-body-lg); font-weight: var(--x-weight-semibold); }
|
||||||
|
.x-pinpad__dots { display: flex; gap: var(--x-space-3); }
|
||||||
|
.x-pinpad__dots--shake { animation: x-shake 0.36s var(--x-ease); }
|
||||||
|
.x-pinpad__dot {
|
||||||
|
width: 14px; height: 14px; border-radius: var(--x-radius-full);
|
||||||
|
border: 2px solid var(--x-line-strong);
|
||||||
|
transition: background-color var(--x-duration-fast) var(--x-ease), border-color var(--x-duration-fast) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-pinpad__dot--filled { background: var(--x-accent); border-color: var(--x-accent); }
|
||||||
|
.x-pinpad__dot--error { border-color: var(--x-danger); }
|
||||||
|
.x-pinpad__status { min-height: 20px; display: flex; align-items: center; color: var(--x-ink-3); }
|
||||||
|
.x-pinpad__error { font-size: var(--x-text-label); line-height: var(--x-leading-label); color: var(--x-danger-ink); }
|
||||||
|
.x-pinpad__keys { display: grid; grid-template-columns: repeat(3, 72px); gap: var(--x-space-3); }
|
||||||
|
.x-pinpad__key {
|
||||||
|
height: 60px; border: 0; border-radius: var(--x-radius-card);
|
||||||
|
background: var(--x-surface-2); color: var(--x-ink);
|
||||||
|
font: inherit; font-size: var(--x-text-heading); font-weight: var(--x-weight-medium);
|
||||||
|
display: flex; align-items: center; justify-content: center;
|
||||||
|
cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
|
||||||
|
transition: background-color var(--x-duration-fast) var(--x-ease), transform var(--x-duration-fast) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-pinpad__key:hover:not(:disabled) { background: var(--x-surface-3); }
|
||||||
|
.x-pinpad__key:active:not(:disabled) { transform: scale(0.95); }
|
||||||
|
.x-pinpad__key:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||||
|
.x-pinpad__key:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||||
|
.x-pinpad__key--backspace { background: transparent; color: var(--x-ink-2); }
|
||||||
|
@keyframes x-shake {
|
||||||
|
20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
|
||||||
|
60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── InfoTip ─────────────────────────────────────────────────────────────── */
|
||||||
|
.x-infotip {
|
||||||
|
display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
|
||||||
|
width: 24px; height: 24px; margin: -4px 0; padding: 0;
|
||||||
|
border: 0; border-radius: var(--x-radius-full); background: transparent;
|
||||||
|
color: var(--x-ink-3); cursor: pointer; -webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
.x-infotip:hover, .x-infotip--open { color: var(--x-accent); background: var(--x-accent-soft); }
|
||||||
|
.x-infotip:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||||
|
.x-infotip__popover {
|
||||||
|
position: fixed; z-index: var(--x-z-popover);
|
||||||
|
box-sizing: border-box; max-width: min(320px, calc(100vw - 16px));
|
||||||
|
padding: var(--x-space-2-5) var(--x-space-3);
|
||||||
|
background: var(--x-ink); color: var(--x-canvas);
|
||||||
|
border-radius: var(--x-radius-sm); box-shadow: var(--x-shadow-popover);
|
||||||
|
font-size: var(--x-text-label); line-height: var(--x-leading-label); font-weight: var(--x-weight-regular);
|
||||||
|
animation: x-fade-in var(--x-duration-fast) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-infotip__popover::after {
|
||||||
|
content: ""; position: absolute; left: var(--x-arrow-x, 50%);
|
||||||
|
width: 10px; height: 10px; background: inherit; transform: translateX(-50%) rotate(45deg);
|
||||||
|
}
|
||||||
|
.x-infotip__popover--above::after { bottom: -4px; }
|
||||||
|
.x-infotip__popover--below::after { top: -4px; }
|
||||||
|
|
||||||
|
/* ── EmptyState ──────────────────────────────────────────────────────────── */
|
||||||
|
.x-empty {
|
||||||
|
display: flex; flex-direction: column; align-items: center; text-align: center;
|
||||||
|
padding: var(--x-space-12) var(--x-space-6); color: var(--x-ink-2);
|
||||||
|
}
|
||||||
|
.x-empty--compact { padding: var(--x-space-6) var(--x-space-4); }
|
||||||
|
.x-empty__icon {
|
||||||
|
display: flex; align-items: center; justify-content: center;
|
||||||
|
width: 48px; height: 48px; margin-bottom: var(--x-space-3);
|
||||||
|
border-radius: var(--x-radius-card); background: var(--x-surface-2); color: var(--x-ink-3);
|
||||||
|
}
|
||||||
|
.x-empty__icon svg { width: 24px; height: 24px; }
|
||||||
|
.x-empty__title { font-size: var(--x-text-body-lg); line-height: var(--x-leading-body-lg); font-weight: var(--x-weight-semibold); color: var(--x-ink); }
|
||||||
|
.x-empty__description { max-width: 360px; margin-top: var(--x-space-1); font-size: var(--x-text-body); line-height: var(--x-leading-body); }
|
||||||
|
.x-empty__action { margin-top: var(--x-space-4); }
|
||||||
|
|
||||||
|
/* ── Field, Input, Select ────────────────────────────────────────────────── */
|
||||||
|
.x-field { display: flex; flex-direction: column; gap: var(--x-space-1-5); }
|
||||||
|
.x-field__label-row { display: flex; align-items: center; gap: var(--x-space-1); }
|
||||||
|
.x-field__label { font-size: var(--x-text-label); line-height: var(--x-leading-label); font-weight: var(--x-weight-medium); color: var(--x-ink); }
|
||||||
|
.x-field__required { color: var(--x-danger-ink); }
|
||||||
|
.x-field__hint { font-size: var(--x-text-caption); line-height: var(--x-leading-caption); color: var(--x-ink-3); }
|
||||||
|
.x-field__error { font-size: var(--x-text-caption); line-height: var(--x-leading-caption); color: var(--x-danger-ink); }
|
||||||
|
|
||||||
|
.x-input, .x-select__control {
|
||||||
|
box-sizing: border-box; width: 100%;
|
||||||
|
min-height: var(--x-control-md); padding: 0 var(--x-space-3);
|
||||||
|
background: var(--x-surface); color: var(--x-ink);
|
||||||
|
border: 1px solid var(--x-line-strong); border-radius: var(--x-radius-control);
|
||||||
|
font: inherit; font-size: var(--x-text-body-lg); /* 16px: phones don't zoom in on focus */
|
||||||
|
transition: border-color var(--x-duration-fast) var(--x-ease), box-shadow var(--x-duration-fast) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-input::placeholder { color: var(--x-ink-3); }
|
||||||
|
.x-input:hover:not(:disabled), .x-select__control:hover:not(:disabled) { border-color: var(--x-ink-3); }
|
||||||
|
.x-input:focus, .x-select__control:focus { outline: none; border-color: var(--x-accent); box-shadow: var(--x-focus-ring); }
|
||||||
|
.x-input:disabled, .x-select__control:disabled { background: var(--x-surface-2); color: var(--x-ink-3); cursor: not-allowed; }
|
||||||
|
.x-input[aria-invalid="true"], .x-select__control[aria-invalid="true"] { border-color: var(--x-danger); }
|
||||||
|
.x-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgb(var(--x-danger-rgb) / 0.3); }
|
||||||
|
.x-input--sm, .x-select--sm .x-select__control { min-height: var(--x-control-sm); font-size: var(--x-text-body); }
|
||||||
|
.x-input--lg, .x-select--lg .x-select__control { min-height: var(--x-control-lg); }
|
||||||
|
.x-textarea { padding: var(--x-space-2-5) var(--x-space-3); resize: vertical; min-height: 88px; }
|
||||||
|
|
||||||
|
.x-select { position: relative; display: block; }
|
||||||
|
.x-select__control { appearance: none; -webkit-appearance: none; padding-right: var(--x-space-10); cursor: pointer; }
|
||||||
|
.x-select__chevron { position: absolute; right: var(--x-space-3); top: 50%; transform: translateY(-50%); color: var(--x-ink-3); pointer-events: none; }
|
||||||
|
|
||||||
|
/* ── Switch ──────────────────────────────────────────────────────────────── */
|
||||||
|
.x-switch {
|
||||||
|
position: relative; flex-shrink: 0;
|
||||||
|
width: 44px; height: 26px; padding: 0;
|
||||||
|
border: 0; border-radius: var(--x-radius-full);
|
||||||
|
background: var(--x-ink-3); cursor: pointer; /* off track: 3:1 against the surface (contrast test) */
|
||||||
|
transition: background-color var(--x-duration-base) var(--x-ease);
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
.x-switch::before { content: ""; position: absolute; inset: -9px 0; } /* 44px touch target */
|
||||||
|
.x-switch__thumb {
|
||||||
|
position: absolute; top: 3px; left: 3px;
|
||||||
|
width: 20px; height: 20px; border-radius: var(--x-radius-full);
|
||||||
|
background: #fff; box-shadow: var(--x-shadow-raised);
|
||||||
|
transition: transform var(--x-duration-base) var(--x-ease);
|
||||||
|
}
|
||||||
|
.x-switch--on { background: var(--x-accent); }
|
||||||
|
.x-switch--on .x-switch__thumb { transform: translateX(18px); }
|
||||||
|
.x-switch:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||||
|
.x-switch:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||||
|
|
||||||
|
.x-switch-row { display: flex; align-items: center; gap: var(--x-space-4); }
|
||||||
|
.x-switch-row__text { flex: 1; min-width: 0; }
|
||||||
|
.x-switch-row__label { display: block; font-size: var(--x-text-body); line-height: var(--x-leading-body); font-weight: var(--x-weight-medium); color: var(--x-ink); cursor: pointer; }
|
||||||
|
.x-switch-row__description { margin-top: var(--x-space-0-5); font-size: var(--x-text-label); line-height: var(--x-leading-label); color: var(--x-ink-2); }
|
||||||
|
.x-switch-row--disabled .x-switch-row__label { cursor: not-allowed; opacity: 0.6; }
|
||||||
@@ -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>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
import { ModalFrame } from '../internal/ModalFrame.jsx'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Centered modal dialog.
|
||||||
|
*
|
||||||
|
* <Dialog open={open} onClose={() => setOpen(false)} title="Delete product?"
|
||||||
|
* footer={<><Button variant="secondary" onClick={close}>Cancel</Button>
|
||||||
|
* <Button variant="danger" onClick={remove}>Delete</Button></>}>
|
||||||
|
* This can't be undone.
|
||||||
|
* </Dialog>
|
||||||
|
*
|
||||||
|
* Escape, the backdrop and the × close it; focus moves in, is trapped, and returns
|
||||||
|
* to where it was. dismissible={false} for steps that must be finished (no ×, no Escape).
|
||||||
|
* size: 'sm' (400px) | 'md' (520px) | 'lg' (720px). closeLabel: the × text (translate it).
|
||||||
|
* initialFocus: a ref to focus first (default: the first field or button in the body).
|
||||||
|
*/
|
||||||
|
export function Dialog({ size = 'md', className, ...props }) {
|
||||||
|
return <ModalFrame {...props} panelClass={cx('x-dialog', `x-dialog--${size}`, className)} />
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What a list or page shows when there's nothing in it yet.
|
||||||
|
* <EmptyState icon={<Inbox />} title="No online orders yet"
|
||||||
|
* description="New orders from the QR menu appear here." action={<Button>Open menu settings</Button>} />
|
||||||
|
* compact: less padding, for use inside cards.
|
||||||
|
*/
|
||||||
|
export function EmptyState({ icon, title, description, action, compact = false, className }) {
|
||||||
|
return (
|
||||||
|
<div className={cx('x-empty', compact && 'x-empty--compact', className)}>
|
||||||
|
{icon && <div className="x-empty__icon" aria-hidden="true">{icon}</div>}
|
||||||
|
{title && <div className="x-empty__title">{title}</div>}
|
||||||
|
{description && <div className="x-empty__description">{description}</div>}
|
||||||
|
{action && <div className="x-empty__action">{action}</div>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { Children, cloneElement, isValidElement, useId } from 'react'
|
||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label + control + hint/error, wired for screen readers (id, aria-describedby,
|
||||||
|
* aria-invalid, required). Wrap exactly one control:
|
||||||
|
*
|
||||||
|
* <Field label="Name" hint="Shown on tickets" error={errors.name} required>
|
||||||
|
* <Input value={name} onChange={e => setName(e.target.value)} />
|
||||||
|
* </Field>
|
||||||
|
*
|
||||||
|
* info: optional element placed after the label, usually an <InfoTip>.
|
||||||
|
*/
|
||||||
|
export function Field({ label, hint, error, required = false, info, id, className, children }) {
|
||||||
|
const auto = useId()
|
||||||
|
const controlId = id || auto
|
||||||
|
const hintId = `${controlId}-hint`
|
||||||
|
const errorId = `${controlId}-error`
|
||||||
|
// The error replaces the hint while there is one
|
||||||
|
const describedBy = error ? errorId : hint ? hintId : undefined
|
||||||
|
|
||||||
|
const only = Children.only(children)
|
||||||
|
const control = isValidElement(only)
|
||||||
|
? cloneElement(only, {
|
||||||
|
id: only.props.id || controlId,
|
||||||
|
'aria-describedby': cx(only.props['aria-describedby'], describedBy) || undefined,
|
||||||
|
'aria-invalid': error ? true : only.props['aria-invalid'],
|
||||||
|
required: required || only.props.required,
|
||||||
|
})
|
||||||
|
: only
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cx('x-field', error && 'x-field--error', className)}>
|
||||||
|
{label && (
|
||||||
|
<div className="x-field__label-row">
|
||||||
|
<label className="x-field__label" htmlFor={controlId}>
|
||||||
|
{label}{required && <span className="x-field__required" aria-hidden="true"> *</span>}
|
||||||
|
</label>
|
||||||
|
{info}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{control}
|
||||||
|
{error
|
||||||
|
? <div id={errorId} className="x-field__error">{error}</div>
|
||||||
|
: hint && <div id={hintId} className="x-field__hint">{hint}</div>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Text input styled with the tokens. All <input> props pass through; size: 'sm' | 'md' | 'lg'. */
|
||||||
|
export function Input({ size = 'md', className, ref, ...rest }) {
|
||||||
|
return <input ref={ref} className={cx('x-input', `x-input--${size}`, className)} {...rest} />
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Multi-line text input. */
|
||||||
|
export function Textarea({ className, rows = 3, ref, ...rest }) {
|
||||||
|
return <textarea ref={ref} rows={rows} className={cx('x-input', 'x-textarea', className)} {...rest} />
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Native <select> (best on phones and with screen readers), styled.
|
||||||
|
* <Select value={v} onChange={e => setV(e.target.value)} options={[{ value: 'el', label: 'Ελληνικά' }]} />
|
||||||
|
* or pass <option> children. placeholder adds a first, disabled, empty option.
|
||||||
|
*/
|
||||||
|
export function Select({ options, placeholder, size = 'md', className, children, ref, ...rest }) {
|
||||||
|
return (
|
||||||
|
<span className={cx('x-select', `x-select--${size}`, className)}>
|
||||||
|
<select ref={ref} className="x-select__control" {...rest}>
|
||||||
|
{placeholder != null && <option value="" disabled>{placeholder}</option>}
|
||||||
|
{options
|
||||||
|
? options.map(o => <option key={o.value} value={o.value} disabled={o.disabled}>{o.label}</option>)
|
||||||
|
: children}
|
||||||
|
</select>
|
||||||
|
<svg className="x-select__chevron" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||||
|
<path d="M6 9l6 6 6-6" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react'
|
||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
import { Portal } from '../internal/Portal.jsx'
|
||||||
|
|
||||||
|
const GAP = 8
|
||||||
|
const MARGIN = 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "(i)" help tip next to a setting or label (D-12: every manager page gets them).
|
||||||
|
* Opens on click/tap (works on touch screens), closes on Escape, a click outside, or
|
||||||
|
* a second click. Placed above the button, or below when there's no room.
|
||||||
|
*
|
||||||
|
* <label>Alert after failures <InfoTip>How many failed print attempts before managers are notified. 0 turns it off.</InfoTip></label>
|
||||||
|
*
|
||||||
|
* label: the button's accessible name (translate it). side: 'top' | 'bottom' (preferred side).
|
||||||
|
*/
|
||||||
|
export function InfoTip({ children, label = 'More info', side = 'top', className }) {
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
const [pos, setPos] = useState(null)
|
||||||
|
const button = useRef(null)
|
||||||
|
const tip = useRef(null)
|
||||||
|
const id = useId()
|
||||||
|
|
||||||
|
const place = useCallback(() => {
|
||||||
|
const b = button.current?.getBoundingClientRect()
|
||||||
|
const t = tip.current?.getBoundingClientRect()
|
||||||
|
if (!b || !t) return
|
||||||
|
const roomAbove = b.top - GAP - MARGIN >= t.height
|
||||||
|
const roomBelow = window.innerHeight - b.bottom - GAP - MARGIN >= t.height
|
||||||
|
const above = side === 'top' ? (roomAbove || !roomBelow) : !(roomBelow || !roomAbove)
|
||||||
|
const top = above ? b.top - GAP - t.height : b.bottom + GAP
|
||||||
|
const left = Math.min(Math.max(MARGIN, b.left + b.width / 2 - t.width / 2), window.innerWidth - MARGIN - t.width)
|
||||||
|
setPos({ top, left, above, arrow: b.left + b.width / 2 - left })
|
||||||
|
}, [side])
|
||||||
|
|
||||||
|
useLayoutEffect(() => { if (open) place() }, [open, place])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return
|
||||||
|
const close = () => setOpen(false)
|
||||||
|
const onKey = e => { if (e.key === 'Escape') { e.stopPropagation(); close(); button.current?.focus() } }
|
||||||
|
const onDown = e => {
|
||||||
|
if (button.current?.contains(e.target) || tip.current?.contains(e.target)) return
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
document.addEventListener('keydown', onKey, true)
|
||||||
|
document.addEventListener('pointerdown', onDown)
|
||||||
|
window.addEventListener('resize', place)
|
||||||
|
window.addEventListener('scroll', place, true)
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('keydown', onKey, true)
|
||||||
|
document.removeEventListener('pointerdown', onDown)
|
||||||
|
window.removeEventListener('resize', place)
|
||||||
|
window.removeEventListener('scroll', place, true)
|
||||||
|
}
|
||||||
|
}, [open, place])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
ref={button}
|
||||||
|
type="button"
|
||||||
|
className={cx('x-infotip', open && 'x-infotip--open', className)}
|
||||||
|
aria-label={label}
|
||||||
|
aria-expanded={open}
|
||||||
|
aria-describedby={open ? id : undefined}
|
||||||
|
onClick={() => setOpen(o => !o)}
|
||||||
|
>
|
||||||
|
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">
|
||||||
|
<circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" strokeWidth="1.5" />
|
||||||
|
<circle cx="8" cy="4.75" r="1" fill="currentColor" />
|
||||||
|
<path d="M8 7.25v4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
{open && (
|
||||||
|
<Portal>
|
||||||
|
<div
|
||||||
|
ref={tip}
|
||||||
|
id={id}
|
||||||
|
role="tooltip"
|
||||||
|
className={cx('x-infotip__popover', pos && (pos.above ? 'x-infotip__popover--above' : 'x-infotip__popover--below'))}
|
||||||
|
style={pos ? { top: pos.top, left: pos.left, '--x-arrow-x': `${pos.arrow}px` } : { top: 0, left: 0, visibility: 'hidden' }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</Portal>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
import { Spinner } from './Spinner.jsx'
|
||||||
|
import { nextPin, pinAction } from './pin.js'
|
||||||
|
|
||||||
|
const KEYS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', null, '0', 'Backspace']
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Numeric PIN entry: dots + a 3×4 keypad, also driven by the physical keyboard.
|
||||||
|
*
|
||||||
|
* <PinPad length={4} onComplete={async pin => { await unlock(pin) }} />
|
||||||
|
*
|
||||||
|
* onComplete(pin) runs when `length` digits are in. If it returns a promise the pad
|
||||||
|
* shows a spinner until it settles. If it throws / rejects (or returns false), the pad
|
||||||
|
* shakes, shows `error` text if given, and clears for another try. On success it clears too.
|
||||||
|
*
|
||||||
|
* error: text under the dots (e.g. "Wrong PIN"); a change of it also shakes the pad.
|
||||||
|
* captureKeyboard (default true): digits/Backspace typed anywhere go to the pad,
|
||||||
|
* except while the user is typing in a field.
|
||||||
|
* Labels for translation: backspaceLabel, progressLabel(n, length).
|
||||||
|
*/
|
||||||
|
export function PinPad({
|
||||||
|
length = 4, onComplete, onChange, disabled = false, error, title,
|
||||||
|
captureKeyboard = true, backspaceLabel = 'Delete',
|
||||||
|
progressLabel = (n, total) => `${n} of ${total} digits entered`,
|
||||||
|
className,
|
||||||
|
}) {
|
||||||
|
const [value, setValue] = useState('')
|
||||||
|
const [busy, setBusy] = useState(false)
|
||||||
|
const [shake, setShake] = useState(0)
|
||||||
|
const latest = useRef({ value, busy, disabled })
|
||||||
|
useLayoutEffect(() => { latest.current = { value, busy, disabled } })
|
||||||
|
|
||||||
|
const fail = useCallback(() => {
|
||||||
|
setShake(n => n + 1)
|
||||||
|
setValue('')
|
||||||
|
onChange?.('')
|
||||||
|
}, [onChange])
|
||||||
|
|
||||||
|
const submit = useCallback(async pin => {
|
||||||
|
let ok = true
|
||||||
|
try {
|
||||||
|
const result = onComplete?.(pin)
|
||||||
|
if (result && typeof result.then === 'function') {
|
||||||
|
setBusy(true)
|
||||||
|
ok = (await result) !== false
|
||||||
|
} else {
|
||||||
|
ok = result !== false
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
ok = false
|
||||||
|
} finally {
|
||||||
|
setBusy(false)
|
||||||
|
}
|
||||||
|
if (ok) { setValue(''); onChange?.('') } else fail()
|
||||||
|
}, [onComplete, onChange, fail])
|
||||||
|
|
||||||
|
const press = useCallback(key => {
|
||||||
|
const { value: current, busy: isBusy, disabled: isDisabled } = latest.current
|
||||||
|
const action = pinAction(key)
|
||||||
|
if (!action || isBusy || isDisabled) return
|
||||||
|
const next = nextPin(current, action, length)
|
||||||
|
if (next === current) return
|
||||||
|
setValue(next)
|
||||||
|
onChange?.(next)
|
||||||
|
if (next.length === length) submit(next)
|
||||||
|
}, [length, onChange, submit])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!captureKeyboard) return
|
||||||
|
const onKey = e => {
|
||||||
|
if (e.ctrlKey || e.metaKey || e.altKey) return
|
||||||
|
const t = e.target
|
||||||
|
if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return
|
||||||
|
if (pinAction(e.key)) { e.preventDefault(); press(e.key) }
|
||||||
|
}
|
||||||
|
document.addEventListener('keydown', onKey)
|
||||||
|
return () => document.removeEventListener('keydown', onKey)
|
||||||
|
}, [captureKeyboard, press])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cx('x-pinpad', disabled && 'x-pinpad--disabled', className)}>
|
||||||
|
{title && <div className="x-pinpad__title">{title}</div>}
|
||||||
|
{/* Re-keyed on every failed attempt and on every new error text, which replays the shake */}
|
||||||
|
<div key={`${shake}:${error || ''}`} className={cx('x-pinpad__dots', (shake > 0 || error) && 'x-pinpad__dots--shake')} aria-hidden="true">
|
||||||
|
{Array.from({ length }, (_, i) => (
|
||||||
|
<span key={i} className={cx('x-pinpad__dot', i < value.length && 'x-pinpad__dot--filled', error && 'x-pinpad__dot--error')} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="x-visually-hidden" aria-live="polite">{progressLabel(value.length, length)}</div>
|
||||||
|
<div className="x-pinpad__status">
|
||||||
|
{busy ? <Spinner size="sm" /> : error ? <span className="x-pinpad__error" role="alert">{error}</span> : null}
|
||||||
|
</div>
|
||||||
|
<div className="x-pinpad__keys">
|
||||||
|
{KEYS.map(k => k === null
|
||||||
|
? <span key="blank" aria-hidden="true" />
|
||||||
|
: (
|
||||||
|
<button
|
||||||
|
key={k}
|
||||||
|
type="button"
|
||||||
|
className={cx('x-pinpad__key', k === 'Backspace' && 'x-pinpad__key--backspace')}
|
||||||
|
onClick={() => press(k)}
|
||||||
|
disabled={disabled || busy}
|
||||||
|
aria-label={k === 'Backspace' ? backspaceLabel : undefined}
|
||||||
|
>
|
||||||
|
{k === 'Backspace'
|
||||||
|
? (
|
||||||
|
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||||
|
<path d="M21 5H9l-6 7 6 7h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1z" /><path d="M17 9l-6 6M11 9l6 6" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
: k}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
import { ModalFrame } from '../internal/ModalFrame.jsx'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A panel that slides in from the bottom (phones: action sheets, pickers) or the
|
||||||
|
* right (desktop: detail and edit panels). Same props and behaviour as Dialog.
|
||||||
|
* side: 'bottom' | 'right'
|
||||||
|
*/
|
||||||
|
export function Sheet({ side = 'bottom', className, ...props }) {
|
||||||
|
return (
|
||||||
|
<ModalFrame
|
||||||
|
{...props}
|
||||||
|
overlayClass={`x-overlay--${side}`}
|
||||||
|
panelClass={cx('x-sheet', `x-sheet--${side}`, className)}
|
||||||
|
bodyClass="x-sheet__body"
|
||||||
|
grip={side === 'bottom'}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loading indicator. With a `label` (default "Loading") it is announced to screen
|
||||||
|
* readers; pass label={null} when the surrounding element already says it (a busy button).
|
||||||
|
* size: 'sm' (16px) | 'md' (24px) | 'lg' (40px)
|
||||||
|
*/
|
||||||
|
export function Spinner({ size = 'md', label = 'Loading', className, ...rest }) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={cx('x-spinner', `x-spinner--${size}`, className)}
|
||||||
|
role={label ? 'status' : undefined}
|
||||||
|
aria-hidden={label ? undefined : true}
|
||||||
|
{...rest}
|
||||||
|
>
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<circle cx="12" cy="12" r="9" stroke="currentColor" strokeOpacity="0.25" strokeWidth="3" />
|
||||||
|
<path d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" strokeWidth="3" strokeLinecap="round" />
|
||||||
|
</svg>
|
||||||
|
{label && <span className="x-visually-hidden">{label}</span>}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { useId } from 'react'
|
||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On/off toggle for settings that take effect immediately.
|
||||||
|
* <Switch checked={on} onChange={setOn} label="Print kitchen tickets" description="..." />
|
||||||
|
* onChange receives the new boolean. Without `label`, pass aria-label.
|
||||||
|
* The whole row (label + description) is clickable.
|
||||||
|
*/
|
||||||
|
export function Switch({ checked, onChange, label, description, disabled = false, id, className, ...rest }) {
|
||||||
|
const auto = useId()
|
||||||
|
const switchId = id || auto
|
||||||
|
const descId = `${switchId}-desc`
|
||||||
|
|
||||||
|
const control = (
|
||||||
|
<button
|
||||||
|
id={switchId}
|
||||||
|
type="button"
|
||||||
|
role="switch"
|
||||||
|
aria-checked={!!checked}
|
||||||
|
aria-describedby={description ? descId : undefined}
|
||||||
|
disabled={disabled}
|
||||||
|
className={cx('x-switch', checked && 'x-switch--on')}
|
||||||
|
onClick={() => onChange?.(!checked)}
|
||||||
|
{...rest}
|
||||||
|
>
|
||||||
|
<span className="x-switch__thumb" />
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!label && !description) return <span className={className}>{control}</span>
|
||||||
|
return (
|
||||||
|
<div className={cx('x-switch-row', disabled && 'x-switch-row--disabled', className)}>
|
||||||
|
<div className="x-switch-row__text">
|
||||||
|
{label && <label className="x-switch-row__label" htmlFor={switchId}>{label}</label>}
|
||||||
|
{description && <div id={descId} className="x-switch-row__description">{description}</div>}
|
||||||
|
</div>
|
||||||
|
{control}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
import { Portal } from '../internal/Portal.jsx'
|
||||||
|
import { ToastContext } from './toastContext.js'
|
||||||
|
|
||||||
|
let nextId = 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap the app once: <ToastProvider><App /></ToastProvider>
|
||||||
|
* Then anywhere: const toast = useToast()
|
||||||
|
* toast.success('Saved')
|
||||||
|
* toast.show({ tone: 'danger', title: 'Printer offline', description: 'Bar printer', duration: 0 })
|
||||||
|
*
|
||||||
|
* tone: 'neutral' | 'success' | 'warning' | 'danger' | 'info'. duration in ms (0 = stays until closed).
|
||||||
|
* Danger toasts are announced assertively (role="alert"), the rest politely.
|
||||||
|
* The timer pauses while the pointer is over a toast.
|
||||||
|
* placement: 'top-right' | 'top-center' | 'bottom-center'. closeLabel: the × text (translate it).
|
||||||
|
*/
|
||||||
|
export function ToastProvider({ children, placement = 'top-right', max = 4, closeLabel = 'Dismiss' }) {
|
||||||
|
const [toasts, setToasts] = useState([])
|
||||||
|
|
||||||
|
const dismiss = useCallback(id => setToasts(list => list.filter(t => t.id !== id)), [])
|
||||||
|
const show = useCallback(opts => {
|
||||||
|
const t = typeof opts === 'string' ? { title: opts } : opts
|
||||||
|
const id = t.id ?? nextId++
|
||||||
|
const toast = { tone: 'neutral', duration: t.tone === 'danger' ? 8000 : 4000, ...t, id }
|
||||||
|
setToasts(list => [...list.filter(x => x.id !== id), toast].slice(-max))
|
||||||
|
return id
|
||||||
|
}, [max])
|
||||||
|
|
||||||
|
const api = useMemo(() => {
|
||||||
|
const tone = name => (title, opts = {}) => show({ ...opts, title, tone: name })
|
||||||
|
return { show, dismiss, success: tone('success'), error: tone('danger'), warning: tone('warning'), info: tone('info') }
|
||||||
|
}, [show, dismiss])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ToastContext.Provider value={api}>
|
||||||
|
{children}
|
||||||
|
<Portal>
|
||||||
|
<div className={cx('x-toasts', `x-toasts--${placement}`)} role="region" aria-label="Notifications">
|
||||||
|
{toasts.map(t => <ToastItem key={t.id} toast={t} onDismiss={dismiss} closeLabel={closeLabel} />)}
|
||||||
|
</div>
|
||||||
|
</Portal>
|
||||||
|
</ToastContext.Provider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ToastItem({ toast, onDismiss, closeLabel }) {
|
||||||
|
const { id, tone, title, description, duration, action } = toast
|
||||||
|
const [paused, setPaused] = useState(false)
|
||||||
|
const remaining = useRef(duration)
|
||||||
|
const started = useRef(0)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!duration || paused) return
|
||||||
|
started.current = Date.now()
|
||||||
|
const timer = setTimeout(() => onDismiss(id), remaining.current)
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timer)
|
||||||
|
remaining.current -= Date.now() - started.current
|
||||||
|
}
|
||||||
|
}, [paused, duration, id, onDismiss])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cx('x-toast', `x-toast--${tone}`)}
|
||||||
|
role={tone === 'danger' ? 'alert' : 'status'}
|
||||||
|
onMouseEnter={() => setPaused(true)}
|
||||||
|
onMouseLeave={() => setPaused(false)}
|
||||||
|
>
|
||||||
|
<span className="x-toast__bar" aria-hidden="true" />
|
||||||
|
<div className="x-toast__text">
|
||||||
|
{title && <div className="x-toast__title">{title}</div>}
|
||||||
|
{description && <div className="x-toast__description">{description}</div>}
|
||||||
|
</div>
|
||||||
|
{action && (
|
||||||
|
<button type="button" className="x-toast__action" onClick={() => { action.onClick?.(); onDismiss(id) }}>
|
||||||
|
{action.label}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<button type="button" className="x-toast__close" aria-label={closeLabel} title={closeLabel} onClick={() => onDismiss(id)}>
|
||||||
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true">
|
||||||
|
<path d="M6 6l12 12M18 6L6 18" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// PIN entry rules, kept free of React so they can be unit-tested (tests/pin.test.mjs).
|
||||||
|
|
||||||
|
/** Normalise a key or keypad press into an action, or null if it isn't one. */
|
||||||
|
export function pinAction(key) {
|
||||||
|
if (/^[0-9]$/.test(key)) return { type: 'digit', digit: key }
|
||||||
|
if (key === 'Backspace' || key === 'Delete') return { type: 'backspace' }
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Next PIN value. Digits are ignored once `length` is reached; backspace on an
|
||||||
|
* empty PIN is a no-op; 'clear' empties it.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
export function nextPin(value, action, length) {
|
||||||
|
switch (action?.type) {
|
||||||
|
case 'digit': return value.length >= length ? value : value + action.digit
|
||||||
|
case 'backspace': return value.slice(0, -1)
|
||||||
|
case 'clear': return ''
|
||||||
|
default: return value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { createContext, useContext } from 'react'
|
||||||
|
|
||||||
|
export const ToastContext = createContext(null)
|
||||||
|
|
||||||
|
/** toast.success('Saved'), toast.error(title, { description }), toast.show({...}), toast.dismiss(id). See ToastProvider. */
|
||||||
|
export function useToast() {
|
||||||
|
const ctx = useContext(ToastContext)
|
||||||
|
if (!ctx) throw new Error('useToast() needs a <ToastProvider> above it')
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
@@ -1,3 +1,23 @@
|
|||||||
// @xenia/ui — Design tokens (CSS variables), the Tailwind preset and base components (plan step 2.3).
|
// @xenia/ui — design tokens and base components shared by the manager, the terminal
|
||||||
// Imported from source by Vite (no build step). Filled in by its plan step.
|
// and the waiter app (APPS_PLATFORM §9, plan step 2.3). Imported from source by Vite.
|
||||||
export {}
|
//
|
||||||
|
// Styles are separate so an app chooses what to load:
|
||||||
|
// import '@xenia/ui/tokens.css' CSS variables only (the waiter today)
|
||||||
|
// import '@xenia/ui/styles.css' tokens + the components' styles (.x-* classes)
|
||||||
|
// Tailwind apps also add the preset: import xenia from '@xenia/ui/tailwind-preset'.
|
||||||
|
//
|
||||||
|
// Components ship English default labels (Close, Loading, Delete…); pass translated
|
||||||
|
// ones as props until @xenia/i18n exists (2.4).
|
||||||
|
|
||||||
|
export { Button, IconButton } from './components/Button.jsx'
|
||||||
|
export { Dialog } from './components/Dialog.jsx'
|
||||||
|
export { Sheet } from './components/Sheet.jsx'
|
||||||
|
export { ToastProvider } from './components/Toast.jsx'
|
||||||
|
export { useToast } from './components/toastContext.js'
|
||||||
|
export { PinPad } from './components/PinPad.jsx'
|
||||||
|
export { InfoTip } from './components/InfoTip.jsx'
|
||||||
|
export { EmptyState } from './components/EmptyState.jsx'
|
||||||
|
export { Spinner } from './components/Spinner.jsx'
|
||||||
|
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
||||||
|
export { Switch } from './components/Switch.jsx'
|
||||||
|
export { cx } from './internal/cx.js'
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { useId, useRef } from 'react'
|
||||||
|
import { cx } from './cx.js'
|
||||||
|
import { Portal } from './Portal.jsx'
|
||||||
|
import { useModal } from './useModal.js'
|
||||||
|
import { IconButton } from '../components/Button.jsx'
|
||||||
|
|
||||||
|
const CloseIcon = () => (
|
||||||
|
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true">
|
||||||
|
<path d="M6 6l12 12M18 6L6 18" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
|
||||||
|
/** The shared body of Dialog and Sheet: backdrop, panel, header with ×, body, footer. */
|
||||||
|
export function ModalFrame({
|
||||||
|
open, onClose, title, description, children, footer,
|
||||||
|
dismissible = true, closeLabel = 'Close', initialFocus,
|
||||||
|
overlayClass, panelClass, grip = false, bodyClass,
|
||||||
|
}) {
|
||||||
|
const panel = useRef(null)
|
||||||
|
const titleId = useId()
|
||||||
|
const descId = useId()
|
||||||
|
useModal(open, panel, { onClose, dismissible, initialFocus })
|
||||||
|
if (!open) return null
|
||||||
|
|
||||||
|
const showClose = dismissible && !!onClose
|
||||||
|
return (
|
||||||
|
<Portal>
|
||||||
|
<div
|
||||||
|
className={cx('x-overlay', overlayClass)}
|
||||||
|
onMouseDown={e => { if (e.target === e.currentTarget && dismissible) onClose?.() }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
ref={panel}
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby={title ? titleId : undefined}
|
||||||
|
aria-describedby={description ? descId : undefined}
|
||||||
|
tabIndex={-1}
|
||||||
|
className={panelClass}
|
||||||
|
>
|
||||||
|
{grip && <div className="x-sheet__grip" aria-hidden="true" />}
|
||||||
|
{(title || description || showClose) && (
|
||||||
|
<div className="x-modal__header">
|
||||||
|
<div className="x-modal__titles">
|
||||||
|
{title && <h2 id={titleId} className="x-modal__title">{title}</h2>}
|
||||||
|
{description && <p id={descId} className="x-modal__description">{description}</p>}
|
||||||
|
</div>
|
||||||
|
{showClose && (
|
||||||
|
<IconButton label={closeLabel} size="sm" className="x-modal__close" onClick={onClose} data-x-autofocus-skip="">
|
||||||
|
<CloseIcon />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{children != null && <div className={cx('x-modal__body', bodyClass)}>{children}</div>}
|
||||||
|
{footer && <div className="x-modal__footer">{footer}</div>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { createPortal } from 'react-dom'
|
||||||
|
|
||||||
|
/** Render children into document.body (dialogs, sheets, toasts, popovers). */
|
||||||
|
export function Portal({ children }) {
|
||||||
|
if (typeof document === 'undefined') return null
|
||||||
|
return createPortal(children, document.body)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/** Join class names, skipping falsy values: cx('a', cond && 'b') */
|
||||||
|
export function cx(...parts) {
|
||||||
|
return parts.filter(Boolean).join(' ')
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { useEffect, useLayoutEffect, useRef } from 'react'
|
||||||
|
|
||||||
|
// Shared by Dialog and Sheet: Escape closes (the topmost one only), focus moves in
|
||||||
|
// and is trapped while open, focus returns on close, and the page doesn't scroll.
|
||||||
|
|
||||||
|
const stack = [] // open modals, innermost last
|
||||||
|
let scrollLocks = 0
|
||||||
|
let savedOverflow = ''
|
||||||
|
|
||||||
|
const FOCUSABLE = [
|
||||||
|
'a[href]', 'button:not([disabled])', 'input:not([disabled]):not([type="hidden"])',
|
||||||
|
'select:not([disabled])', 'textarea:not([disabled])', '[tabindex]:not([tabindex="-1"])',
|
||||||
|
'[contenteditable="true"]',
|
||||||
|
].join(',')
|
||||||
|
|
||||||
|
export function focusables(root) {
|
||||||
|
return [...root.querySelectorAll(FOCUSABLE)].filter(el => el.getClientRects().length > 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Is this modal the innermost open one? (Toasts and popovers use it to stay out of the way.) */
|
||||||
|
export function isTopmost(token) {
|
||||||
|
return stack[stack.length - 1] === token
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} open
|
||||||
|
* @param {{ current: HTMLElement|null }} panelRef the dialog/sheet panel
|
||||||
|
* @param {{ onClose?: () => void, dismissible?: boolean, initialFocus?: { current: HTMLElement|null } }} opts
|
||||||
|
*/
|
||||||
|
export function useModal(open, panelRef, { onClose, dismissible = true, initialFocus } = {}) {
|
||||||
|
const latest = useRef({ onClose, dismissible })
|
||||||
|
useLayoutEffect(() => { latest.current = { onClose, dismissible } })
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return
|
||||||
|
const token = {}
|
||||||
|
stack.push(token)
|
||||||
|
const previous = document.activeElement
|
||||||
|
|
||||||
|
if (scrollLocks++ === 0) {
|
||||||
|
savedOverflow = document.body.style.overflow
|
||||||
|
document.body.style.overflow = 'hidden'
|
||||||
|
}
|
||||||
|
|
||||||
|
const panel = panelRef.current
|
||||||
|
const target = initialFocus?.current || (panel && focusables(panel).find(el => !el.hasAttribute('data-x-autofocus-skip'))) || panel
|
||||||
|
target?.focus({ preventScroll: true })
|
||||||
|
|
||||||
|
const onKey = e => {
|
||||||
|
if (!isTopmost(token)) return
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
if (latest.current.dismissible && latest.current.onClose) {
|
||||||
|
e.stopPropagation()
|
||||||
|
latest.current.onClose()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const root = panelRef.current
|
||||||
|
if (e.key !== 'Tab' || !root) return
|
||||||
|
const items = focusables(root)
|
||||||
|
if (!items.length) { e.preventDefault(); root.focus(); return }
|
||||||
|
const first = items[0]
|
||||||
|
const last = items[items.length - 1]
|
||||||
|
const inside = root.contains(document.activeElement)
|
||||||
|
if (e.shiftKey && (document.activeElement === first || !inside)) {
|
||||||
|
e.preventDefault(); last.focus()
|
||||||
|
} else if (!e.shiftKey && (document.activeElement === last || !inside)) {
|
||||||
|
e.preventDefault(); first.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener('keydown', onKey)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('keydown', onKey)
|
||||||
|
stack.splice(stack.indexOf(token), 1)
|
||||||
|
if (--scrollLocks === 0) document.body.style.overflow = savedOverflow
|
||||||
|
if (previous && typeof previous.focus === 'function' && document.contains(previous)) {
|
||||||
|
previous.focus({ preventScroll: true })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [open]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/* Tokens + component styles. Import once at the app root: import '@xenia/ui/styles.css' */
|
||||||
|
@import './tokens.css';
|
||||||
|
@import './components.css';
|
||||||
@@ -0,0 +1,374 @@
|
|||||||
|
/*
|
||||||
|
* @xenia/ui design tokens (APPS_PLATFORM §9, plan step 2.3).
|
||||||
|
*
|
||||||
|
* Every token is prefixed --x- so it never collides with an app's own variables
|
||||||
|
* (the waiter already uses --bg, --text, --accent…). This file only declares custom
|
||||||
|
* properties: importing it changes nothing on screen until something uses them.
|
||||||
|
*
|
||||||
|
* Colours come in two forms:
|
||||||
|
* --x-<name>-rgb space-separated channels, e.g. "15 118 110" (Tailwind preset: alpha support)
|
||||||
|
* --x-<name> ready to use, e.g. color: var(--x-ink)
|
||||||
|
*
|
||||||
|
* Theme, set on <html> (or any container; portals render in <body>, so prefer <html>):
|
||||||
|
* data-theme="light" (default) | "dark" | "system" (follows the OS)
|
||||||
|
* data-venue-theme="teal" (default) | "amber" | "blue" | "violet" | "rose" (accent colour only)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ── Light (default) ─────────────────────────────────────────────────────── */
|
||||||
|
:root {
|
||||||
|
--x-canvas-rgb: 248 250 252;
|
||||||
|
--x-surface-rgb: 255 255 255;
|
||||||
|
--x-surface-2-rgb: 241 245 249;
|
||||||
|
--x-surface-3-rgb: 226 232 240;
|
||||||
|
--x-line-rgb: 226 232 240;
|
||||||
|
--x-line-strong-rgb: 203 213 225;
|
||||||
|
--x-ink-rgb: 15 23 42;
|
||||||
|
--x-ink-2-rgb: 71 85 105;
|
||||||
|
--x-ink-3-rgb: 100 116 139;
|
||||||
|
--x-success-rgb: 21 128 61;
|
||||||
|
--x-success-fg-rgb: 255 255 255;
|
||||||
|
--x-success-soft-rgb: 220 252 231;
|
||||||
|
--x-success-ink-rgb: 21 128 61;
|
||||||
|
--x-warning-rgb: 180 83 9;
|
||||||
|
--x-warning-fg-rgb: 255 255 255;
|
||||||
|
--x-warning-soft-rgb: 254 243 199;
|
||||||
|
--x-warning-ink-rgb: 146 64 14;
|
||||||
|
--x-danger-rgb: 220 38 38;
|
||||||
|
--x-danger-fg-rgb: 255 255 255;
|
||||||
|
--x-danger-soft-rgb: 254 226 226;
|
||||||
|
--x-danger-ink-rgb: 185 28 28;
|
||||||
|
--x-info-rgb: 37 99 235;
|
||||||
|
--x-info-fg-rgb: 255 255 255;
|
||||||
|
--x-info-soft-rgb: 219 234 254;
|
||||||
|
--x-info-ink-rgb: 29 78 216;
|
||||||
|
--x-scrim-rgb: 15 23 42;
|
||||||
|
--x-accent-rgb: 15 118 110;
|
||||||
|
--x-accent-strong-rgb: 17 94 89;
|
||||||
|
--x-accent-fg-rgb: 255 255 255;
|
||||||
|
--x-accent-soft-rgb: 204 251 241;
|
||||||
|
--x-accent-ink-rgb: 17 94 89;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Dark ────────────────────────────────────────────────────────────────── */
|
||||||
|
[data-theme="dark"] {
|
||||||
|
--x-canvas-rgb: 13 21 32;
|
||||||
|
--x-surface-rgb: 26 37 53;
|
||||||
|
--x-surface-2-rgb: 36 48 68;
|
||||||
|
--x-surface-3-rgb: 46 61 84;
|
||||||
|
--x-line-rgb: 37 50 69;
|
||||||
|
--x-line-strong-rgb: 58 77 104;
|
||||||
|
--x-ink-rgb: 237 242 247;
|
||||||
|
--x-ink-2-rgb: 148 163 184;
|
||||||
|
--x-ink-3-rgb: 122 143 166;
|
||||||
|
--x-success-rgb: 34 197 94;
|
||||||
|
--x-success-fg-rgb: 5 46 22;
|
||||||
|
--x-success-soft-rgb: 20 83 45;
|
||||||
|
--x-success-ink-rgb: 134 239 172;
|
||||||
|
--x-warning-rgb: 245 158 11;
|
||||||
|
--x-warning-fg-rgb: 28 16 0;
|
||||||
|
--x-warning-soft-rgb: 107 58 0;
|
||||||
|
--x-warning-ink-rgb: 253 230 138;
|
||||||
|
--x-danger-rgb: 248 113 113;
|
||||||
|
--x-danger-fg-rgb: 69 10 10;
|
||||||
|
--x-danger-soft-rgb: 90 20 20;
|
||||||
|
--x-danger-ink-rgb: 254 202 202;
|
||||||
|
--x-info-rgb: 96 165 250;
|
||||||
|
--x-info-fg-rgb: 23 37 84;
|
||||||
|
--x-info-soft-rgb: 30 58 138;
|
||||||
|
--x-info-ink-rgb: 191 219 254;
|
||||||
|
--x-scrim-rgb: 0 0 0;
|
||||||
|
--x-accent-rgb: 45 212 191;
|
||||||
|
--x-accent-strong-rgb: 94 234 212;
|
||||||
|
--x-accent-fg-rgb: 4 47 46;
|
||||||
|
--x-accent-soft-rgb: 19 78 74;
|
||||||
|
--x-accent-ink-rgb: 153 246 228;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"] {
|
||||||
|
--x-canvas-rgb: 13 21 32;
|
||||||
|
--x-surface-rgb: 26 37 53;
|
||||||
|
--x-surface-2-rgb: 36 48 68;
|
||||||
|
--x-surface-3-rgb: 46 61 84;
|
||||||
|
--x-line-rgb: 37 50 69;
|
||||||
|
--x-line-strong-rgb: 58 77 104;
|
||||||
|
--x-ink-rgb: 237 242 247;
|
||||||
|
--x-ink-2-rgb: 148 163 184;
|
||||||
|
--x-ink-3-rgb: 122 143 166;
|
||||||
|
--x-success-rgb: 34 197 94;
|
||||||
|
--x-success-fg-rgb: 5 46 22;
|
||||||
|
--x-success-soft-rgb: 20 83 45;
|
||||||
|
--x-success-ink-rgb: 134 239 172;
|
||||||
|
--x-warning-rgb: 245 158 11;
|
||||||
|
--x-warning-fg-rgb: 28 16 0;
|
||||||
|
--x-warning-soft-rgb: 107 58 0;
|
||||||
|
--x-warning-ink-rgb: 253 230 138;
|
||||||
|
--x-danger-rgb: 248 113 113;
|
||||||
|
--x-danger-fg-rgb: 69 10 10;
|
||||||
|
--x-danger-soft-rgb: 90 20 20;
|
||||||
|
--x-danger-ink-rgb: 254 202 202;
|
||||||
|
--x-info-rgb: 96 165 250;
|
||||||
|
--x-info-fg-rgb: 23 37 84;
|
||||||
|
--x-info-soft-rgb: 30 58 138;
|
||||||
|
--x-info-ink-rgb: 191 219 254;
|
||||||
|
--x-scrim-rgb: 0 0 0;
|
||||||
|
--x-accent-rgb: 45 212 191;
|
||||||
|
--x-accent-strong-rgb: 94 234 212;
|
||||||
|
--x-accent-fg-rgb: 4 47 46;
|
||||||
|
--x-accent-soft-rgb: 19 78 74;
|
||||||
|
--x-accent-ink-rgb: 153 246 228;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Venue themes (accent only) ──────────────────────────────────────────── */
|
||||||
|
[data-venue-theme="teal"] {
|
||||||
|
--x-accent-rgb: 15 118 110;
|
||||||
|
--x-accent-strong-rgb: 17 94 89;
|
||||||
|
--x-accent-fg-rgb: 255 255 255;
|
||||||
|
--x-accent-soft-rgb: 204 251 241;
|
||||||
|
--x-accent-ink-rgb: 17 94 89;
|
||||||
|
}
|
||||||
|
[data-theme="dark"][data-venue-theme="teal"],
|
||||||
|
[data-theme="dark"] [data-venue-theme="teal"] {
|
||||||
|
--x-accent-rgb: 45 212 191;
|
||||||
|
--x-accent-strong-rgb: 94 234 212;
|
||||||
|
--x-accent-fg-rgb: 4 47 46;
|
||||||
|
--x-accent-soft-rgb: 19 78 74;
|
||||||
|
--x-accent-ink-rgb: 153 246 228;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"][data-venue-theme="teal"],
|
||||||
|
[data-theme="system"] [data-venue-theme="teal"] {
|
||||||
|
--x-accent-rgb: 45 212 191;
|
||||||
|
--x-accent-strong-rgb: 94 234 212;
|
||||||
|
--x-accent-fg-rgb: 4 47 46;
|
||||||
|
--x-accent-soft-rgb: 19 78 74;
|
||||||
|
--x-accent-ink-rgb: 153 246 228;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[data-venue-theme="amber"] {
|
||||||
|
--x-accent-rgb: 180 83 9;
|
||||||
|
--x-accent-strong-rgb: 146 64 14;
|
||||||
|
--x-accent-fg-rgb: 255 255 255;
|
||||||
|
--x-accent-soft-rgb: 254 243 199;
|
||||||
|
--x-accent-ink-rgb: 146 64 14;
|
||||||
|
}
|
||||||
|
[data-theme="dark"][data-venue-theme="amber"],
|
||||||
|
[data-theme="dark"] [data-venue-theme="amber"] {
|
||||||
|
--x-accent-rgb: 245 158 11;
|
||||||
|
--x-accent-strong-rgb: 251 191 36;
|
||||||
|
--x-accent-fg-rgb: 28 16 0;
|
||||||
|
--x-accent-soft-rgb: 107 58 0;
|
||||||
|
--x-accent-ink-rgb: 253 230 138;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"][data-venue-theme="amber"],
|
||||||
|
[data-theme="system"] [data-venue-theme="amber"] {
|
||||||
|
--x-accent-rgb: 245 158 11;
|
||||||
|
--x-accent-strong-rgb: 251 191 36;
|
||||||
|
--x-accent-fg-rgb: 28 16 0;
|
||||||
|
--x-accent-soft-rgb: 107 58 0;
|
||||||
|
--x-accent-ink-rgb: 253 230 138;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[data-venue-theme="blue"] {
|
||||||
|
--x-accent-rgb: 37 99 235;
|
||||||
|
--x-accent-strong-rgb: 29 78 216;
|
||||||
|
--x-accent-fg-rgb: 255 255 255;
|
||||||
|
--x-accent-soft-rgb: 219 234 254;
|
||||||
|
--x-accent-ink-rgb: 29 78 216;
|
||||||
|
}
|
||||||
|
[data-theme="dark"][data-venue-theme="blue"],
|
||||||
|
[data-theme="dark"] [data-venue-theme="blue"] {
|
||||||
|
--x-accent-rgb: 96 165 250;
|
||||||
|
--x-accent-strong-rgb: 147 197 253;
|
||||||
|
--x-accent-fg-rgb: 23 37 84;
|
||||||
|
--x-accent-soft-rgb: 30 58 138;
|
||||||
|
--x-accent-ink-rgb: 191 219 254;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"][data-venue-theme="blue"],
|
||||||
|
[data-theme="system"] [data-venue-theme="blue"] {
|
||||||
|
--x-accent-rgb: 96 165 250;
|
||||||
|
--x-accent-strong-rgb: 147 197 253;
|
||||||
|
--x-accent-fg-rgb: 23 37 84;
|
||||||
|
--x-accent-soft-rgb: 30 58 138;
|
||||||
|
--x-accent-ink-rgb: 191 219 254;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[data-venue-theme="violet"] {
|
||||||
|
--x-accent-rgb: 124 58 237;
|
||||||
|
--x-accent-strong-rgb: 109 40 217;
|
||||||
|
--x-accent-fg-rgb: 255 255 255;
|
||||||
|
--x-accent-soft-rgb: 237 233 254;
|
||||||
|
--x-accent-ink-rgb: 91 33 182;
|
||||||
|
}
|
||||||
|
[data-theme="dark"][data-venue-theme="violet"],
|
||||||
|
[data-theme="dark"] [data-venue-theme="violet"] {
|
||||||
|
--x-accent-rgb: 167 139 250;
|
||||||
|
--x-accent-strong-rgb: 196 181 253;
|
||||||
|
--x-accent-fg-rgb: 46 16 101;
|
||||||
|
--x-accent-soft-rgb: 76 29 149;
|
||||||
|
--x-accent-ink-rgb: 221 214 254;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"][data-venue-theme="violet"],
|
||||||
|
[data-theme="system"] [data-venue-theme="violet"] {
|
||||||
|
--x-accent-rgb: 167 139 250;
|
||||||
|
--x-accent-strong-rgb: 196 181 253;
|
||||||
|
--x-accent-fg-rgb: 46 16 101;
|
||||||
|
--x-accent-soft-rgb: 76 29 149;
|
||||||
|
--x-accent-ink-rgb: 221 214 254;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[data-venue-theme="rose"] {
|
||||||
|
--x-accent-rgb: 225 29 72;
|
||||||
|
--x-accent-strong-rgb: 190 18 60;
|
||||||
|
--x-accent-fg-rgb: 255 255 255;
|
||||||
|
--x-accent-soft-rgb: 255 228 230;
|
||||||
|
--x-accent-ink-rgb: 159 18 57;
|
||||||
|
}
|
||||||
|
[data-theme="dark"][data-venue-theme="rose"],
|
||||||
|
[data-theme="dark"] [data-venue-theme="rose"] {
|
||||||
|
--x-accent-rgb: 251 113 133;
|
||||||
|
--x-accent-strong-rgb: 253 164 175;
|
||||||
|
--x-accent-fg-rgb: 76 5 25;
|
||||||
|
--x-accent-soft-rgb: 136 19 55;
|
||||||
|
--x-accent-ink-rgb: 254 205 211;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"][data-venue-theme="rose"],
|
||||||
|
[data-theme="system"] [data-venue-theme="rose"] {
|
||||||
|
--x-accent-rgb: 251 113 133;
|
||||||
|
--x-accent-strong-rgb: 253 164 175;
|
||||||
|
--x-accent-fg-rgb: 76 5 25;
|
||||||
|
--x-accent-soft-rgb: 136 19 55;
|
||||||
|
--x-accent-ink-rgb: 254 205 211;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Ready-to-use colours ────────────────────────────────────────────────────
|
||||||
|
* Redeclared wherever the channels can change, so a nested data-theme /
|
||||||
|
* data-venue-theme container gets its own values (custom properties are
|
||||||
|
* resolved where they are declared, then inherited). */
|
||||||
|
:root,
|
||||||
|
[data-theme],
|
||||||
|
[data-venue-theme] {
|
||||||
|
--x-canvas: rgb(var(--x-canvas-rgb));
|
||||||
|
--x-surface: rgb(var(--x-surface-rgb));
|
||||||
|
--x-surface-2: rgb(var(--x-surface-2-rgb));
|
||||||
|
--x-surface-3: rgb(var(--x-surface-3-rgb));
|
||||||
|
--x-line: rgb(var(--x-line-rgb));
|
||||||
|
--x-line-strong: rgb(var(--x-line-strong-rgb));
|
||||||
|
--x-ink: rgb(var(--x-ink-rgb));
|
||||||
|
--x-ink-2: rgb(var(--x-ink-2-rgb));
|
||||||
|
--x-ink-3: rgb(var(--x-ink-3-rgb));
|
||||||
|
--x-success: rgb(var(--x-success-rgb));
|
||||||
|
--x-success-fg: rgb(var(--x-success-fg-rgb));
|
||||||
|
--x-success-soft: rgb(var(--x-success-soft-rgb));
|
||||||
|
--x-success-ink: rgb(var(--x-success-ink-rgb));
|
||||||
|
--x-warning: rgb(var(--x-warning-rgb));
|
||||||
|
--x-warning-fg: rgb(var(--x-warning-fg-rgb));
|
||||||
|
--x-warning-soft: rgb(var(--x-warning-soft-rgb));
|
||||||
|
--x-warning-ink: rgb(var(--x-warning-ink-rgb));
|
||||||
|
--x-danger: rgb(var(--x-danger-rgb));
|
||||||
|
--x-danger-fg: rgb(var(--x-danger-fg-rgb));
|
||||||
|
--x-danger-soft: rgb(var(--x-danger-soft-rgb));
|
||||||
|
--x-danger-ink: rgb(var(--x-danger-ink-rgb));
|
||||||
|
--x-info: rgb(var(--x-info-rgb));
|
||||||
|
--x-info-fg: rgb(var(--x-info-fg-rgb));
|
||||||
|
--x-info-soft: rgb(var(--x-info-soft-rgb));
|
||||||
|
--x-info-ink: rgb(var(--x-info-ink-rgb));
|
||||||
|
--x-scrim: rgb(var(--x-scrim-rgb));
|
||||||
|
--x-accent: rgb(var(--x-accent-rgb));
|
||||||
|
--x-accent-strong: rgb(var(--x-accent-strong-rgb));
|
||||||
|
--x-accent-fg: rgb(var(--x-accent-fg-rgb));
|
||||||
|
--x-accent-soft: rgb(var(--x-accent-soft-rgb));
|
||||||
|
--x-accent-ink: rgb(var(--x-accent-ink-rgb));
|
||||||
|
--x-focus-ring: 0 0 0 3px rgb(var(--x-accent-rgb) / 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For native controls (select popups, scrollbars) inside @xenia/ui components only.
|
||||||
|
* Deliberately NOT set on <html>: that would restyle an app's own controls. */
|
||||||
|
:root { --x-color-scheme: light; }
|
||||||
|
[data-theme="dark"] { --x-color-scheme: dark; }
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"] { --x-color-scheme: dark; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Everything that doesn't depend on the theme ─────────────────────────── */
|
||||||
|
:root {
|
||||||
|
/* Type */
|
||||||
|
--x-font-sans: "Google Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||||
|
--x-font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
|
||||||
|
--x-text-caption: 12px; --x-leading-caption: 16px;
|
||||||
|
--x-text-label: 13px; --x-leading-label: 18px;
|
||||||
|
--x-text-body: 14px; --x-leading-body: 20px;
|
||||||
|
--x-text-body-lg: 16px; --x-leading-body-lg: 24px;
|
||||||
|
--x-text-title: 18px; --x-leading-title: 26px;
|
||||||
|
--x-text-heading: 22px; --x-leading-heading: 30px;
|
||||||
|
--x-text-display: 28px; --x-leading-display: 36px;
|
||||||
|
--x-weight-regular: 400;
|
||||||
|
--x-weight-medium: 500;
|
||||||
|
--x-weight-semibold: 600;
|
||||||
|
--x-weight-bold: 700;
|
||||||
|
|
||||||
|
/* Spacing: the same 4 px steps as Tailwind's default scale (p-1 = 4px … p-16 = 64px) */
|
||||||
|
--x-space-0-5: 2px;
|
||||||
|
--x-space-1: 4px;
|
||||||
|
--x-space-1-5: 6px;
|
||||||
|
--x-space-2: 8px;
|
||||||
|
--x-space-2-5: 10px;
|
||||||
|
--x-space-3: 12px;
|
||||||
|
--x-space-4: 16px;
|
||||||
|
--x-space-5: 20px;
|
||||||
|
--x-space-6: 24px;
|
||||||
|
--x-space-8: 32px;
|
||||||
|
--x-space-10: 40px;
|
||||||
|
--x-space-12: 48px;
|
||||||
|
--x-space-16: 64px;
|
||||||
|
|
||||||
|
/* Radius */
|
||||||
|
--x-radius-sm: 8px; /* chips, small controls */
|
||||||
|
--x-radius-control: 12px; /* buttons, inputs (the manager's rounded-xl) */
|
||||||
|
--x-radius-card: 16px; /* cards, popovers (rounded-2xl) */
|
||||||
|
--x-radius-dialog: 20px; /* dialogs, sheets */
|
||||||
|
--x-radius-full: 9999px;
|
||||||
|
|
||||||
|
/* Control heights: 44 px is the minimum touch target */
|
||||||
|
--x-control-sm: 36px;
|
||||||
|
--x-control-md: 44px;
|
||||||
|
--x-control-lg: 52px;
|
||||||
|
|
||||||
|
/* Elevation */
|
||||||
|
--x-shadow-raised: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 3px rgb(15 23 42 / 0.08);
|
||||||
|
--x-shadow-popover: 0 8px 24px rgb(15 23 42 / 0.12), 0 2px 6px rgb(15 23 42 / 0.08);
|
||||||
|
--x-shadow-overlay: 0 24px 48px rgb(15 23 42 / 0.18), 0 8px 16px rgb(15 23 42 / 0.10);
|
||||||
|
|
||||||
|
/* Motion */
|
||||||
|
--x-duration-fast: 120ms;
|
||||||
|
--x-duration-base: 180ms;
|
||||||
|
--x-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||||
|
|
||||||
|
/* Stacking */
|
||||||
|
--x-z-overlay: 1000;
|
||||||
|
--x-z-toast: 1100;
|
||||||
|
--x-z-popover: 1200;
|
||||||
|
}
|
||||||
|
[data-theme="dark"] {
|
||||||
|
--x-shadow-raised: 0 1px 2px rgb(0 0 0 / 0.30), 0 1px 3px rgb(0 0 0 / 0.30);
|
||||||
|
--x-shadow-popover: 0 8px 24px rgb(0 0 0 / 0.45), 0 2px 6px rgb(0 0 0 / 0.30);
|
||||||
|
--x-shadow-overlay: 0 24px 48px rgb(0 0 0 / 0.55), 0 8px 16px rgb(0 0 0 / 0.35);
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
[data-theme="system"] {
|
||||||
|
--x-shadow-raised: 0 1px 2px rgb(0 0 0 / 0.30), 0 1px 3px rgb(0 0 0 / 0.30);
|
||||||
|
--x-shadow-popover: 0 8px 24px rgb(0 0 0 / 0.45), 0 2px 6px rgb(0 0 0 / 0.30);
|
||||||
|
--x-shadow-overlay: 0 24px 48px rgb(0 0 0 / 0.55), 0 8px 16px rgb(0 0 0 / 0.35);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
:root {
|
||||||
|
--x-duration-fast: 0ms;
|
||||||
|
--x-duration-base: 0ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// WCAG contrast of the token pairs the components actually use, in light and dark,
|
||||||
|
// for every venue theme. Reads tokens.css itself, so a colour edit that breaks
|
||||||
|
// readability fails here.
|
||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
import { test } from 'node:test'
|
||||||
|
|
||||||
|
const css = readFileSync(new URL('../src/tokens.css', import.meta.url), 'utf8')
|
||||||
|
|
||||||
|
/** Channel declarations of the first rule whose selector list is exactly `selector`. */
|
||||||
|
function rule(selector) {
|
||||||
|
const re = /([^{}]+)\{([^{}]*)\}/g
|
||||||
|
for (const m of css.matchAll(re)) {
|
||||||
|
const sel = m[1].replace(/\/\*[\s\S]*?\*\//g, '').trim().replace(/\s+/g, ' ')
|
||||||
|
if (sel !== selector) continue
|
||||||
|
return Object.fromEntries([...m[2].matchAll(/--x-([\w-]+)-rgb:\s*([\d\s]+);/g)].map(([, k, v]) => [k, v.trim().split(/\s+/).map(Number)]))
|
||||||
|
}
|
||||||
|
throw new Error(`no rule ${selector}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const lum = ([r, g, b]) => {
|
||||||
|
const f = c => { c /= 255; return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4 }
|
||||||
|
return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b)
|
||||||
|
}
|
||||||
|
const ratio = (a, b) => { const [x, y] = [lum(a), lum(b)].sort((p, q) => q - p); return (x + 0.05) / (y + 0.05) }
|
||||||
|
|
||||||
|
const TEXT = 4.5 // normal-size text (AA)
|
||||||
|
const UI = 3 // component boundaries and states (AA, 1.4.11)
|
||||||
|
const pairs = [
|
||||||
|
['ink', 'surface', TEXT], ['ink-2', 'surface', TEXT], ['ink-3', 'surface', TEXT], ['ink', 'canvas', TEXT],
|
||||||
|
['ink-2', 'surface-2', TEXT],
|
||||||
|
['canvas', 'ink', TEXT], // InfoTip popover
|
||||||
|
['accent-fg', 'accent', TEXT], ['accent-fg', 'accent-strong', TEXT],
|
||||||
|
['accent-ink', 'accent-soft', TEXT], ['accent-ink', 'surface', TEXT],
|
||||||
|
['accent', 'surface', UI], // switch on, focus, filled PIN dots
|
||||||
|
['ink-3', 'surface', UI], // switch off track
|
||||||
|
...['success', 'warning', 'danger', 'info'].flatMap(t => [
|
||||||
|
[`${t}-fg`, t, TEXT], [`${t}-ink`, `${t}-soft`, TEXT], [`${t}-ink`, 'surface', TEXT], [t, 'surface', UI],
|
||||||
|
]),
|
||||||
|
]
|
||||||
|
|
||||||
|
const venues = ['teal', 'amber', 'blue', 'violet', 'rose']
|
||||||
|
const light = rule(':root')
|
||||||
|
const dark = rule('[data-theme="dark"]')
|
||||||
|
|
||||||
|
for (const venue of venues) {
|
||||||
|
for (const [mode, base, sel] of [
|
||||||
|
['light', light, `[data-venue-theme="${venue}"]`],
|
||||||
|
['dark', dark, `[data-theme="dark"][data-venue-theme="${venue}"], [data-theme="dark"] [data-venue-theme="${venue}"]`],
|
||||||
|
]) {
|
||||||
|
test(`${venue} / ${mode}`, () => {
|
||||||
|
const t = { ...base, ...rule(sel) }
|
||||||
|
const failures = pairs
|
||||||
|
.map(([fg, bg, min]) => [fg, bg, min, ratio(t[fg], t[bg])])
|
||||||
|
.filter(([, , min, r]) => r < min)
|
||||||
|
.map(([fg, bg, min, r]) => `${fg} on ${bg}: ${r.toFixed(2)} < ${min}`)
|
||||||
|
assert.deepEqual(failures, [])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('system theme mirrors dark', () => {
|
||||||
|
const sys = css.slice(css.indexOf('@media (prefers-color-scheme: dark)'))
|
||||||
|
assert.match(sys, /\[data-theme="system"\]/)
|
||||||
|
const darkCanvas = dark.canvas.join(' ')
|
||||||
|
assert.ok(sys.includes(`--x-canvas-rgb: ${darkCanvas};`), 'system dark uses the dark canvas')
|
||||||
|
})
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { test } from 'node:test'
|
||||||
|
import { nextPin, pinAction } from '../src/components/pin.js'
|
||||||
|
|
||||||
|
test('keys map to actions', () => {
|
||||||
|
assert.deepEqual(pinAction('7'), { type: 'digit', digit: '7' })
|
||||||
|
assert.deepEqual(pinAction('Backspace'), { type: 'backspace' })
|
||||||
|
assert.deepEqual(pinAction('Delete'), { type: 'backspace' })
|
||||||
|
for (const k of ['a', 'Enter', 'Escape', ' ', '12', '']) assert.equal(pinAction(k), null, k)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('digits stop at the length', () => {
|
||||||
|
let v = ''
|
||||||
|
for (const k of '123456') v = nextPin(v, pinAction(k), 4)
|
||||||
|
assert.equal(v, '1234')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('backspace and clear', () => {
|
||||||
|
assert.equal(nextPin('123', { type: 'backspace' }, 4), '12')
|
||||||
|
assert.equal(nextPin('', { type: 'backspace' }, 4), '')
|
||||||
|
assert.equal(nextPin('123', { type: 'clear' }, 4), '')
|
||||||
|
assert.equal(nextPin('12', null, 4), '12')
|
||||||
|
})
|
||||||
@@ -14,6 +14,9 @@ python -m pytest tests -q -m db # DB tests only: real app + temp SQLite
|
|||||||
|
|
||||||
cd ../waiter_pwa
|
cd ../waiter_pwa
|
||||||
npm test # server rediscovery scan
|
npm test # server rediscovery scan
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
npm test -w @xenia/ui # PIN rules + WCAG contrast of every token pair (light/dark × venue themes)
|
||||||
```
|
```
|
||||||
|
|
||||||
**DB tests** (`local_backend/tests/conftest.py`) run the real FastAPI app against a throwaway SQLite database in a temp folder (never your dev or venue DB). Fixtures: `db` (session, rolled back after each test even if the code commits), `client` (TestClient with `get_db` overridden, license check open, no lifespan), `make_user(role=..., perms=...)` (password `password`, PIN `1234`), `login(user)` (auth headers). A test that uses any of them is marked `db` automatically.
|
**DB tests** (`local_backend/tests/conftest.py`) run the real FastAPI app against a throwaway SQLite database in a temp folder (never your dev or venue DB). Fixtures: `db` (session, rolled back after each test even if the code commits), `client` (TestClient with `get_db` overridden, license check open, no lifespan), `make_user(role=..., perms=...)` (password `password`, PIN `1234`), `login(user)` (auth headers). A test that uses any of them is marked `db` automatically.
|
||||||
@@ -33,6 +36,7 @@ Or run one suite at a time:
|
|||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `node install.mjs` | `install.sh`: VPN-safe `HOST_IP` detection (simulated WireGuard/WiFi hosts); fresh install, upgrade, re-run; proxy config identical to `nginx-proxy/nginx.conf` | Docker | ~1 min |
|
| `node install.mjs` | `install.sh`: VPN-safe `HOST_IP` detection (simulated WireGuard/WiFi hosts); fresh install, upgrade, re-run; proxy config identical to `nginx-proxy/nginx.conf` | Docker | ~1 min |
|
||||||
| `python license_e2e.py` | Offline licensing with a real cloud + site process: 400 days offline, tampered file, clock set back, expiry deferred to workday close, renewal, remote lock | Python deps of both backends | ~2 min |
|
| `python license_e2e.py` | Offline licensing with a real cloud + site process: 400 days offline, tampered file, clock set back, expiry deferred to workday close, renewal, remote lock | Python deps of both backends | ~2 min |
|
||||||
|
| `node ui.mjs` | `@xenia/ui` components on the dev-only gallery (`/ui-gallery`, manager Vite :5185): dialog focus/Escape/backdrop, sheet, toasts, field wiring, switch, InfoTip, PinPad, themes | Edge | ~30 s |
|
||||||
| `node browser.mjs` | Waiter web modes (same-origin, plain HTTP by LAN IP, venue mode), install dialog + drawer entry (Android / iPhone / desktop / no APK) | Docker, Edge | ~2 min |
|
| `node browser.mjs` | Waiter web modes (same-origin, plain HTTP by LAN IP, venue mode), install dialog + drawer entry (Android / iPhone / desktop / no APK) | Docker, Edge | ~2 min |
|
||||||
| `node android.mjs basics` | Pairing, wrong address / other venue's QR, login + live WS, back button, restart, two venues, camera permission | Android emulator | ~5 min |
|
| `node android.mjs basics` | Pairing, wrong address / other venue's QR, login + live WS, back button, restart, two venues, camera permission | Android emulator | ~5 min |
|
||||||
| `node android.mjs rediscovery` | Server IP change (logged in / out), server down + manual search, cold start while offline | Android emulator | ~4 min |
|
| `node android.mjs rediscovery` | Server IP change (logged in / out), server down + manual search, cold start while offline | Android emulator | ~4 min |
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
// node run-all.mjs everything (Android included)
|
// node run-all.mjs everything (Android included)
|
||||||
// node run-all.mjs --no-android skip the emulator suite
|
// node run-all.mjs --no-android skip the emulator suite
|
||||||
import { spawnSync } from 'node:child_process'
|
import { spawnSync } from 'node:child_process'
|
||||||
import { BACKEND, E2E, PYTHON, WAITER } from './lib/env.mjs'
|
import { BACKEND, CS, E2E, PYTHON, WAITER } from './lib/env.mjs'
|
||||||
|
|
||||||
const shell = process.platform === 'win32'
|
const shell = process.platform === 'win32'
|
||||||
const suites = [
|
const suites = [
|
||||||
['unit: local_backend (pytest)', PYTHON, ['-m', 'pytest', 'tests', '-q'], BACKEND],
|
['unit: local_backend (pytest)', PYTHON, ['-m', 'pytest', 'tests', '-q'], BACKEND],
|
||||||
['unit: waiter_pwa (node --test)', 'npm', ['test', '--silent'], WAITER],
|
['unit: waiter_pwa (node --test)', 'npm', ['test', '--silent'], WAITER],
|
||||||
|
['unit: packages/ui (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/ui'], CS],
|
||||||
['install.sh', 'node', ['install.mjs'], E2E],
|
['install.sh', 'node', ['install.mjs'], E2E],
|
||||||
['license (cloud + site)', PYTHON, ['license_e2e.py'], E2E],
|
['license (cloud + site)', PYTHON, ['license_e2e.py'], E2E],
|
||||||
['browser', 'node', ['browser.mjs'], E2E],
|
['browser', 'node', ['browser.mjs'], E2E],
|
||||||
|
['ui (@xenia/ui gallery)', 'node', ['ui.mjs'], E2E],
|
||||||
]
|
]
|
||||||
if (!process.argv.includes('--no-android')) suites.push(['android (emulator)', 'node', ['android.mjs'], E2E])
|
if (!process.argv.includes('--no-android')) suites.push(['android (emulator)', 'node', ['android.mjs'], E2E])
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
// @xenia/ui suite (Playwright + Edge): the shared components' behaviour on the
|
||||||
|
// gallery page (plan step 2.3). Starts the manager's Vite dev server (:5185), which
|
||||||
|
// serves /ui-gallery in dev builds only. No backend needed.
|
||||||
|
// node ui.mjs
|
||||||
|
import { spawn } from 'node:child_process'
|
||||||
|
import { openSync } from 'node:fs'
|
||||||
|
import path from 'node:path'
|
||||||
|
import { chromium } from 'playwright'
|
||||||
|
import { BROWSER_CHANNEL, CS, OUT, reporter, sleep } from './lib/env.mjs'
|
||||||
|
import { killTree, waitHttp } from './lib/proc.mjs'
|
||||||
|
|
||||||
|
const PORT = 5185
|
||||||
|
const URL = `http://localhost:${PORT}/ui-gallery`
|
||||||
|
const log = openSync(path.join(OUT, `vite-${PORT}.log`), 'w')
|
||||||
|
const vite = spawn('npx', ['vite', '--port', String(PORT), '--strictPort'], {
|
||||||
|
cwd: path.join(CS, 'manager_dashboard'), shell: process.platform === 'win32', detached: process.platform !== 'win32',
|
||||||
|
stdio: ['ignore', log, log],
|
||||||
|
})
|
||||||
|
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
||||||
|
const r = reporter('ui: @xenia/ui components (gallery)')
|
||||||
|
|
||||||
|
try {
|
||||||
|
await waitHttp(`http://localhost:${PORT}/`)
|
||||||
|
const p = await browser.newPage({ viewport: { width: 1280, height: 900 } })
|
||||||
|
const errs = []
|
||||||
|
p.on('pageerror', e => errs.push('pageerror: ' + e.message))
|
||||||
|
// The manager shell may call the API (no backend here): ignore failed requests only
|
||||||
|
p.on('console', m => { if (m.type() === 'error' && !/Failed to load resource/i.test(m.text())) errs.push(m.text().slice(0, 200)) })
|
||||||
|
const active = () => p.evaluate(() => { const a = document.activeElement; return a ? (a.getAttribute('aria-label') || a.textContent || a.tagName).trim().slice(0, 40) : null })
|
||||||
|
const btn = name => p.getByRole('button', { name, exact: true })
|
||||||
|
|
||||||
|
await p.goto(URL)
|
||||||
|
await p.waitForSelector('text=@xenia/ui gallery', { timeout: 60_000 })
|
||||||
|
|
||||||
|
// Dialog
|
||||||
|
await btn('Open dialog').click()
|
||||||
|
const dlg = p.getByRole('dialog', { name: 'Delete product?' })
|
||||||
|
r.check('dialog: opens with role + accessible name', await dlg.isVisible())
|
||||||
|
r.check('dialog: focuses the first field, not the ×', await p.evaluate(() => document.activeElement?.tagName) === 'INPUT')
|
||||||
|
for (let i = 0; i < 6; i++) await p.keyboard.press('Tab')
|
||||||
|
r.check('dialog: Tab stays inside', await p.evaluate(() => !!document.activeElement?.closest('[role="dialog"]')))
|
||||||
|
r.check('dialog: page scroll locked', await p.evaluate(() => document.body.style.overflow) === 'hidden')
|
||||||
|
await p.keyboard.press('Escape')
|
||||||
|
r.check('dialog: Escape closes, focus back on the opener', !(await dlg.isVisible()) && (await active()) === 'Open dialog')
|
||||||
|
r.check('dialog: scroll unlocked', await p.evaluate(() => document.body.style.overflow) === '')
|
||||||
|
await btn('Open dialog').click()
|
||||||
|
await p.mouse.click(10, 10)
|
||||||
|
r.check('dialog: backdrop click closes', !(await dlg.isVisible()))
|
||||||
|
await btn('Non-dismissible dialog').click()
|
||||||
|
await p.keyboard.press('Escape'); await p.mouse.click(10, 10)
|
||||||
|
const locked = p.getByRole('dialog', { name: 'Finish the close of day' })
|
||||||
|
r.check('dialog: non-dismissible ignores Escape/backdrop, no ×', await locked.isVisible() && (await locked.getByRole('button', { name: 'Close' }).count()) === 0)
|
||||||
|
await locked.getByRole('button', { name: 'Done' }).click()
|
||||||
|
|
||||||
|
// Sheet
|
||||||
|
await btn('Bottom sheet').click()
|
||||||
|
const sheet = p.getByRole('dialog', { name: 'Move order' })
|
||||||
|
await sheet.getByRole('button', { name: 'Close' }).click()
|
||||||
|
r.check('sheet: × closes', !(await sheet.isVisible()))
|
||||||
|
|
||||||
|
// Toast
|
||||||
|
await btn('Toast: success').click()
|
||||||
|
await btn('Toast: danger').click()
|
||||||
|
r.check('toast: success is a polite status, danger an alert',
|
||||||
|
await p.locator('.x-toast--success[role="status"]').count() === 1 && await p.locator('.x-toast--danger[role="alert"]').count() === 1)
|
||||||
|
await btn('Toast: action').click()
|
||||||
|
await p.getByRole('button', { name: 'Undo' }).click()
|
||||||
|
r.check('toast: action runs and dismisses', await p.locator('.x-toast', { hasText: 'Undone' }).count() === 1 && await p.locator('.x-toast', { hasText: 'Order moved' }).count() === 0)
|
||||||
|
await sleep(4500)
|
||||||
|
r.check('toast: auto-dismisses', await p.locator('.x-toast', { hasText: 'Saved' }).count() === 0)
|
||||||
|
|
||||||
|
// Field
|
||||||
|
const price = p.getByLabel('Price')
|
||||||
|
r.check('field: error wired (aria-invalid + aria-describedby)', await price.getAttribute('aria-invalid') === 'true' &&
|
||||||
|
await p.evaluate(id => document.getElementById(id)?.textContent, await price.getAttribute('aria-describedby')) === 'Enter a price, e.g. 3,50')
|
||||||
|
const name = p.getByLabel('Product name *')
|
||||||
|
r.check('field: required + hint wired', await name.getAttribute('required') !== null &&
|
||||||
|
(await p.evaluate(id => document.getElementById(id)?.textContent, await name.getAttribute('aria-describedby'))).startsWith('Shown on'))
|
||||||
|
|
||||||
|
// Switch
|
||||||
|
const sw = p.getByRole('switch', { name: 'Alert after print failures' })
|
||||||
|
await sw.click()
|
||||||
|
r.check('switch: toggles aria-checked', await sw.getAttribute('aria-checked') === 'true')
|
||||||
|
await p.getByText('Print kitchen tickets').click()
|
||||||
|
r.check('switch: the label toggles it', await p.getByRole('switch', { name: 'Print kitchen tickets' }).getAttribute('aria-checked') === 'false')
|
||||||
|
|
||||||
|
// InfoTip
|
||||||
|
const tip = p.getByRole('button', { name: 'More info' }).first()
|
||||||
|
await tip.click()
|
||||||
|
r.check('infotip: opens', await p.getByRole('tooltip').isVisible())
|
||||||
|
await p.keyboard.press('Escape')
|
||||||
|
r.check('infotip: Escape closes, focus back', !(await p.getByRole('tooltip').isVisible()) && (await active()) === 'More info')
|
||||||
|
await tip.click(); await p.mouse.click(5, 300)
|
||||||
|
r.check('infotip: click outside closes', !(await p.getByRole('tooltip').isVisible()))
|
||||||
|
|
||||||
|
// PinPad
|
||||||
|
const pad = p.locator('.x-pinpad')
|
||||||
|
await pad.scrollIntoViewIfNeeded()
|
||||||
|
for (const d of '9999') await pad.getByRole('button', { name: d, exact: true }).click()
|
||||||
|
await sleep(900)
|
||||||
|
r.check('pinpad: wrong PIN → error, cleared', await pad.getByRole('alert').textContent() === 'Wrong PIN' && await pad.locator('.x-pinpad__dot--filled').count() === 0)
|
||||||
|
await pad.getByRole('button', { name: '1', exact: true }).click()
|
||||||
|
await pad.getByRole('button', { name: 'Delete' }).click()
|
||||||
|
r.check('pinpad: backspace', await pad.locator('.x-pinpad__dot--filled').count() === 0)
|
||||||
|
await p.locator('body').click({ position: { x: 5, y: 5 } })
|
||||||
|
await p.keyboard.type('1234')
|
||||||
|
await sleep(900)
|
||||||
|
r.check('pinpad: right PIN from the keyboard', (await p.getByTestId('pin-result').textContent()).startsWith('Unlocked'))
|
||||||
|
await name.fill('')
|
||||||
|
await name.type('12')
|
||||||
|
r.check('pinpad: typing in a field does not feed it', await pad.locator('.x-pinpad__dot--filled').count() === 0)
|
||||||
|
|
||||||
|
// Themes
|
||||||
|
await p.getByLabel('Theme', { exact: true }).selectOption('dark')
|
||||||
|
await p.getByLabel('Venue theme').selectOption('amber')
|
||||||
|
await sleep(500) // buttons fade between colours
|
||||||
|
const bg = await p.evaluate(() => getComputedStyle(document.querySelector('.x-btn--primary')).backgroundColor)
|
||||||
|
r.check('theme: dark + venue amber change the accent', bg === 'rgb(245, 158, 11)', bg)
|
||||||
|
await p.screenshot({ path: path.join(OUT, 'ui-gallery-dark-amber.png'), fullPage: true })
|
||||||
|
await p.evaluate(() => { history.pushState({}, '', '/login'); dispatchEvent(new PopStateEvent('popstate')) })
|
||||||
|
await sleep(500)
|
||||||
|
r.check('theme: leaving the gallery restores <html>', await p.evaluate(() => !document.documentElement.hasAttribute('data-theme') && !document.documentElement.hasAttribute('data-venue-theme')))
|
||||||
|
|
||||||
|
r.check('no page or console errors', errs.length === 0, errs.slice(0, 3).join(' | '))
|
||||||
|
} finally {
|
||||||
|
await browser.close()
|
||||||
|
killTree(vite)
|
||||||
|
}
|
||||||
|
process.exit(r.done() ? 1 : 0)
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
"@capacitor/core": "8.5.2",
|
"@capacitor/core": "8.5.2",
|
||||||
"@capgo/capacitor-updater": "8.51.25",
|
"@capgo/capacitor-updater": "8.51.25",
|
||||||
"@tanstack/react-query": "^5.100.11",
|
"@tanstack/react-query": "^5.100.11",
|
||||||
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.15.1",
|
"axios": "^1.15.1",
|
||||||
"dexie": "^4.4.2",
|
"dexie": "^4.4.2",
|
||||||
"qr-scanner": "^1.4.2",
|
"qr-scanner": "^1.4.2",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { StrictMode } from 'react'
|
import { StrictMode } from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
|
import '@xenia/ui/tokens.css' // shared --x-* tokens; the waiter's own --bg/--text… stay as they are
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import App from './App.jsx'
|
import App from './App.jsx'
|
||||||
import db from './db/posdb.js'
|
import db from './db/posdb.js'
|
||||||
|
|||||||
Reference in New Issue
Block a user