actual-css 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/README.md +6 -6
- package/components.json +19 -4
- package/dist/actual.full.css +451 -118
- package/dist/actual.full.js +2 -2
- package/dist/actual.full.min.css +1 -1
- package/dist/types/data-flag.d.ts +1 -0
- package/dist/types/enhancement-loader-state.d.ts +6 -0
- package/dist/types/enhancement-loader.d.ts +0 -2
- package/dist/types/parse-config.d.ts +0 -1
- package/dist/types/popover-transport.d.ts +2 -0
- package/dist/types/status.d.ts +0 -1
- package/dist/types/validation.d.ts +6 -2
- package/docs/pages/components/app-navigation.md +67 -0
- package/docs/pages/components/button.md +3 -0
- package/docs/pages/components/dialog.md +3 -0
- package/docs/pages/components/list.md +13 -0
- package/docs/pages/components/segmented.md +7 -4
- package/docs/pages/components/table.md +4 -1
- package/docs/pages/enhancements/flyout.md +12 -3
- package/docs/pages/enhancements/tooltip.md +1 -0
- package/docs/pages/examples/overview.md +29 -1
- package/docs/pages/forms/combobox.md +10 -8
- package/docs/pages/forms/labels.md +7 -0
- package/docs/pages/forms/overview.md +13 -10
- package/docs/pages/forms/validation.md +3 -3
- package/docs/pages/foundations/philosophy.md +26 -0
- package/docs/pages/foundations/theming.md +80 -7
- package/docs/pages/foundations/tokens.md +39 -2
- package/docs/pages/guides/coding-agents.md +11 -0
- package/docs/pages/guides/introduction.md +1 -1
- package/docs/pages/guides/progressive-enhancement.md +88 -20
- package/docs/pages/guides/tailwind.md +12 -6
- package/docs/pages/guides/upgrading.md +52 -0
- package/docs/pages/layout/app-layout.md +50 -1
- package/docs/pages/patterns/empty-state.md +48 -10
- package/forms.json +325 -0
- package/llms.txt +2 -1
- package/package.json +3 -1
- package/reserved-classes.json +1 -0
- package/skills/actual-css/SKILL.md +1 -1
- package/skills/actual-css/references/api-and-vocabulary.md +2 -1
- package/src/cli/actual-css.js +8 -2
- package/src/css/components/app-nav.css +75 -18
- package/src/css/components/badge.css +7 -1
- package/src/css/components/button.css +20 -3
- package/src/css/components/flyout.css +5 -2
- package/src/css/components/list.css +28 -13
- package/src/css/components/menu.css +18 -0
- package/src/css/components/meter.css +4 -0
- package/src/css/components/progress.css +9 -2
- package/src/css/components/segmented.css +22 -12
- package/src/css/components/table.css +21 -2
- package/src/css/core/theme.css +11 -1
- package/src/css/core/tokens.css +16 -2
- package/src/css/forms/choice-card.css +4 -3
- package/src/css/forms/choice.css +28 -16
- package/src/css/forms/control.css +23 -16
- package/src/css/forms/custom-select.css +3 -1
- package/src/css/forms/form.css +8 -5
- package/src/css/forms/otp.css +2 -1
- package/src/css/forms/range.css +20 -6
- package/src/css/forms/select.css +12 -4
- package/src/css/forms/switch.css +11 -5
- package/src/css/layout/app-layout.css +104 -5
- package/src/js/data-flag.js +4 -0
- package/src/js/dialog.js +5 -8
- package/src/js/enhancement-loader-state.js +7 -0
- package/src/js/enhancement-loader.js +4 -21
- package/src/js/keys.js +5 -7
- package/src/js/parse-config.js +0 -2
- package/src/js/popover-transport.js +18 -0
- package/src/js/status.js +0 -2
- package/src/js/surface.js +35 -41
- package/src/js/tooltip.js +8 -36
- package/src/js/validation.js +24 -10
- package/src/tooling/css-bundle.js +5 -0
- package/src/tooling/design-tokens.js +8 -1
- package/src/tooling/theme-contrast.js +45 -17
- package/tokens.json +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readDataFlag(element: any, name: any, defaultValue?: boolean): boolean;
|
package/dist/types/status.d.ts
CHANGED
|
@@ -6,7 +6,12 @@ export declare class FormValidator {
|
|
|
6
6
|
alnum(v: any): boolean;
|
|
7
7
|
"starts-with"(v: any, _el: any, ...prefixes: any[]): boolean;
|
|
8
8
|
"ends-with"(v: any, _el: any, ...suffixes: any[]): boolean;
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} v
|
|
11
|
+
* @param {Element | null} [_el]
|
|
12
|
+
* @param {string} [format]
|
|
13
|
+
*/
|
|
14
|
+
date(v: string, _el?: Element | null, format?: string): boolean;
|
|
10
15
|
"tel-prefix"(value: any, _el: any, ...prefixes: any[]): boolean;
|
|
11
16
|
};
|
|
12
17
|
static registerRule(name: any, callback: any): void;
|
|
@@ -14,4 +19,3 @@ export declare class FormValidator {
|
|
|
14
19
|
static clearFieldError(el: any): void;
|
|
15
20
|
static setErrors(form: any, errors: any): void;
|
|
16
21
|
}
|
|
17
|
-
export default FormValidator;
|
|
@@ -36,7 +36,74 @@ permits. The component contains no JavaScript and does not manage routing.
|
|
|
36
36
|
The icon slot accepts SVGs, images, and decorative elements such as icon-font
|
|
37
37
|
`i` elements marked with `aria-hidden="true"`.
|
|
38
38
|
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
- A tile is a direct-child `a` or `button`. Use a button for an action that is
|
|
42
|
+
not a destination, such as a "More" button that opens a
|
|
43
|
+
[drawer](drawer.md) holding the secondary destinations.
|
|
44
|
+
- `aria-current="page"` goes on a link only. When the current page lives in
|
|
45
|
+
the "More" drawer, mark the link in the drawer, not the button: the button
|
|
46
|
+
opens a group of destinations and keeps `aria-expanded`.
|
|
47
|
+
- A disabled destination is a `button` with `disabled`.
|
|
48
|
+
|
|
49
|
+
## Header and footer
|
|
50
|
+
|
|
51
|
+
Inside `.app-layout`, side navigation can carry a brand and a primary action
|
|
52
|
+
above the destinations and an account block below them. Put them in one
|
|
53
|
+
direct-child `header` and one direct-child `footer`. The header's first child,
|
|
54
|
+
usually the brand, shares the topbar's band; anything after it stacks below.
|
|
55
|
+
The footer sits at the block end and follows the last link when the
|
|
56
|
+
destinations outgrow the viewport. An account menu there is a
|
|
57
|
+
[flyout](../enhancements/flyout.md) opening upward
|
|
58
|
+
(`data-flyout-placement="top-start"`); the
|
|
59
|
+
[Tasks template](../../demo/templates/tasks.html) has one.
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<nav class="app-nav" aria-label="Primary">
|
|
63
|
+
<header>
|
|
64
|
+
<a class="navbar-brand" href="/">Fieldwork</a>
|
|
65
|
+
<a class="btn primary" href="/new">New task</a>
|
|
66
|
+
</header>
|
|
67
|
+
<a href="/today" aria-current="page">…</a>
|
|
68
|
+
<a href="/tasks">…</a>
|
|
69
|
+
<footer>
|
|
70
|
+
<button class="btn ghost" type="button">Account</button>
|
|
71
|
+
</footer>
|
|
72
|
+
</nav>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Both are optional. Without a `header`, the brand belongs in the topbar, which
|
|
76
|
+
then spans the navigation; see
|
|
77
|
+
[App layout](../layout/app-layout.md#where-the-brand-lives).
|
|
78
|
+
|
|
79
|
+
At most one of each per `.app-nav`. The bottom bar hides both: it has room for
|
|
80
|
+
destinations only, so give their content a second home on a phone — identity in
|
|
81
|
+
the topbar, the primary action in a [FAB](fab.md), the account behind a button
|
|
82
|
+
tile that opens a bottom-sheet [drawer](drawer.md) with the same items. The
|
|
83
|
+
[Tasks template](../../demo/templates/tasks.html) shows that account tile; it
|
|
84
|
+
hides the tile from the side breakpoint, where the footer takes over. Use an
|
|
85
|
+
SVG or icon-font glyph in the tile: the icon slot sizes its font to
|
|
86
|
+
`--app-nav-icon-size`, which an avatar's initials do not survive.
|
|
87
|
+
|
|
88
|
+
## Rail
|
|
89
|
+
|
|
90
|
+
Set `data-nav="rail"` on `.app-layout` to show the side navigation as a narrow
|
|
91
|
+
rail. Each tile keeps its label as a small caption under the icon, as in the
|
|
92
|
+
bottom bar, so the rail needs no tooltip. Two-word labels wrap onto a second
|
|
93
|
+
line; keep labels to one or two short words. The bottom bar ignores the
|
|
94
|
+
attribute.
|
|
95
|
+
|
|
96
|
+
The application owns the preference: the toggle, its label, and persisting the
|
|
97
|
+
choice. What the header and footer show on the rail, such as a compact brand
|
|
98
|
+
mark, is application CSS keyed to the same attribute. See
|
|
99
|
+
[App layout](../layout/app-layout.md#rail).
|
|
100
|
+
|
|
39
101
|
## Hooks
|
|
40
102
|
|
|
41
103
|
- `--app-nav-size` controls the minimum bottom-bar size.
|
|
42
104
|
- `--app-nav-gap` controls spacing between destinations.
|
|
105
|
+
- `--app-nav-current-bg` and `--app-nav-current-fg` repaint the current state,
|
|
106
|
+
for example a soft tint instead of the selected fill. The bottom bar and the
|
|
107
|
+
rail paint a pill around the icon and keep the label in the bar's ink;
|
|
108
|
+
labelled side navigation fills the whole row. The fill is the only current
|
|
109
|
+
cue, so keep it distinct from the navigation surface.
|
|
@@ -369,3 +369,6 @@ on its components. Tap both rows on a phone to compare:
|
|
|
369
369
|
Change it in `:hover`/`:active` rules for a lift and press.
|
|
370
370
|
Supply shadow-list items; use `0 0 #0000` for no elevation. `none` cannot
|
|
371
371
|
compose with the inset hover overlay and invalidates the whole shadow list.
|
|
372
|
+
- Solid buttons paint the [`--finish`](../foundations/tokens.md#finish) token
|
|
373
|
+
over their fill, and the hover darkens both. `.outline`, `.ghost`, `.link`,
|
|
374
|
+
`.soft` and `.surface` stay flat.
|
|
@@ -534,6 +534,9 @@ Available options:
|
|
|
534
534
|
`closedby="none"`. Use `closedby="none"` for critical dialogs that must be
|
|
535
535
|
closed by an explicit action.
|
|
536
536
|
|
|
537
|
+
Set a `data-dialog-*` toggle to `false` to disable it, in any letter case.
|
|
538
|
+
An empty attribute enables the option.
|
|
539
|
+
|
|
537
540
|
### Open on load
|
|
538
541
|
|
|
539
542
|
Add `data-dialog-open` to show a dialog without a trigger, for example a
|
|
@@ -183,12 +183,25 @@ non-zero `--list-item-pad-inline`: without that gutter, the current indicator
|
|
|
183
183
|
touches the leading region and the trailing touches the row edge. `.grouped`
|
|
184
184
|
sets that gutter already.
|
|
185
185
|
|
|
186
|
+
### Completion beside a navigable row
|
|
187
|
+
|
|
188
|
+
A task row both opens its record and completes it: two controls that must not
|
|
189
|
+
nest. Keep the link as the row and overlay a `label` holding the checkbox on
|
|
190
|
+
the link's leading gutter, positioned against the `li`. The link keeps the
|
|
191
|
+
whole row's hover, current, focus and forced-colors states, so the selection
|
|
192
|
+
and the completion stay independent. The
|
|
193
|
+
[Tasks template](../../demo/templates/tasks.html) has the recipe (checkbox,
|
|
194
|
+
done task, todo item, check off).
|
|
195
|
+
|
|
186
196
|
## Hooks
|
|
187
197
|
|
|
188
198
|
- `--list-item-min-size` controls the row's minimum touch height.
|
|
189
199
|
- `--list-item-pad-block` and `--list-item-pad-inline` control row padding.
|
|
190
200
|
`.grouped` raises the inline padding to a standalone surface's gutter; set
|
|
191
201
|
the hook on the list to choose another.
|
|
202
|
+
- `--list-current-inset-block` controls the inset at both ends of the current
|
|
203
|
+
row's indicator. It follows `--list-item-pad-block` by default. Set it to
|
|
204
|
+
`0` for a full-height indicator that follows the corners of a grouped row.
|
|
192
205
|
- `--list-item-gap` controls spacing between the regions a row actually has.
|
|
193
206
|
- `--list-divider` controls the inter-row dividers, and the leading divider on
|
|
194
207
|
a bare list. `.grouped` replaces that leading divider with its shell border.
|
|
@@ -110,12 +110,15 @@ which both stacks it and gives the tabs runtime Up and Down.
|
|
|
110
110
|
- `--segmented-pad` — inset between the track and its segments, also the gap
|
|
111
111
|
between segments; the segment radius is the track radius minus it.
|
|
112
112
|
- `--segmented-radius` — track corner radius.
|
|
113
|
-
- `--segmented-fg` — label ink of the unselected segments
|
|
114
|
-
takes `--text`.
|
|
113
|
+
- `--segmented-fg` — label ink of the unselected segments.
|
|
115
114
|
- `--segmented-selected-bg` — fill of the selected segment: `--surface-raised`
|
|
116
115
|
in a light scheme, lifted above the track in a dark one. Its shadow follows
|
|
117
|
-
`--shadow
|
|
118
|
-
`--shadow: none`, which would also drop
|
|
116
|
+
`--shadow-control`, or `--shadow` when that is unset; a flat theme sets
|
|
117
|
+
`--shadow-color: transparent`, not a shadow to `none`, which would also drop
|
|
118
|
+
the edge below. The track takes `--shadow-inset`.
|
|
119
|
+
- `--segmented-selected-fg` — label and inset focus ring color for a custom
|
|
120
|
+
selected fill. Set it on the track or inherit it from a theme. Pair it with
|
|
121
|
+
the fill: 4.5:1 for the label, which also gives the ring its 3:1.
|
|
119
122
|
- `--segmented-selected-border` — hairline around the selected segment, none
|
|
120
123
|
by default. Set it once on a theme root, for example a flat light theme,
|
|
121
124
|
where fill and ink alone barely set the selected segment apart from the
|
|
@@ -214,7 +214,10 @@ on one record at a time, use a [list with row actions](list.md).
|
|
|
214
214
|
|
|
215
215
|
## CSS hooks
|
|
216
216
|
|
|
217
|
-
- `--table-cell-pad` — cell padding; `.compact` re-declares
|
|
217
|
+
- `--table-cell-pad` — cell padding, a single length; `.compact` re-declares
|
|
218
|
+
it tighter.
|
|
219
|
+
- `--table-radius` — the corner radius of `.table-wrap`. The first and last
|
|
220
|
+
columns and the caption pad at least this much, so text clears the curve.
|
|
218
221
|
- `--table-min` — minimum table width before `.table-wrap` scrolls horizontally.
|
|
219
222
|
- `--table-header-bg`, `--table-header-fg` — header band fill and ink. Set
|
|
220
223
|
them on a theme root rather than on `.table`: a data grid bridge reads the
|
|
@@ -192,6 +192,10 @@ script, closes it and stays where it landed; Escape is the key that returns
|
|
|
192
192
|
focus to the trigger. `false` keeps the flyout open there too, so a persistent
|
|
193
193
|
panel must not cover the controls around it.
|
|
194
194
|
|
|
195
|
+
A click on a text field, a select or a textarea, or on its label, never closes
|
|
196
|
+
the flyout either: it starts an edit, so an action menu can hold a field, such
|
|
197
|
+
as a theme select in an account menu. A checkbox or radio click is a pick.
|
|
198
|
+
|
|
195
199
|
Arrow keys and Space in a radio group never close the flyout: they move
|
|
196
200
|
through the options, and a pointer pick closes it. Opening from the keyboard
|
|
197
201
|
focuses a group at its checked radio. The [palette picker](../forms/color-swatches.md#palette-in-a-flyout)
|
|
@@ -218,7 +222,8 @@ relies on both.
|
|
|
218
222
|
| `.menu` | Component | Action-list primitive. |
|
|
219
223
|
| `.menu-item` | Component | One action row; joins roving focus. |
|
|
220
224
|
| `.menu-item-icon` | Slot | Fixed leading column for an icon. |
|
|
221
|
-
| `.menu-item-text` | Slot | Flexible label column
|
|
225
|
+
| `.menu-item-text` | Slot | Flexible label column for plain or rich text. |
|
|
226
|
+
| `.menu-item-desc` | Slot | Wrapping secondary line inside the label. |
|
|
222
227
|
| `.menu-item-end` | Slot | Trailing shortcut, badge or status. |
|
|
223
228
|
| `.menu-label` | Variant | Muted, non-interactive group heading. |
|
|
224
229
|
| `.menu-separator` | Variant | Divider row between groups. |
|
|
@@ -307,13 +312,17 @@ records which patterns Biome rejects, and which of its findings were right.
|
|
|
307
312
|
Wrap rich item content in the three optional slots when a menu needs aligned
|
|
308
313
|
icons or trailing metadata. Keep decorative icons hidden from assistive
|
|
309
314
|
technology. Plain text directly inside `.menu-item` remains valid for simple
|
|
310
|
-
actions.
|
|
315
|
+
actions. Put a description inside `.menu-item-text` with `.menu-item-desc`. The
|
|
316
|
+
label and description can wrap together, with the icon aligned to the start
|
|
317
|
+
of the row.
|
|
311
318
|
|
|
312
319
|
```html
|
|
313
320
|
<li>
|
|
314
321
|
<button class="menu-item" type="button" role="menuitem">
|
|
315
322
|
<span class="menu-item-icon" aria-hidden="true">…</span>
|
|
316
|
-
<span class="menu-item-text">
|
|
323
|
+
<span class="menu-item-text">
|
|
324
|
+
Duplicate <span class="menu-item-desc">Create a copy in this workspace</span>
|
|
325
|
+
</span>
|
|
317
326
|
<span class="menu-item-end"><kbd>⌘D</kbd></span>
|
|
318
327
|
</button>
|
|
319
328
|
</li>
|
|
@@ -23,6 +23,7 @@ by promoting it to the top layer with `popover="manual"`.
|
|
|
23
23
|
- JavaScript can generate tooltip elements from `data-tooltip`.
|
|
24
24
|
- Add `data-tooltip-click` to make a supplemental description open on click.
|
|
25
25
|
- Add `data-tooltip-visible` to show it immediately and keep it visible while its trigger is in view.
|
|
26
|
+
- Set `data-tooltip-click`, `data-tooltip-visible` or `data-tooltip-no-tap` to `false` to disable the option, in any letter case.
|
|
26
27
|
- Use `data-tooltip-placement` to set the preferred placement (default `top`).
|
|
27
28
|
- The arrow inherits the tooltip background — custom gradients carry through automatically.
|
|
28
29
|
- Avoid relying on the native `title` attribute as the primary implementation.
|
|
@@ -29,13 +29,16 @@ Whole pages, composed the way a real product would.
|
|
|
29
29
|
- [Order management](../../demo/templates/order-management.html) - one state at three levels (a badge in a selectable list, a message in context, a notification with its own action) composed on the `admin-neutral` business-interface theme
|
|
30
30
|
- [App](../../demo/templates/app.html) - application shell with sidebar
|
|
31
31
|
- [Workspaces](../../demo/templates/workspaces.html) - sectioned sidebar, master/detail list with native current state, and workspace cards
|
|
32
|
+
- [Tasks](../../demo/templates/tasks.html) - inset workspace with one divided surface, a `.measure` editor, and a single-pane task flow on mobile. Edits apply immediately and reset on reload.
|
|
33
|
+
- [TodoMVC](../../demo/templates/todomvc.html) - a buildless task list with hash routing, local persistence, and presentation derived from HTML state. See the [implementation notes](#todomvc).
|
|
32
34
|
- [Marketing](../../demo/templates/marketing.html) - landing page with typography and fluid type
|
|
33
35
|
- [Blog](../../demo/templates/blog.html) - article page with prose
|
|
34
36
|
- [Changelog](../../demo/templates/changelog.html) - release notes on a `.timeline`: version and date beside the rail on wide containers, and a light on the rail that runs from the first release to the last as the page scrolls
|
|
35
37
|
- [Settings modal](../../demo/templates/settings-modal.html) - two-pane preferences dialog opening on load with `data-dialog-open`, with the local CSS it needs audited rule by rule
|
|
36
|
-
- [Modal patterns](../../demo/templates/modal-patterns.html) -
|
|
38
|
+
- [Modal patterns](../../demo/templates/modal-patterns.html) - nine application modals, including a confirmation with detached actions
|
|
37
39
|
- [Workspace settings](../../demo/templates/settings-pricing.html) - plans with visible native choices, preferences and segmented tabs
|
|
38
40
|
- [iOS-style settings](../../demo/templates/settings-ios.html) - iOS-like controls and grouped settings from unchanged framework markup, a local theme, and its findings listed rule by rule
|
|
41
|
+
- [Surface form](../../demo/templates/surface-form.html) - workshop booking with flat, outlined, inset-shadow and lower-edge fields on a blue surface, with visible keyboard focus and validation
|
|
39
42
|
- [Card compositions](../../demo/templates/card-compositions.html) - editorial, team, sign-in and horizontal cards composed from existing primitives
|
|
40
43
|
- [Neo-brutalist](../../demo/templates/neo-brutalist.html) - a risograph print studio on the `neo-brutalist` theme (order alerts, plus-marker FAQ, ruled testimonial grid, docked cookie banner) with the page loading its own fonts
|
|
41
44
|
- [Cyberdeck](../../demo/templates/cyberdeck.html) - a relay station console on the `cyberdeck` theme (bevelled frames, segmented gauges, diamond markers, printed switch states, link-card reticle) with page-level micro-print
|
|
@@ -79,6 +82,31 @@ and extension points.
|
|
|
79
82
|
- [File upload](../../demo/templates/file-upload.html) - the native file input, Dropzone rendering its file rows as Actual components, and FilePond on Actual tokens
|
|
80
83
|
- [Diagrams](../../demo/templates/diagrams.html) - Mermaid timelines, Gantt charts and flowcharts drawn by Pele through a small web component, on Actual tokens
|
|
81
84
|
|
|
85
|
+
## TodoMVC
|
|
86
|
+
|
|
87
|
+
[Open the demo](../../demo/templates/todomvc.html) ·
|
|
88
|
+
[View source](https://github.com/lekoala/actual-css/blob/master/demo/templates/todomvc.html) ·
|
|
89
|
+
[Read the functional spec](https://github.com/tastejs/todomvc/blob/master/app-spec.md)
|
|
90
|
+
|
|
91
|
+
Serve the checkout with `bun scripts/serve.js` and open
|
|
92
|
+
`/demo/templates/todomvc.html` on localhost. The page loads Actual's CSS
|
|
93
|
+
modules directly from `src/css` and runs its own inline JavaScript. Tasks start
|
|
94
|
+
empty and are saved to the browser's local storage.
|
|
95
|
+
|
|
96
|
+
- CSS reads checkbox state to style completed titles and show Clear completed.
|
|
97
|
+
It reads list contents to show the controls and queries the card's width to
|
|
98
|
+
lay out the toolbar. Actual's theme follows the system scheme.
|
|
99
|
+
- JavaScript owns the task records, hash filtering, active count, and focus.
|
|
100
|
+
Filtered rows retain their task checkboxes and use `hidden`. This lets Clear
|
|
101
|
+
completed reflect the entire list while the active filter is in use.
|
|
102
|
+
- The demo uses Actual's own markup and styles. It adds a visible-on-focus Edit
|
|
103
|
+
button alongside double-click editing, so keyboard and touch users can edit
|
|
104
|
+
tasks. Delete and Edit stay visible on touch screens.
|
|
105
|
+
|
|
106
|
+
The [browser acceptance tests](https://github.com/lekoala/actual-css/blob/master/tests/browser/todomvc.test.js)
|
|
107
|
+
exercise the behaviors from the spec. Run them with
|
|
108
|
+
`bun test tests/browser/todomvc.test.js`.
|
|
109
|
+
|
|
82
110
|
## Sites
|
|
83
111
|
|
|
84
112
|
Full sites demo living in `demo/sites`.
|
|
@@ -75,6 +75,7 @@ contrast contracts apply to the combobox for free:
|
|
|
75
75
|
--cb-border-color: var(--form-invalid-border, var(--control-default-border, var(--border-control)));
|
|
76
76
|
--cb-border-radius: var(--radius);
|
|
77
77
|
--cb-focus-color: var(--focus);
|
|
78
|
+
--cb-focus-width: var(--focus-ring-width);
|
|
78
79
|
--cb-muted-color: var(--text-muted);
|
|
79
80
|
--cb-error-color: var(--danger);
|
|
80
81
|
--cb-control-height: var(--control-size);
|
|
@@ -110,14 +111,15 @@ contrast contracts apply to the combobox for free:
|
|
|
110
111
|
The control reads the field geometry a theme gives `.input`: `--border-width`
|
|
111
112
|
and the `--control-shadow` elevation, which focus keeps. Hover follows `.input`
|
|
112
113
|
too (`--control-hover-border`), since the control is typed into, in place of
|
|
113
|
-
the library's own border mix. While the search input
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
no adaptation inside `.join`: `combo-box` owns the radius at
|
|
118
|
-
so the join gives it the group corners and the visible
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
the library's own border mix. While the search input is focused, the control
|
|
115
|
+
takes the same inset outline as `.input` in place of the library's accent
|
|
116
|
+
border; `--cb-focus-width` mirrors `--focus-ring-width`, so a focused chip or
|
|
117
|
+
remove × keeps the library's own inner ring at the field's width. Being inset,
|
|
118
|
+
the outline needs no adaptation inside `.join`: `combo-box` owns the radius at
|
|
119
|
+
zero specificity, so the join gives it the group corners and the visible
|
|
120
|
+
control inherits them. The invalid rule sets `--form-invalid-border`, the hook
|
|
121
|
+
`.field.danger` and `aria-invalid` already use, so border and outline turn
|
|
122
|
+
danger together.
|
|
121
123
|
|
|
122
124
|
### Limits
|
|
123
125
|
|
|
@@ -43,3 +43,10 @@ The mixed shape `<label for="x">…<input id="x"></label>` is allowed by the spe
|
|
|
43
43
|
|
|
44
44
|
`.field-label` works on a `<span>`, on a detached `<label for>`, or on a
|
|
45
45
|
`<legend>`. `.required-mark` goes inside a label.
|
|
46
|
+
|
|
47
|
+
### Hooks
|
|
48
|
+
|
|
49
|
+
- `--field-label-scale`: label size as a fraction of `--control-font-size`,
|
|
50
|
+
so it follows `.sm`/`.lg`. `1` sets labels at the field text size. Applies
|
|
51
|
+
to `.field-label` and the `.field-group.flush` legend; set it on `:root`, a
|
|
52
|
+
form, or a single field.
|
|
@@ -177,18 +177,21 @@ background shared by `.input`, `.textarea`, `.select` and external widget bridge
|
|
|
177
177
|
Use `--control-bg` for a local field override; state rules still own readonly,
|
|
178
178
|
disabled and validation fills.
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
edge
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
field borders).
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
Set `--control-hover-
|
|
188
|
-
|
|
180
|
+
Fields rest on the quiet `--border` edge, and on the 3:1 `--border-control`
|
|
181
|
+
edge under increased contrast. Set `--control-default-border: var(--border-control)`
|
|
182
|
+
for strong identification everywhere, and `--control-border-block-end-color` /
|
|
183
|
+
`-width` for a different lower edge; readonly and disabled fields drop that
|
|
184
|
+
lower edge. Recipes: Foundations · Theming (field borders).
|
|
185
|
+
|
|
186
|
+
`.input`, `.textarea` and `.select` share one hover: the border darkens and the
|
|
187
|
+
fill stays. Set `--control-hover-border` to tune that border, and
|
|
188
|
+
`--control-hover-bg` to add a hover fill — the cue a field needs when its hover
|
|
189
|
+
border is cleared.
|
|
189
190
|
Set `--control-shadow` to give `.input`, `.textarea` and `.select` a resting
|
|
190
191
|
elevation (unset by default). It inherits, so a theme can set it once on its
|
|
191
|
-
root; keyboard focus and an open custom select keep it.
|
|
192
|
+
root; keyboard focus and an open custom select keep it. Unset, it falls back
|
|
193
|
+
to `--shadow-inset`, the recess fields share with the switch, range, progress
|
|
194
|
+
and segmented rails ([Elevation](../foundations/tokens.md#elevation)).
|
|
192
195
|
|
|
193
196
|
## Notes
|
|
194
197
|
|
|
@@ -168,7 +168,7 @@ Custom rules live in `data-validation-rules` as a comma-separated list; each rul
|
|
|
168
168
|
- `alnum` — Value is empty or letters and digits only.
|
|
169
169
|
- `starts-with <token>…` — Value must begin with one of the literal tokens (`starts-with INV- CR-`). The value is trimmed before comparison; the match is case-sensitive.
|
|
170
170
|
- `ends-with <token>…` — Value must end with one of the literal tokens (`ends-with .pdf .csv`). Trimmed, case-sensitive.
|
|
171
|
-
- `date` —
|
|
171
|
+
- `date [format]` — Validates a calendar date. Pass the format shown to the user, for example `date dd/mm/yyyy`, to enforce the order, separator and digit count. Supported formats are `yyyy-mm-dd`, `dd/mm/yyyy`, `mm/dd/yyyy`, `dd.mm.yyyy`, `mm.dd.yyyy`, `dd-mm-yyyy` and `mm-dd-yyyy`. With no format, the rule accepts any of these shapes, including one-digit days and months in year-last dates.
|
|
172
172
|
- `tel-prefix <prefix>…` — A local number (its digits, with the usual separators `space ( ) . / -` ignored) passes; an explicit international number is normalized (`00` to `+`) and must match one of the literal prefixes (`tel-prefix +32`, `tel-prefix +32 +33 +352`). A value that is not dialing digits fails. With no prefix, only local input passes. The entered value is never modified.
|
|
173
173
|
|
|
174
174
|
`starts-with` and `ends-with` options are literal tokens: no quoting, no escaping, and a token cannot contain whitespace. Without a token they fail rather than passing silently. `tel-prefix` without a prefix is instead a deliberate local-only policy.
|
|
@@ -214,7 +214,7 @@ The `date` rule pairs naturally with `data-mask` — the mask structures input,
|
|
|
214
214
|
<span class="field-label">Date (ISO)</span>
|
|
215
215
|
<input class="input" name="date-iso"
|
|
216
216
|
data-mask="9999-99-99"
|
|
217
|
-
data-validation-rules="date"
|
|
217
|
+
data-validation-rules="date yyyy-mm-dd"
|
|
218
218
|
inputmode="numeric"
|
|
219
219
|
autocomplete="off"
|
|
220
220
|
placeholder="yyyy-mm-dd"
|
|
@@ -232,7 +232,7 @@ The `date` rule pairs naturally with `data-mask` — the mask structures input,
|
|
|
232
232
|
<span class="field-label">Date (European)</span>
|
|
233
233
|
<input class="input" name="date-eu"
|
|
234
234
|
data-mask="99/99/9999"
|
|
235
|
-
data-validation-rules="date"
|
|
235
|
+
data-validation-rules="date dd/mm/yyyy"
|
|
236
236
|
inputmode="numeric"
|
|
237
237
|
autocomplete="off"
|
|
238
238
|
placeholder="dd/mm/yyyy"
|
|
@@ -58,6 +58,32 @@ type together is a component: give it a name in application CSS.
|
|
|
58
58
|
`--card-pad`, `--cluster-justify`) are the API. Other custom properties are
|
|
59
59
|
internal and may change.
|
|
60
60
|
|
|
61
|
+
### Derive presentation from the state your HTML already exposes
|
|
62
|
+
|
|
63
|
+
| Layer | Responsibility |
|
|
64
|
+
| ----------- | --------------------------- |
|
|
65
|
+
| Application | Owns the data |
|
|
66
|
+
| JavaScript | Manages behavior |
|
|
67
|
+
| HTML | Exposes state and structure |
|
|
68
|
+
| CSS | Derives presentation |
|
|
69
|
+
|
|
70
|
+
Before adding a class, data attribute or listener for a visual change, look
|
|
71
|
+
for the state on the element or a related control. In the
|
|
72
|
+
[Tasks workspace](../../demo/templates/tasks.html), JavaScript updates the
|
|
73
|
+
task in the model, moves it between groups and sets the checkbox's `checked`
|
|
74
|
+
property. The row gets its completed appearance from that checkbox.
|
|
75
|
+
|
|
76
|
+
```css
|
|
77
|
+
.task-row:has(.task-check .check:checked) .list-item-title {
|
|
78
|
+
color: var(--text-muted);
|
|
79
|
+
text-decoration: line-through;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The same approach applies to a list's [empty state](../patterns/empty-state.md#no-results).
|
|
84
|
+
For a change that depends on available space, let [intrinsic layouts or
|
|
85
|
+
container queries](../layout/choosing.md) adapt the same markup in each context.
|
|
86
|
+
|
|
61
87
|
## Before adding CSS
|
|
62
88
|
|
|
63
89
|
Go down the layers and stop at the first that answers the need:
|
|
@@ -90,10 +90,37 @@ Keep the outline visible against the surrounding surface when changing colors.
|
|
|
90
90
|
|
|
91
91
|
→ [Button hooks](../components/button.md#css-hooks) · [Focus tokens](./tokens.md#color)
|
|
92
92
|
|
|
93
|
-
###
|
|
93
|
+
### Field borders: quiet or strong / field contrast / WCAG 1.4.11
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
Fields rest on the quiet `--border` edge, like a neutral outline button. On a
|
|
96
|
+
fill equal to the surface that edge sits under 3:1, so the default does not
|
|
97
|
+
meet WCAG 1.4.11 (non-text contrast, AA): the field reads by its label and
|
|
98
|
+
place, which an audit does not count. `actual-css contrast` reports it as a
|
|
99
|
+
warning. Increased contrast (`prefers-contrast: more`) gives every field the
|
|
100
|
+
3:1 `--border-control` edge back, and forced colors draw it in a system color.
|
|
101
|
+
For a formal AA audit (EN 301 549, RGAA), use the strong recipe.
|
|
102
|
+
|
|
103
|
+
```css
|
|
104
|
+
/* Actual default: quiet fields. */
|
|
105
|
+
:root {
|
|
106
|
+
--control-default-border: var(--border);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Strong field identification: a 3:1 edge on every side. */
|
|
110
|
+
:root {
|
|
111
|
+
--control-default-border: var(--border-control);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The criterion asks for 3:1, not a width: a 1px edge passes. The checker reads
|
|
116
|
+
the stronger of a field's lower edge and its fill against the surface, so a
|
|
117
|
+
fill that reaches 3:1 identifies the field without an edge. A faint tint, as on
|
|
118
|
+
a raised panel (below), reads well on a good screen but does not count.
|
|
119
|
+
Checkboxes, radios and switches keep `--border-control`, their only cue.
|
|
120
|
+
|
|
121
|
+
### Underline fields / bottom border only
|
|
122
|
+
|
|
123
|
+
To keep the 3:1 cue on the lower side alone, set the lower-edge hook:
|
|
97
124
|
|
|
98
125
|
```css
|
|
99
126
|
:root {
|
|
@@ -107,7 +134,7 @@ For an underline-only field on a tinted fill, also set
|
|
|
107
134
|
`--control-default-bg: var(--surface-subtle)`,
|
|
108
135
|
`--control-default-border: transparent` and
|
|
109
136
|
`--control-hover-border: transparent`; without the last one, hover draws a full
|
|
110
|
-
frame around the field. Readonly and disabled fields keep their quiet
|
|
137
|
+
frame around the field. Set `--control-hover-bg` for the hover cue instead. Readonly and disabled fields keep their quiet
|
|
111
138
|
`--border` frame on that tint; a theme that wants them frameless too sets
|
|
112
139
|
`--control-border: transparent` on those states. In forced colors every side
|
|
113
140
|
is drawn again in a system color.
|
|
@@ -120,6 +147,44 @@ Avoid lowering `--border-control-mix` instead: the default palette sits at
|
|
|
120
147
|
|
|
121
148
|
→ [Forms hooks](../forms/overview.md#hooks)
|
|
122
149
|
|
|
150
|
+
### Fields inside a card or panel / filled fields on a raised surface
|
|
151
|
+
|
|
152
|
+
The field hooks inherit, so a container retunes every field inside it. On a
|
|
153
|
+
raised panel, a tinted fill sets the fields apart from the panel:
|
|
154
|
+
|
|
155
|
+
```css
|
|
156
|
+
.settings-panel {
|
|
157
|
+
--control-default-bg: var(--surface-subtle);
|
|
158
|
+
|
|
159
|
+
background: var(--surface-raised);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The fill step sets the fields apart but stays under 3:1 on its own. For strict
|
|
164
|
+
identification, use the strong edge above; for a borderless filled field, move
|
|
165
|
+
the edge to the lower side as in the underline recipe.
|
|
166
|
+
|
|
167
|
+
→ [Forms hooks](../forms/overview.md#hooks) · Examples · Surface form
|
|
168
|
+
|
|
169
|
+
### Recessed, sunken or inset fields / relief / tactile
|
|
170
|
+
|
|
171
|
+
`--shadow-inset` presses fields and the switch, range, progress, meter and
|
|
172
|
+
segmented rails into the surface together. Pair it with a fill a step below
|
|
173
|
+
the surface around the fields:
|
|
174
|
+
|
|
175
|
+
```css
|
|
176
|
+
:root {
|
|
177
|
+
--shadow-inset: inset 0 1px 2px color-mix(in oklch, var(--shadow-color) 14%, transparent);
|
|
178
|
+
--control-default-bg: var(--surface-subtle);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The shade does not identify a field; keep its edge. `--shadow-control` raises
|
|
183
|
+
the moving parts on those rails, and `--finish` adds a sheen to every solid
|
|
184
|
+
fill. The `tactile` theme combines the three.
|
|
185
|
+
|
|
186
|
+
→ [Elevation tokens](./tokens.md#elevation)
|
|
187
|
+
|
|
123
188
|
### Keep bare native controls on-theme / accent-color
|
|
124
189
|
|
|
125
190
|
Bare checkboxes, radios, ranges, and `<progress>` follow the theme through
|
|
@@ -303,9 +368,17 @@ application CSS:
|
|
|
303
368
|
`src/css/themes/` holds example palettes (`ocean`, `spruce`, `neon`, `brutalist`, …) as
|
|
304
369
|
reference material to copy into your own `[data-theme]` island — they are demo
|
|
305
370
|
assets, not package entrypoints. Each sets the intent/surface/text tokens and
|
|
306
|
-
lets the core derive everything else.
|
|
307
|
-
|
|
308
|
-
|
|
371
|
+
lets the core derive everything else. Customize, in the docs header, previews a
|
|
372
|
+
preset on these pages, or adjusts the default theme's radius, borders, density, fields,
|
|
373
|
+
elevation, finish and font and copies the resulting CSS.
|
|
374
|
+
|
|
375
|
+
- `gradient`: outer focus halos on fields, and a button finish.
|
|
376
|
+
- `tactile`: raised cards, recessed fields and rails, domed buttons, all from
|
|
377
|
+
the elevation and finish tokens.
|
|
378
|
+
- `plush`: borderless cards, fields and rails pressed in by an inner shade,
|
|
379
|
+
tonal quiet actions, and press motion: squishing buttons, a stretching
|
|
380
|
+
switch knob. Its fields have no 3:1 cue at rest, a documented exception: the
|
|
381
|
+
outline returns under increased contrast and forced colors.
|
|
309
382
|
- `neo-brutalist`: hard shadows, pastel fills, and plus-shaped accordion
|
|
310
383
|
markers. Use it as a page skin: its rules cross nested theme boundaries.
|
|
311
384
|
- `material`: filled underline fields, pill buttons, and a table hover that
|
|
@@ -128,8 +128,10 @@ A theme with translucent surfaces overrides both with opaque values.
|
|
|
128
128
|
|
|
129
129
|
`--border` separates surfaces: cards, tables, dividers, panels.
|
|
130
130
|
`--border-control` is the resting edge that tells a control apart from the
|
|
131
|
-
surface —
|
|
132
|
-
|
|
131
|
+
surface — checkboxes and radios, the unchecked switch track, choice cards, the
|
|
132
|
+
color and file inputs. Text fields, OTP cells and join addons rest on
|
|
133
|
+
`--control-default-border`, the quiet `--border`, and take `--border-control`
|
|
134
|
+
under increased contrast ([field borders](./theming.md#field-borders-quiet-or-strong-field-contrast-wcag-1411)). It is
|
|
133
135
|
derived from `--text` and `--surface`; on the default palette it holds 3:1
|
|
134
136
|
against `--surface` and 2.9–3.0 against `--surface-subtle`. `actual-css
|
|
135
137
|
contrast` reports it for your theme. `--border-control-mix` sets the ink share;
|
|
@@ -446,6 +448,37 @@ Use a tiny elevation surface. Components should not invent their own shadow scal
|
|
|
446
448
|
|
|
447
449
|
With `color-mix()` support the shadows derive from `--shadow-color` (a theme token) and re-declare on every theme boundary so islands follow their own shadow color.
|
|
448
450
|
|
|
451
|
+
Two control-scale roles are unset by default, so the default theme stays flat.
|
|
452
|
+
A theme sets them on its root to add relief (raised, recessed, tactile, skeuomorphic):
|
|
453
|
+
|
|
454
|
+
- `--shadow-control` lifts the part that moves on a rail: the selected segment,
|
|
455
|
+
the switch knob, the range thumb. `--shadow` is too wide at that size.
|
|
456
|
+
Buttons keep their own `--btn-shadow`, which every variant reads.
|
|
457
|
+
- `--shadow-inset` recesses fields (through `--control-shadow`) and rails:
|
|
458
|
+
switch track, range track, progress, meter and segmented track.
|
|
459
|
+
|
|
460
|
+
Both enter shadow lists beside rings and overlays: flatten them with
|
|
461
|
+
`0 0 #0000`, never `none`. A recess does not identify a field; keep the
|
|
462
|
+
`--border-control` edge.
|
|
463
|
+
|
|
464
|
+
### Finish
|
|
465
|
+
|
|
466
|
+
`--finish` is a `background-image` layered over every solid fill (unset by
|
|
467
|
+
default): a gloss, a dome, a texture (sheen, gradient buttons, glossy,
|
|
468
|
+
satin). Solid buttons, checked checkboxes, radios and switches, the progress
|
|
469
|
+
value and solid badges read it; outline, ghost, soft and unchecked parts stay
|
|
470
|
+
flat.
|
|
471
|
+
|
|
472
|
+
```css
|
|
473
|
+
:root {
|
|
474
|
+
--finish: linear-gradient(rgb(255 255 255 / 0.15), transparent);
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Keep it a translucent neutral, so one value lights every intent and the intent
|
|
479
|
+
color stays in the color tokens. `actual-css contrast` measures the fill
|
|
480
|
+
without it, so keep it a veil.
|
|
481
|
+
|
|
449
482
|
### Motion
|
|
450
483
|
|
|
451
484
|
Motion durations keep transitions consistent and easy to disable.
|
|
@@ -481,6 +514,10 @@ Icons used by CSS-only controls are public tokens because users may need to repl
|
|
|
481
514
|
}
|
|
482
515
|
```
|
|
483
516
|
|
|
517
|
+
`--icon-check` is the mark of every checked state: checkbox, choice card,
|
|
518
|
+
chip, menu item and picker option. Replace it to restyle them all; its stroke
|
|
519
|
+
scales with the size each component draws it at.
|
|
520
|
+
|
|
484
521
|
A single icon token can serve both `background-image` (native select) and `mask-image` (accordion, custom select) — the embedded stroke color is the fallback for image use; mask consumers provide their own color via `background-color`. Only add an icon token when CSS needs the icon. Markup icons should stay in markup.
|
|
485
522
|
|
|
486
523
|
### Composition tokens
|