actual-css 0.20.1 → 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 +105 -0
- package/README.md +6 -6
- package/components.json +29 -7
- package/dist/actual.full.css +542 -135
- 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/tooltip.d.ts +4 -0
- 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/meter.md +1 -0
- package/docs/pages/components/progress.md +1 -0
- package/docs/pages/components/segmented.md +7 -4
- package/docs/pages/components/table.md +4 -1
- package/docs/pages/components/timeline.md +32 -0
- package/docs/pages/enhancements/flyout.md +12 -3
- package/docs/pages/enhancements/tooltip.md +6 -1
- package/docs/pages/examples/overview.md +30 -1
- package/docs/pages/forms/combobox.md +14 -10
- package/docs/pages/forms/labels.md +7 -0
- package/docs/pages/forms/overview.md +13 -10
- package/docs/pages/forms/range.md +3 -1
- 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 +109 -19
- 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 +2 -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/avatar.css +1 -0
- package/src/css/components/badge.css +7 -1
- package/src/css/components/button.css +20 -3
- package/src/css/components/flyout.css +8 -2
- package/src/css/components/list.css +28 -13
- package/src/css/components/menu.css +18 -0
- package/src/css/components/meter.css +11 -6
- package/src/css/components/progress.css +14 -6
- package/src/css/components/rating.css +2 -0
- package/src/css/components/segmented.css +22 -12
- package/src/css/components/table.css +21 -2
- package/src/css/components/timeline.css +50 -1
- package/src/css/core/theme.css +11 -1
- package/src/css/core/tokens.css +20 -2
- package/src/css/forms/choice-card.css +6 -4
- 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 +7 -1
- package/src/css/forms/range.css +31 -11
- package/src/css/forms/select.css +13 -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 +24 -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 +70 -36
- package/src/js/validation.js +24 -10
- package/src/tooling/css-bundle.js +5 -0
- package/src/tooling/design-tokens.js +9 -2
- package/src/tooling/theme-contrast.js +45 -17
- package/tokens.json +5 -0
|
@@ -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
|
|
@@ -139,6 +139,17 @@ it.
|
|
|
139
139
|
A polished interface is not necessarily a finished design. Before polishing,
|
|
140
140
|
strip the ornaments mentally and ask what the page actually says.
|
|
141
141
|
|
|
142
|
+
## Prefer derived presentation
|
|
143
|
+
|
|
144
|
+
Before adding a JavaScript-managed class, data attribute or listener, check
|
|
145
|
+
whether native HTML, ARIA or an existing application attribute already exposes
|
|
146
|
+
the state. Use a local, readable CSS selector for the visual change. Reach for
|
|
147
|
+
intrinsic layouts or container queries when the change depends on available
|
|
148
|
+
space. Keep data updates, accessible state and focus management with the code
|
|
149
|
+
that owns the interaction.
|
|
150
|
+
|
|
151
|
+
See [Derive presentation from the state your HTML already exposes](../foundations/philosophy.md#derive-presentation-from-the-state-your-html-already-exposes).
|
|
152
|
+
|
|
142
153
|
## With a design skill
|
|
143
154
|
|
|
144
155
|
A design skill and the Actual skill do not overlap. The design skill owns the
|
|
@@ -52,7 +52,7 @@ optimizing — the bare `actual-css` entrypoint and `actual-css/full` both resol
|
|
|
52
52
|
to the complete compiled framework:
|
|
53
53
|
|
|
54
54
|
```html
|
|
55
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/actual-css@0.
|
|
55
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/actual-css@0.21/dist/actual.full.min.css">
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
The package does not maintain separate partial bundles. Modular entrypoints map
|
|
@@ -183,7 +183,13 @@ published in `package.json#exports`:
|
|
|
183
183
|
| `actual-css/js/menu` | Menu keyboard/click wiring, item vocabulary |
|
|
184
184
|
| `actual-css/js/surface` | Surface lifecycle (`openSurface`, `closeSurface`, …) |
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
Import from the JavaScript subpaths in `package.json#exports`. The symbols
|
|
187
|
+
exported by those entry points are the public API, including the helpers used
|
|
188
|
+
to compose widgets. Import a component entry point directly to run its setup
|
|
189
|
+
when it has no exports.
|
|
190
|
+
|
|
191
|
+
Use `parseConfig` from `actual-css/js/parse-config` to read
|
|
192
|
+
[declarative configuration](#declarative-configuration) in custom enhancements.
|
|
187
193
|
|
|
188
194
|
## Floating contract
|
|
189
195
|
|
|
@@ -572,28 +578,108 @@ export async function prepare({ resolve, loadStyle }) {
|
|
|
572
578
|
await loadStyle(resolve("./autosubmit.css"));
|
|
573
579
|
}
|
|
574
580
|
|
|
575
|
-
export default function autosubmit(form, { config, signal
|
|
576
|
-
const
|
|
581
|
+
export default function autosubmit(form, { config, signal }) {
|
|
582
|
+
const delay = config.delay ?? 200;
|
|
583
|
+
let timer;
|
|
577
584
|
|
|
578
|
-
form.addEventListener("change", () =>
|
|
585
|
+
form.addEventListener("change", () => {
|
|
586
|
+
clearTimeout(timer);
|
|
587
|
+
timer = setTimeout(() => form.requestSubmit(), delay);
|
|
588
|
+
}, { signal });
|
|
589
|
+
return () => clearTimeout(timer);
|
|
579
590
|
}
|
|
580
591
|
```
|
|
581
592
|
|
|
582
593
|
```html
|
|
583
|
-
<form data-enhance="autosubmit"
|
|
584
|
-
data-enhance-config='{ "max": 3 }'>
|
|
594
|
+
<form data-enhance="autosubmit" data-enhance-config="delay:200">…</form>
|
|
585
595
|
```
|
|
586
596
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
597
|
+
The connect function receives the element plus `{ config, signal, emit }`.
|
|
598
|
+
The loader reads `config` from [`data-enhance-config`](#declarative-configuration)
|
|
599
|
+
and owns the AbortController. Call `emit` to dispatch
|
|
600
|
+
`actual:<name>:<type>` events. Connect must be synchronous and may return
|
|
601
|
+
a cleanup function.
|
|
602
|
+
|
|
603
|
+
#### Without a build
|
|
604
|
+
|
|
605
|
+
The plain `<script src="actual.full.js">` bundle exposes no global, so a page
|
|
606
|
+
without a bundler cannot call `registerEnhancement()`. It does not need to: the
|
|
607
|
+
bundle watches manifests, so a page declares its own module and the runtime
|
|
608
|
+
imports and registers it, on the same lifecycle as the built-in behaviors.
|
|
609
|
+
|
|
610
|
+
```html
|
|
611
|
+
<script type="application/json" data-enhance-modules>
|
|
612
|
+
{ "autosubmit": "/js/autosubmit.js" }
|
|
613
|
+
</script>
|
|
614
|
+
<script src="/dist/actual.full.js" defer></script>
|
|
615
|
+
|
|
616
|
+
<form data-enhance="autosubmit" data-enhance-config="delay:350">…</form>
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
`/js/autosubmit.js` is an ES module with the default export shown above; no
|
|
620
|
+
import of Actual is needed. Serve the page over HTTP: browsers refuse module
|
|
621
|
+
imports from a page opened as `file://`, and the behavior silently never
|
|
622
|
+
connects. A behavior that owns its own attribute instead of a
|
|
623
|
+
`data-enhance` token can stay a classic script.
|
|
592
624
|
|
|
593
625
|
`loadScript(url)` and `loadStyle(url)` are public helpers for non-ESM assets.
|
|
594
626
|
Names are reserved once per manifest set — redeclaring a name from a different
|
|
595
|
-
URL throws, and duplicate declarations share one import promise.
|
|
596
|
-
|
|
627
|
+
URL throws, and duplicate declarations share one import promise.
|
|
628
|
+
|
|
629
|
+
## Declarative configuration
|
|
630
|
+
|
|
631
|
+
For hand-written HTML, use comma-separated `key:value` pairs. The outer
|
|
632
|
+
braces are optional.
|
|
633
|
+
|
|
634
|
+
```html
|
|
635
|
+
<div data-config="delay:200,wrap:true"></div>
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
The manifest loader reads `data-enhance-config` automatically. In a custom
|
|
639
|
+
enhancement, choose an attribute and import the `parseConfig` primitive from
|
|
640
|
+
`actual-css/js/parse-config`. Here, `data-config` is an application attribute.
|
|
641
|
+
|
|
642
|
+
```js
|
|
643
|
+
import { parseConfig } from "actual-css/js/parse-config";
|
|
644
|
+
|
|
645
|
+
const config = parseConfig(element.getAttribute("data-config"));
|
|
646
|
+
// { delay: 200, wrap: true }
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
Strict JSON objects work in the same attribute, including output from
|
|
650
|
+
`JSON.stringify()`. The parser tries strict JSON first and falls back to the
|
|
651
|
+
compact syntax if JSON parsing fails.
|
|
652
|
+
|
|
653
|
+
```html
|
|
654
|
+
<div data-config='{"delay":200,"wrap":true}'></div>
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
### Supported syntax
|
|
658
|
+
|
|
659
|
+
- Separate pairs with commas and keys from values with a colon. Whitespace
|
|
660
|
+
around tokens is allowed. Nested objects require braces and arrays require
|
|
661
|
+
brackets. Both may contain compact objects and quoted strings.
|
|
662
|
+
- Unquoted keys match `[A-Za-z_$][A-Za-z0-9_$-]*`. Quote other keys with
|
|
663
|
+
single or double quotes.
|
|
664
|
+
- Values are quoted strings, JSON numbers (including decimals and exponents),
|
|
665
|
+
`true`, `false`, `null`, objects, or arrays. Quote text values such as
|
|
666
|
+
`placement:'bottom'`.
|
|
667
|
+
- Double-quoted strings use JSON escaping. In single-quoted strings, use
|
|
668
|
+
`\'` for an apostrophe, write double quotes literally, and use JSON escapes
|
|
669
|
+
such as `\n` and `\t` for control characters. In HTML, escape any quote
|
|
670
|
+
that matches the attribute delimiter as `"` or `'`.
|
|
671
|
+
|
|
672
|
+
### Errors and defaults
|
|
673
|
+
|
|
674
|
+
`parseConfig()` returns an empty object for missing, blank, or non-string
|
|
675
|
+
input. The result of parsing a string must be an object. Valid JSON with
|
|
676
|
+
an array, scalar, or `null` at the root throws `TypeError`. Malformed input
|
|
677
|
+
throws `SyntaxError`, including trailing commas, bare text values, comments,
|
|
678
|
+
and unfinished strings.
|
|
679
|
+
|
|
680
|
+
Use the result to apply your enhancement's defaults and validate its option
|
|
681
|
+
values. If parsing throws during enhancer setup, the runtime logs the error
|
|
682
|
+
and skips setup for that element.
|
|
597
683
|
|
|
598
684
|
## Lifecycle rules
|
|
599
685
|
|
|
@@ -666,12 +752,14 @@ Actual's built-in filters.
|
|
|
666
752
|
```js
|
|
667
753
|
import enhance from "actual-css/js/enhance";
|
|
668
754
|
import { dispatchInput, onTextInput, selectionStart, setCaret } from "actual-css/js/input";
|
|
755
|
+
import { parseConfig } from "actual-css/js/parse-config";
|
|
669
756
|
|
|
670
757
|
const filters = {
|
|
671
|
-
currency(value) {
|
|
758
|
+
currency(value, precision) {
|
|
672
759
|
const normalized = value.replace(/,/g, ".");
|
|
673
760
|
const [whole, decimals = ""] = normalized.replace(/[^0-9.]/g, "").split(".");
|
|
674
|
-
|
|
761
|
+
const fraction = decimals.slice(0, precision);
|
|
762
|
+
return fraction ? `${whole}.${fraction}` : whole;
|
|
675
763
|
},
|
|
676
764
|
time(value) {
|
|
677
765
|
const digits = value.replace(/\D/g, "").slice(0, 4);
|
|
@@ -681,8 +769,10 @@ const filters = {
|
|
|
681
769
|
|
|
682
770
|
enhance({
|
|
683
771
|
"input[data-app-filter]": (input) => {
|
|
684
|
-
const
|
|
685
|
-
if (!
|
|
772
|
+
const { kind, precision } = parseConfig(input.dataset.appFilter);
|
|
773
|
+
if (typeof kind !== "string" || !Object.hasOwn(filters, kind)) return;
|
|
774
|
+
const digits = Number.isInteger(precision) && precision >= 0 ? precision : 2;
|
|
775
|
+
const filter = (value) => filters[kind](value, digits);
|
|
686
776
|
|
|
687
777
|
const controller = new AbortController();
|
|
688
778
|
let filtering = false;
|
|
@@ -712,8 +802,8 @@ enhance({
|
|
|
712
802
|
```
|
|
713
803
|
|
|
714
804
|
```html
|
|
715
|
-
<input class="input" inputmode="decimal" data-app-filter="currency" autocomplete="off" />
|
|
716
|
-
<input class="input" inputmode="numeric" data-app-filter="time" autocomplete="off" />
|
|
805
|
+
<input class="input" inputmode="decimal" data-app-filter="kind:'currency',precision:3" autocomplete="off" />
|
|
806
|
+
<input class="input" inputmode="numeric" data-app-filter="kind:'time'" autocomplete="off" />
|
|
717
807
|
```
|
|
718
808
|
|
|
719
809
|
## Textarea autogrow
|
|
@@ -166,7 +166,7 @@ consider whether the real requirement is simply “create another column wheneve
|
|
|
166
166
|
|
|
167
167
|
This removes viewport breakpoint choreography entirely.
|
|
168
168
|
|
|
169
|
-
##
|
|
169
|
+
## Context-aware components
|
|
170
170
|
|
|
171
171
|
Tailwind allows almost every utility to be changed independently at a breakpoint:
|
|
172
172
|
|
|
@@ -186,7 +186,11 @@ If the requirement is:
|
|
|
186
186
|
|
|
187
187
|
> Show these items horizontally when there is enough room, otherwise stack them.
|
|
188
188
|
|
|
189
|
-
use a layout primitive such as `.switcher
|
|
189
|
+
use a layout primitive such as [`.switcher`](../layout/switcher.md). For cards
|
|
190
|
+
that reflow as space permits, use [`.grid`](../layout/grid.md). When a component
|
|
191
|
+
needs a specific width threshold, query its container in application CSS.
|
|
192
|
+
Actual's fixed-count grids and Steps can also read the shared
|
|
193
|
+
[`actual-container` context](../layout/grid.md#balanced-subdivision).
|
|
190
194
|
|
|
191
195
|
If the requirement truly is:
|
|
192
196
|
|
|
@@ -312,7 +316,7 @@ Otherwise write the declaration normally.
|
|
|
312
316
|
|
|
313
317
|
This is one of the largest mechanical differences for Tailwind-heavy applications.
|
|
314
318
|
|
|
315
|
-
## State
|
|
319
|
+
## State-aware components
|
|
316
320
|
|
|
317
321
|
Tailwind can keep highly specific state rules in markup:
|
|
318
322
|
|
|
@@ -342,9 +346,11 @@ For application-specific state styling, keep the semantic attribute and style it
|
|
|
342
346
|
}
|
|
343
347
|
```
|
|
344
348
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
349
|
+
Apply the same approach to `group-*`, `peer-*`, `has-*` and arbitrary selector
|
|
350
|
+
variants. For example, the [Tasks workspace](../../demo/templates/tasks.html)
|
|
351
|
+
uses `:has(.task-check .check:checked)` on a named row so every instance shares
|
|
352
|
+
the completed style in one rule. See [the state principle](../foundations/philosophy.md#derive-presentation-from-the-state-your-html-already-exposes)
|
|
353
|
+
for the selector and the division of responsibilities.
|
|
348
354
|
|
|
349
355
|
## Colors and dark mode
|
|
350
356
|
|
|
@@ -7,6 +7,58 @@ sections in order when skipping a release.
|
|
|
7
7
|
|
|
8
8
|
**Related terms:** migration, breaking changes, update, version.
|
|
9
9
|
|
|
10
|
+
## 0.20 to 0.21
|
|
11
|
+
|
|
12
|
+
### Field borders
|
|
13
|
+
|
|
14
|
+
`.input`, `.textarea`, `.select`, `.join-addon` and `.otp` cells rest on the
|
|
15
|
+
quiet `--border` edge, and on `--border-control` only under
|
|
16
|
+
`prefers-contrast: more`. On a fill identical to the surface, the quiet edge
|
|
17
|
+
does not meet the 3:1 of WCAG 1.4.11. To keep the strong edge everywhere:
|
|
18
|
+
|
|
19
|
+
```css
|
|
20
|
+
:root {
|
|
21
|
+
--control-default-border: var(--border-control);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
[Theming](../foundations/theming.md) lists the other field treatments that
|
|
26
|
+
keep a 3:1 cue.
|
|
27
|
+
|
|
28
|
+
### Button gradients
|
|
29
|
+
|
|
30
|
+
`.btn` paints `--btn-bg` with `background-color`. A gradient in `--ui-bg`,
|
|
31
|
+
`--btn-bg` or `--btn-default-bg` no longer renders: keep a color there and
|
|
32
|
+
move the image to `--finish`.
|
|
33
|
+
|
|
34
|
+
### Named JavaScript exports
|
|
35
|
+
|
|
36
|
+
`actual-css/js/parse-config`, `actual-css/js/status` and
|
|
37
|
+
`actual-css/js/validation` have no default export:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import { parseConfig } from "actual-css/js/parse-config";
|
|
41
|
+
import { status } from "actual-css/js/status";
|
|
42
|
+
import { FormValidator } from "actual-css/js/validation";
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`nextItem()` from `actual-css/js/keys` stops at the first and last item. Pass
|
|
46
|
+
`{ wrap: true }` where focus should cycle.
|
|
47
|
+
|
|
48
|
+
### App layout topbar
|
|
49
|
+
|
|
50
|
+
On wide screens, an `.app-layout` without an `.app-nav > header` lets its
|
|
51
|
+
`.topbar` span the side navigation. To keep the navigation at full height,
|
|
52
|
+
move the brand into an `.app-nav > header`.
|
|
53
|
+
|
|
54
|
+
### Select
|
|
55
|
+
|
|
56
|
+
- A hovered `.select` no longer fills with `--surface-subtle`; set
|
|
57
|
+
`--control-hover-bg` to restore a hover fill on every field.
|
|
58
|
+
- The chevron sits `--select-icon-inset` from the edge, so the default
|
|
59
|
+
glyph's ink lines up with `--control-pad-x`. Set the offset for a
|
|
60
|
+
replacement `--icon-chevron` whose ink fills more or less of its box.
|
|
61
|
+
|
|
10
62
|
## 0.16 to 0.17
|
|
11
63
|
|
|
12
64
|
### Current nav link
|
|
@@ -8,6 +8,9 @@ Use `.app-layout` only when all three direct regions are intentional:
|
|
|
8
8
|
- `.app-main` is the page's independent scroll container;
|
|
9
9
|
- `.app-nav` changes from bottom navigation to labelled side navigation.
|
|
10
10
|
|
|
11
|
+
**Related terms:** app shell, workspace, inset shell, tab bar, bottom
|
|
12
|
+
navigation, side navigation, navigation rail, master-detail app.
|
|
13
|
+
|
|
11
14
|
This is not a generic wrapper for a website, dashboard, or anything described
|
|
12
15
|
as an "app." It fixes the shell to the dynamic viewport and hides overflow on
|
|
13
16
|
that shell. A public, marketing, editorial, or normally scrolling page should
|
|
@@ -41,6 +44,28 @@ assigns those children to named grid areas and changes `.app-nav` from a bottom
|
|
|
41
44
|
bar to labelled side navigation. Missing, renamed, or wrapped regions mean a
|
|
42
45
|
different layout contract should be used.
|
|
43
46
|
|
|
47
|
+
## Where the brand lives
|
|
48
|
+
|
|
49
|
+
From the side breakpoint, the brand's place decides who owns the top-left
|
|
50
|
+
corner:
|
|
51
|
+
|
|
52
|
+
- brand in the topbar, no `header` in `.app-nav`: the topbar is a global bar
|
|
53
|
+
over the navigation, for identity, global search, the account and other
|
|
54
|
+
application-wide context. Collapsing the rail leaves the brand untouched.
|
|
55
|
+
- brand in a side `.app-nav > header`: the navigation runs the full height,
|
|
56
|
+
the compact shape of a small standalone app.
|
|
57
|
+
|
|
58
|
+
No attribute chooses between them; adding or removing the `header` does. The
|
|
59
|
+
[Tasks template](../../demo/templates/tasks.html) switches between both from
|
|
60
|
+
its account menu.
|
|
61
|
+
|
|
62
|
+
The topbar earns its band with global actions, such as search or creation.
|
|
63
|
+
Without any, hide it from the side breakpoint (`@media (min-width: 48rem)`):
|
|
64
|
+
its row collapses, the side navigation's `header` carries the brand, and a
|
|
65
|
+
phone keeps the topbar, where that header is hidden. Size
|
|
66
|
+
`--app-layout-bar-size` to the main region's first row so the brand stays on
|
|
67
|
+
its line; the [Tasks template](../../demo/templates/tasks.html) does this.
|
|
68
|
+
|
|
44
69
|
A direct-child `.fab` overlays the end of the main grid area. It therefore
|
|
45
70
|
clears both bottom and side navigation without copying the navigation size or
|
|
46
71
|
bottom safe-area inset. When navigation moves aside, the layout applies the
|
|
@@ -52,6 +77,30 @@ which avoids fixed-position offsets and keeps mobile keyboard resizing within
|
|
|
52
77
|
the same layout contract. The topbar preserves its normal spacing below the
|
|
53
78
|
top safe-area inset. The recipe provides no routing or page lifecycle.
|
|
54
79
|
|
|
55
|
-
|
|
80
|
+
The [Tasks template](../../demo/templates/tasks.html) composes it with a
|
|
81
|
+
master-detail workspace inset on the canvas: `.app-nav` drops its own surface,
|
|
82
|
+
and `.app-main` carries the raised one.
|
|
83
|
+
|
|
84
|
+
## Rail
|
|
85
|
+
|
|
86
|
+
`data-nav="rail"` is a desktop preference for a captioned rail instead of labelled
|
|
87
|
+
side navigation. Below the side breakpoint both produce the same bottom bar.
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<div class="app-layout" data-nav="rail">
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The layout only draws the rail. Toggling the attribute, labelling the toggle
|
|
94
|
+
and remembering the choice belong to the application; to use the rail on
|
|
95
|
+
tablets only, set the attribute from `matchMedia`. See
|
|
96
|
+
[App navigation](../components/app-navigation.md#rail) for what each tile shows.
|
|
97
|
+
|
|
98
|
+
## Hooks
|
|
56
99
|
|
|
57
100
|
- `--app-nav-side-size` controls the side navigation track.
|
|
101
|
+
- `--app-nav-rail-size` controls the rail track.
|
|
102
|
+
- `--app-layout-bar-size` is the top band shared by the topbar and the first
|
|
103
|
+
row of a side `.app-nav > header`, so the brand sits on the topbar's line and
|
|
104
|
+
the first destination starts level with the main region. Raise it when the
|
|
105
|
+
topbar holds taller content, or size it to the main region's first row when
|
|
106
|
+
the topbar is hidden on desktop.
|
|
@@ -37,22 +37,44 @@ For an icon on a tinted disc, compose an [icon slot](icon-slot.md).
|
|
|
37
37
|
|
|
38
38
|
## No results
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
Filter the list with `hidden` and announce the result count in a persistent
|
|
41
|
+
`role="status"` region. CSS shows the empty state when no list item is visible.
|
|
42
|
+
Browsers without `:has()` still show the count, including zero. When clearing
|
|
43
|
+
the search from the empty state, return focus to the field before the button
|
|
44
|
+
disappears. Try searching for “zebra”.
|
|
43
45
|
|
|
44
46
|
```html demo
|
|
47
|
+
<style>
|
|
48
|
+
#member-empty {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#member-results:not(:has(> li:not([hidden]))) {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#member-results:not(:has(> li:not([hidden]))) + #member-empty {
|
|
57
|
+
display: flex;
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
60
|
+
|
|
45
61
|
<div class="stack">
|
|
46
62
|
<div class="field">
|
|
47
63
|
<label class="field-label" for="member-search">Search members</label>
|
|
48
|
-
<input class="input" type="search" id="member-search"
|
|
64
|
+
<input class="input" type="search" id="member-search">
|
|
49
65
|
</div>
|
|
50
66
|
|
|
51
|
-
<
|
|
52
|
-
|
|
67
|
+
<p class="muted" id="member-count" role="status">3 members found.</p>
|
|
68
|
+
<ul class="list" id="member-results">
|
|
69
|
+
<li class="list-item">Alice Chen</li>
|
|
70
|
+
<li class="list-item">Bob Okafor</li>
|
|
71
|
+
<li class="list-item">Charlie Ruiz</li>
|
|
72
|
+
</ul>
|
|
73
|
+
|
|
74
|
+
<section class="stack items-center text-center" id="member-empty"
|
|
53
75
|
aria-labelledby="no-results-title">
|
|
54
76
|
<hgroup>
|
|
55
|
-
<h3 id="no-results-title">No members
|
|
77
|
+
<h3 id="no-results-title">No matching members</h3>
|
|
56
78
|
<p class="muted">Check the spelling, or clear the search to see everyone.</p>
|
|
57
79
|
</hgroup>
|
|
58
80
|
<button class="btn outline" type="button" id="clear-member-search">
|
|
@@ -61,14 +83,30 @@ otherwise it falls to the page.
|
|
|
61
83
|
</section>
|
|
62
84
|
</div>
|
|
63
85
|
|
|
64
|
-
<script>
|
|
86
|
+
<script type="module">
|
|
65
87
|
const search = document.getElementById("member-search");
|
|
66
|
-
const
|
|
88
|
+
const members = document.getElementById("member-results").children;
|
|
89
|
+
const count = document.getElementById("member-count");
|
|
67
90
|
|
|
91
|
+
function filterMembers() {
|
|
92
|
+
const query = search.value.trim().toLowerCase();
|
|
93
|
+
let matches = 0;
|
|
94
|
+
|
|
95
|
+
for (const member of members) {
|
|
96
|
+
member.hidden = !member.textContent.toLowerCase().includes(query);
|
|
97
|
+
if (!member.hidden) matches += 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
count.textContent = `${matches} ${matches === 1 ? "member" : "members"} found.`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
search.addEventListener("input", filterMembers);
|
|
68
104
|
document.getElementById("clear-member-search").addEventListener("click", () => {
|
|
69
105
|
search.value = "";
|
|
70
|
-
noResults.hidden = true;
|
|
71
106
|
search.focus();
|
|
107
|
+
filterMembers();
|
|
72
108
|
});
|
|
109
|
+
|
|
110
|
+
filterMembers();
|
|
73
111
|
</script>
|
|
74
112
|
```
|