feat(ui): IconButton tones, Switch info slot, wide right sheet, PrintArea / PrintSheet

- IconButton tone=danger|warning|info|success|special|accent: a pastel button (soft background,
  ink icon) for row actions that stand apart.
- Switch info: an element (InfoTip) right after the label instead of after the switch.
- Sheet size=wide: a 600 px drawer.
- PrintArea: content rendered into <body>, hidden on screen, the only thing printed while mounted;
  PrintSheet: cards to cut out (dashed cut lines, never split across pages).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 14:48:50 +02:00
co-authored by Claude Opus 5.5
parent 618fef53ef
commit b77bb8bb40
6 changed files with 78 additions and 7 deletions
+32
View File
@@ -52,6 +52,15 @@
.x-btn--danger:hover:not(:disabled) { background: rgb(var(--x-danger-rgb) / 0.88); } .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 { padding: 0; width: var(--x-control-md); }
/* a pastel tone on a button (IconButton tone=…): soft background, ink icon */
.x-btn--tone { background: rgb(var(--x-tone-soft)); color: rgb(var(--x-tone-ink)); }
.x-btn--tone:hover:not(:disabled) { background: rgb(var(--x-tone) / 0.24); color: rgb(var(--x-tone-ink)); }
.x-btn--tone-danger { --x-tone: var(--x-danger-rgb); --x-tone-soft: var(--x-danger-soft-rgb); --x-tone-ink: var(--x-danger-ink-rgb); }
.x-btn--tone-warning { --x-tone: var(--x-warning-rgb); --x-tone-soft: var(--x-warning-soft-rgb); --x-tone-ink: var(--x-warning-ink-rgb); }
.x-btn--tone-info { --x-tone: var(--x-info-rgb); --x-tone-soft: var(--x-info-soft-rgb); --x-tone-ink: var(--x-info-ink-rgb); }
.x-btn--tone-success { --x-tone: var(--x-success-rgb); --x-tone-soft: var(--x-success-soft-rgb); --x-tone-ink: var(--x-success-ink-rgb); }
.x-btn--tone-special { --x-tone: var(--x-special-rgb); --x-tone-soft: var(--x-special-soft-rgb); --x-tone-ink: var(--x-special-ink-rgb); }
.x-btn--tone-accent { --x-tone: var(--x-accent-rgb); --x-tone-soft: var(--x-accent-soft-rgb); --x-tone-ink: var(--x-accent-ink-rgb); }
.x-btn--icon.x-btn--sm { width: var(--x-control-sm); } .x-btn--icon.x-btn--sm { width: var(--x-control-sm); }
.x-btn--icon.x-btn--lg { width: var(--x-control-lg); } .x-btn--icon.x-btn--lg { width: var(--x-control-lg); }
@@ -91,6 +100,9 @@
} }
.x-sheet--right { .x-sheet--right {
width: min(480px, 100vw); height: 100%; width: min(480px, 100vw); height: 100%;
}
.x-sheet--right.x-sheet--wide { width: min(600px, 100vw); }
.x-sheet--right {
border-radius: var(--x-radius-dialog) 0 0 var(--x-radius-dialog); border-radius: var(--x-radius-dialog) 0 0 var(--x-radius-dialog);
animation: x-slide-left var(--x-duration-base) var(--x-ease); animation: x-slide-left var(--x-duration-base) var(--x-ease);
} }
@@ -313,6 +325,8 @@
.x-switch-row { display: flex; align-items: center; gap: var(--x-space-4); } .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__text { flex: 1; min-width: 0; }
.x-switch-row__head { display: flex; align-items: center; gap: var(--x-space-1-5); }
.x-switch-row__head .x-switch-row__label { display: inline; }
.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__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__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; } .x-switch-row--disabled .x-switch-row__label { cursor: not-allowed; opacity: 0.6; }
@@ -498,3 +512,21 @@
.x-tabs__badge { min-width: 18px; padding: 0 var(--x-space-1-5); box-sizing: border-box; border-radius: var(--x-radius-full); background: var(--x-surface-2); color: var(--x-ink-2); font-size: var(--x-text-caption); font-weight: var(--x-weight-bold); text-align: center; font-variant-numeric: tabular-nums; } .x-tabs__badge { min-width: 18px; padding: 0 var(--x-space-1-5); box-sizing: border-box; border-radius: var(--x-radius-full); background: var(--x-surface-2); color: var(--x-ink-2); font-size: var(--x-text-caption); font-weight: var(--x-weight-bold); text-align: center; font-variant-numeric: tabular-nums; }
.x-tabs__badge--warn { background: var(--x-danger-soft); color: var(--x-danger-ink); } .x-tabs__badge--warn { background: var(--x-danger-soft); color: var(--x-danger-ink); }
.x-tabs__end { flex-shrink: 0; display: flex; align-items: center; gap: var(--x-space-2); } .x-tabs__end { flex-shrink: 0; display: flex; align-items: center; gap: var(--x-space-2); }
/* ── Print (PrintArea / PrintSheet, 2026-11-20) ─────────────────────────────
* A mounted .x-print-area is the only thing printed; on screen it is hidden. */
.x-print-area { display: none; }
@media print {
@page { margin: 10mm; }
body:has(> .x-print-area) > :not(.x-print-area) { display: none !important; }
.x-print-area { display: block; color: #000; background: #fff; }
}
.x-print-sheet {
display: grid; grid-template-columns: repeat(var(--x-print-columns, 3), 1fr);
border-top: 1px dashed #888; border-left: 1px dashed #888;
}
.x-print-sheet > * {
break-inside: avoid; page-break-inside: avoid;
border-right: 1px dashed #888; border-bottom: 1px dashed #888;
padding: 6mm 4mm; display: grid; justify-items: center; align-content: start; gap: 2mm; text-align: center;
}
+8 -3
View File
@@ -27,9 +27,14 @@ export function Button({
) )
} }
/** A square button with only an icon. `label` is required: it becomes aria-label and the tooltip. */ /**
* A square button with only an icon. `label` is required: it becomes aria-label and the tooltip.
* tone: 'danger' | 'warning' | 'info' | 'success' | 'special' | 'accent' — a pastel button in that
* colour (soft background, ink icon), for row actions that should stand apart (delete red, block
* orange, zones blue: DESIGN.md §3).
*/
export function IconButton({ export function IconButton({
label, variant = 'ghost', size = 'md', type = 'button', className, children, ref, ...rest label, variant = 'ghost', size = 'md', tone, type = 'button', className, children, ref, ...rest
}) { }) {
return ( return (
<button <button
@@ -37,7 +42,7 @@ export function IconButton({
type={type} type={type}
aria-label={label} aria-label={label}
title={label} title={label}
className={cx('x-btn', 'x-btn--icon', `x-btn--${variant}`, `x-btn--${size}`, className)} className={cx('x-btn', 'x-btn--icon', `x-btn--${variant}`, `x-btn--${size}`, tone && `x-btn--tone x-btn--tone-${tone}`, className)}
{...rest} {...rest}
> >
{children} {children}
+27
View File
@@ -0,0 +1,27 @@
import { Portal } from '../internal/Portal.jsx'
import { cx } from '../internal/cx.js'
/**
* What goes on paper (2026-11-20). Rendered straight into <body>, hidden on screen; while it is
* mounted, printing (window.print()) prints only it — not the page, the menu or the dialogs.
*
* <PrintArea><PrintSheet>{cards}</PrintSheet></PrintArea>
* <Button onClick={() => window.print()}>Print</Button>
*
* Mount one at a time (the page's own print content).
*/
export function PrintArea({ className, children, ...rest }) {
return (
<Portal>
<div className={cx('x-print-area', className)} {...rest}>{children}</div>
</Portal>
)
}
/**
* Cards to cut out: a grid of equal cells with dashed cut lines between them, never split across
* pages. columns: cells per row on an A4 page (default 3).
*/
export function PrintSheet({ columns = 3, className, children, ...rest }) {
return <div className={cx('x-print-sheet', className)} style={{ '--x-print-columns': columns }} {...rest}>{children}</div>
}
+2 -2
View File
@@ -6,12 +6,12 @@ import { ModalFrame } from '../internal/ModalFrame.jsx'
* right (desktop: detail and edit panels). Same props and behaviour as Dialog. * right (desktop: detail and edit panels). Same props and behaviour as Dialog.
* side: 'bottom' | 'right' * side: 'bottom' | 'right'
*/ */
export function Sheet({ side = 'bottom', className, ...props }) { export function Sheet({ side = 'bottom', size, className, ...props }) {
return ( return (
<ModalFrame <ModalFrame
{...props} {...props}
overlayClass={`x-overlay--${side}`} overlayClass={`x-overlay--${side}`}
panelClass={cx('x-sheet', `x-sheet--${side}`, className)} panelClass={cx('x-sheet', `x-sheet--${side}`, size === 'wide' && 'x-sheet--wide', className)}
bodyClass="x-sheet__body" bodyClass="x-sheet__body"
grip={side === 'bottom'} grip={side === 'bottom'}
/> />
+8 -2
View File
@@ -6,8 +6,9 @@ import { cx } from '../internal/cx.js'
* <Switch checked={on} onChange={setOn} label="Print kitchen tickets" description="..." /> * <Switch checked={on} onChange={setOn} label="Print kitchen tickets" description="..." />
* onChange receives the new boolean. Without `label`, pass aria-label. * onChange receives the new boolean. Without `label`, pass aria-label.
* The whole row (label + description) is clickable. * The whole row (label + description) is clickable.
* info: an element right after the label (an <InfoTip>), not after the switch.
*/ */
export function Switch({ checked, onChange, label, description, disabled = false, id, className, ...rest }) { export function Switch({ checked, onChange, label, description, info, disabled = false, id, className, ...rest }) {
const auto = useId() const auto = useId()
const switchId = id || auto const switchId = id || auto
const descId = `${switchId}-desc` const descId = `${switchId}-desc`
@@ -32,7 +33,12 @@ export function Switch({ checked, onChange, label, description, disabled = false
return ( return (
<div className={cx('x-switch-row', disabled && 'x-switch-row--disabled', className)}> <div className={cx('x-switch-row', disabled && 'x-switch-row--disabled', className)}>
<div className="x-switch-row__text"> <div className="x-switch-row__text">
{label && <label className="x-switch-row__label" htmlFor={switchId}>{label}</label>} {label && (
<span className="x-switch-row__head">
<label className="x-switch-row__label" htmlFor={switchId}>{label}</label>
{info}
</span>
)}
{description && <div id={descId} className="x-switch-row__description">{description}</div>} {description && <div id={descId} className="x-switch-row__description">{description}</div>}
</div> </div>
{control} {control}
+1
View File
@@ -12,6 +12,7 @@
export { Button, IconButton } from './components/Button.jsx' export { Button, IconButton } from './components/Button.jsx'
export { Dialog } from './components/Dialog.jsx' export { Dialog } from './components/Dialog.jsx'
export { Sheet } from './components/Sheet.jsx' export { Sheet } from './components/Sheet.jsx'
export { PrintArea, PrintSheet } from './components/PrintArea.jsx'
export { ToastProvider } from './components/Toast.jsx' export { ToastProvider } from './components/Toast.jsx'
export { useToast } from './components/toastContext.js' export { useToast } from './components/toastContext.js'
export { PinPad } from './components/PinPad.jsx' export { PinPad } from './components/PinPad.jsx'