feat(ui): Pane and Page fit/header, inset/fill Tabs, quiet tones, dialog toolbar
- Page `fit` + `Pane`: panes scroll on their own, the page doesn't (from 768 px); Page `header`: the title and description above the tabs; the scrollbar's room is always kept, so short and long tabs are the same width. - Tabs `inset` (a card's header: room around the end button) and `fill`. - IconButton tone: grey at rest, the colour on hover; Button tone (ghost text that turns red on hover). - Dialog / Sheet `toolbar`: stays under the title while the body scrolls. - A Switch without a label lines up with the buttons beside it. - DESIGN.md updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,9 +52,13 @@
|
||||
.x-btn--danger:hover:not(:disabled) { background: rgb(var(--x-danger-rgb) / 0.88); }
|
||||
|
||||
.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)); }
|
||||
/* a tone on a button (2026-11-21): quiet at rest, its colour only under the pointer.
|
||||
* IconButton tone=…: a grey square, the icon in the tone's ink on hover / focus.
|
||||
* Button tone=… (ghost): plain text, the tone's ink on hover (e.g. "Remove" turns red). */
|
||||
.x-btn--tone { color: var(--x-ink-2); }
|
||||
.x-btn--tone:hover:not(:disabled), .x-btn--tone:focus-visible { color: rgb(var(--x-tone-ink)); }
|
||||
.x-btn--icon.x-btn--tone { background: var(--x-surface-2); }
|
||||
.x-btn--icon.x-btn--tone:hover:not(:disabled) { background: var(--x-surface-3); }
|
||||
.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); }
|
||||
@@ -121,6 +125,7 @@
|
||||
.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__toolbar { flex-shrink: 0; padding: var(--x-space-2) var(--x-space-6) var(--x-space-3); border-bottom: var(--x-border-width) solid var(--x-line); }
|
||||
.x-modal__body {
|
||||
flex: 1; min-height: 0; overflow-y: auto;
|
||||
padding: var(--x-space-2) var(--x-space-6) var(--x-space-6);
|
||||
@@ -325,6 +330,8 @@
|
||||
.x-switch:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||
.x-switch:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||
|
||||
/* a switch on its own (no label) lines up with the buttons beside it, not with a text baseline */
|
||||
.x-switch-bare { display: inline-flex; align-items: center; vertical-align: middle; }
|
||||
.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__head { display: flex; align-items: center; gap: var(--x-space-1-5); }
|
||||
@@ -355,9 +362,12 @@
|
||||
/* ── Page, PageHeader, Toolbar (the page rule, 2026-11-20) ─────────────────
|
||||
* A page scrolls on its own and is as wide as a 16:9 screen allows, centred beyond. */
|
||||
.x-page { display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0; }
|
||||
.x-page__top { flex-shrink: 0; border-bottom: var(--x-border-width) solid var(--x-line); background: var(--x-surface); }
|
||||
.x-page__top { flex-shrink: 0; border-bottom: var(--x-border-width) solid var(--x-line); background: var(--x-surface); overflow: hidden; scrollbar-gutter: stable; }
|
||||
.x-page__top--header .x-page__top-inner { padding-top: var(--x-page-pad); display: grid; gap: var(--x-space-3); }
|
||||
.x-page__top-inner { box-sizing: border-box; width: 100%; max-width: var(--x-page-max); margin-inline: auto; padding: 0 var(--x-page-pad); }
|
||||
.x-page__scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
|
||||
/* the scrollbar's room is always kept (2026-11-21): a short tab is as wide as a long one, and the
|
||||
* strip above stays aligned with the body */
|
||||
.x-page__scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; }
|
||||
.x-page__body {
|
||||
box-sizing: border-box; width: 100%; max-width: var(--x-page-max); margin-inline: auto;
|
||||
padding: var(--x-page-pad);
|
||||
@@ -365,6 +375,7 @@
|
||||
}
|
||||
.x-page__body--form { max-width: var(--x-page-form-max); }
|
||||
.x-page__top-inner.x-page__body--form { padding-top: 0; padding-bottom: 0; }
|
||||
.x-page__top--header .x-page__top-inner.x-page__body--form { padding-top: var(--x-page-pad); }
|
||||
.x-page__body--flush { padding: 0; }
|
||||
@media (max-width: 768px) {
|
||||
.x-page__body, .x-page__top-inner { padding-inline: var(--x-space-4); }
|
||||
@@ -372,6 +383,20 @@
|
||||
.x-page__body--flush { padding: 0; }
|
||||
}
|
||||
|
||||
/* Page fit + Pane (2026-11-21): panes scroll on their own, the page doesn't (from 768 px) */
|
||||
.x-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
|
||||
border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-card); background: var(--x-surface); box-shadow: var(--x-shadow-raised); }
|
||||
.x-pane__header, .x-pane__footer { flex-shrink: 0; }
|
||||
.x-pane__header { border-bottom: var(--x-border-width) solid var(--x-line); }
|
||||
.x-pane__footer { border-top: var(--x-border-width) solid var(--x-line); }
|
||||
.x-pane__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
|
||||
.x-pane__body--sunken { background: var(--x-surface-2); }
|
||||
@media (min-width: 768px) {
|
||||
.x-page--fit .x-page__scroll { overflow: hidden; }
|
||||
.x-page--fit .x-page__body { height: 100%; display: flex; flex-direction: column; }
|
||||
.x-page--fit .x-page__body > * { flex-shrink: 0; }
|
||||
.x-page--fit .x-page__body > .x-page__fill { flex: 1 1 0; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
|
||||
}
|
||||
.x-page-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--x-space-3); }
|
||||
.x-page-header__titles { flex: 1; min-width: 0; }
|
||||
.x-page-header__title { margin: 0; display: flex; align-items: center; gap: var(--x-space-1); font-size: var(--x-text-title); line-height: var(--x-leading-title); font-weight: var(--x-weight-semibold); color: var(--x-ink); }
|
||||
@@ -514,6 +539,10 @@
|
||||
.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__end { flex-shrink: 0; display: flex; align-items: center; gap: var(--x-space-2); }
|
||||
.x-tabs--inset { align-items: stretch; padding-inline: var(--x-pad-card); min-height: calc(var(--x-control-sm) + 2 * var(--x-pad-card)); }
|
||||
.x-tabs--inset .x-tabs__list { align-items: flex-end; }
|
||||
.x-tabs--inset .x-tabs__end { padding-block: var(--x-pad-card); }
|
||||
.x-tabs--fill .x-tabs__tab { flex: 1 1 0; justify-content: center; }
|
||||
|
||||
/* ── Print (PrintArea / PrintSheet, 2026-11-20) ─────────────────────────────
|
||||
* A mounted .x-print-area is the only thing printed; on screen it is hidden. */
|
||||
|
||||
@@ -6,16 +6,18 @@ import { Spinner } from './Spinner.jsx'
|
||||
* 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
|
||||
* tone: 'danger' | 'warning' | … with variant 'ghost': the text takes that colour under the pointer
|
||||
* (a quiet "Remove" that turns red on hover)
|
||||
*/
|
||||
export function Button({
|
||||
variant = 'primary', size = 'md', loading = false, block = false,
|
||||
variant = 'primary', size = 'md', loading = false, block = false, tone,
|
||||
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)}
|
||||
className={cx('x-btn', `x-btn--${variant}`, `x-btn--${size}`, block && 'x-btn--block', tone && `x-btn--tone x-btn--tone-${tone}`, className)}
|
||||
disabled={disabled || loading}
|
||||
aria-busy={loading || undefined}
|
||||
{...rest}
|
||||
@@ -29,9 +31,9 @@ export function Button({
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* tone: 'danger' | 'warning' | 'info' | 'success' | 'special' | 'accent' — a grey square whose icon
|
||||
* takes that colour under the pointer, for row actions that should stand apart (delete red, block
|
||||
* orange, zones blue: DESIGN.md §3). Quiet at rest (2026-11-21).
|
||||
*/
|
||||
export function IconButton({
|
||||
label, variant = 'ghost', size = 'md', tone, type = 'button', className, children, ref, ...rest
|
||||
|
||||
@@ -63,10 +63,13 @@ export function Segmented({ options = [], value, onChange, size = 'md', classNam
|
||||
* never up and down. tabs: [{ id, label, badge?, warn?, testId? }].
|
||||
* <Tabs tabs={tabs} value={tab} onChange={setTab} />
|
||||
* end: an element at the right end of the strip (a refresh button…).
|
||||
* inset: the strip is the header of a card / panel: the card's padding at the sides, and the same
|
||||
* room above and below `end` (a button never touches the card's edge or the line).
|
||||
* fill: the tabs share the width equally, each label centred (a narrow column's tabs).
|
||||
*/
|
||||
export function Tabs({ tabs = [], value, onChange, size = 'md', end, className, ...rest }) {
|
||||
export function Tabs({ tabs = [], value, onChange, size = 'md', end, inset = false, fill = false, className, ...rest }) {
|
||||
return (
|
||||
<div className={cx('x-tabs', `x-tabs--${size}`, className)} {...rest}>
|
||||
<div className={cx('x-tabs', `x-tabs--${size}`, inset && 'x-tabs--inset', fill && 'x-tabs--fill', className)} {...rest}>
|
||||
<div className="x-tabs__list" role="tablist">
|
||||
{tabs.map(tb => (
|
||||
<button key={tb.id} type="button" role="tab" aria-selected={tb.id === value} data-testid={tb.testId}
|
||||
|
||||
@@ -12,13 +12,22 @@ import { cx } from '../internal/cx.js'
|
||||
* </Page>
|
||||
*
|
||||
* top: an element kept above the scrolling part (a tab strip), as wide as the content.
|
||||
* header: a <PageHeader> shown above `top` (2026-11-21): the page's title and description come
|
||||
* first, then its tabs; each tab then has its own head (title, description, its "New" button).
|
||||
* width: 'full' (default: lists, tables, dashboards) | 'form' (settings and forms, --x-page-form-max).
|
||||
* flush: no padding (a page that draws edge to edge, e.g. a map).
|
||||
* fit: the page is exactly the screen's height and does not scroll itself: its <Pane>s do, each on
|
||||
* its own (two-column pages: Products). Put the panes in an element with `x-page__fill`; what comes
|
||||
* before it (a header) stays. Phones: the page scrolls as usual.
|
||||
*/
|
||||
export function Page({ top, width = 'full', flush = false, className, bodyClassName, testId, children, ...rest }) {
|
||||
export function Page({ top, header, width = 'full', flush = false, fit = false, className, bodyClassName, testId, children, ...rest }) {
|
||||
return (
|
||||
<div className={cx('x-page', className)} data-testid={testId} {...rest}>
|
||||
{top && <div className="x-page__top"><div className={cx('x-page__top-inner', width === 'form' && 'x-page__body--form')}>{top}</div></div>}
|
||||
<div className={cx('x-page', fit && 'x-page--fit', className)} data-testid={testId} {...rest}>
|
||||
{(top || header) && (
|
||||
<div className={cx('x-page__top', header && 'x-page__top--header')}>
|
||||
<div className={cx('x-page__top-inner', width === 'form' && 'x-page__body--form')}>{header}{top}</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="x-page__scroll">
|
||||
<div className={cx('x-page__body', width === 'form' && 'x-page__body--form', flush && 'x-page__body--flush', bodyClassName)}>{children}</div>
|
||||
</div>
|
||||
@@ -50,3 +59,19 @@ export function Toolbar({ className, children, ...rest }) {
|
||||
export function ToolbarSpacer() {
|
||||
return <span className="x-toolbar__spacer" aria-hidden="true" />
|
||||
}
|
||||
|
||||
/**
|
||||
* A pane: a container whose header and footer stay while its body scrolls (2026-11-21).
|
||||
* One side of a <Page fit> (Products: the categories, the list), or any panel with a long list.
|
||||
* <Pane header={<h2>…</h2>} footer={…} sunken>…the list…</Pane>
|
||||
* sunken: the body a shade darker than the pane, so white cards in it stand out.
|
||||
*/
|
||||
export function Pane({ header, footer, sunken = false, as: Tag = 'section', className, bodyClassName, children, ...rest }) {
|
||||
return (
|
||||
<Tag className={cx('x-pane', className)} {...rest}>
|
||||
{header && <div className="x-pane__header">{header}</div>}
|
||||
<div className={cx('x-pane__body', sunken && 'x-pane__body--sunken', bodyClassName)}>{children}</div>
|
||||
{footer && <div className="x-pane__footer">{footer}</div>}
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function Switch({ checked, onChange, label, description, info, disabled =
|
||||
</button>
|
||||
)
|
||||
|
||||
if (!label && !description) return <span className={className}>{control}</span>
|
||||
if (!label && !description) return <span className={cx('x-switch-bare', className)}>{control}</span>
|
||||
return (
|
||||
<div className={cx('x-switch-row', disabled && 'x-switch-row--disabled', className)}>
|
||||
<div className="x-switch-row__text">
|
||||
|
||||
@@ -21,7 +21,7 @@ export { EmptyState } from './components/EmptyState.jsx'
|
||||
export { Spinner } from './components/Spinner.jsx'
|
||||
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
||||
export { Dropdown } from './components/Dropdown.jsx'
|
||||
export { Page, PageHeader, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||
export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||
export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx'
|
||||
export { Switch } from './components/Switch.jsx'
|
||||
export { Stepper } from './components/Stepper.jsx'
|
||||
|
||||
@@ -11,9 +11,9 @@ const CloseIcon = () => (
|
||||
</svg>
|
||||
)
|
||||
|
||||
/** The shared body of Dialog and Sheet: backdrop, panel, header with ×, body, footer. */
|
||||
/** The shared body of Dialog and Sheet: backdrop, panel, header with ×, toolbar, body, footer. */
|
||||
export function ModalFrame({
|
||||
open, onClose, title, description, children, footer,
|
||||
open, onClose, title, description, toolbar, children, footer,
|
||||
dismissible = true, closeLabel, initialFocus,
|
||||
overlayClass, panelClass, grip = false, bodyClass,
|
||||
}) {
|
||||
@@ -54,6 +54,8 @@ export function ModalFrame({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{/* toolbar: stays under the header while the body scrolls (a search box…) */}
|
||||
{toolbar && <div className="x-modal__toolbar">{toolbar}</div>}
|
||||
{children != null && <div className={cx('x-modal__body', bodyClass)}>{children}</div>}
|
||||
{footer && <div className="x-modal__footer">{footer}</div>}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user