actual-css 0.16.1 → 0.17.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 +64 -0
- package/README.md +8 -4
- package/components.json +19 -4
- package/dist/actual.full.css +393 -69
- package/dist/actual.full.js +2 -1
- package/dist/actual.full.min.css +1 -1
- package/docs/design-notes/app-ui.md +37 -3
- package/docs/design-notes/enhancement-contract.md +3 -1
- package/docs/navigation.json +14 -1
- package/docs/pages/components/alert.md +45 -17
- package/docs/pages/components/button.md +3 -0
- package/docs/pages/components/dialog.md +36 -0
- package/docs/pages/components/drawer.md +52 -8
- package/docs/pages/components/navbar.md +26 -2
- package/docs/pages/components/rating.md +111 -12
- package/docs/pages/components/segmented.md +36 -1
- package/docs/pages/components/spinner.md +2 -0
- package/docs/pages/components/table.md +77 -0
- package/docs/pages/components/timeline.md +3 -1
- package/docs/pages/enhancements/flyout.md +83 -14
- package/docs/pages/enhancements/tabs.md +5 -0
- package/docs/pages/examples/overview.md +5 -1
- package/docs/pages/forms/ajax.md +101 -0
- package/docs/pages/forms/color-swatches.md +31 -2
- package/docs/pages/forms/joined-controls.md +8 -3
- package/docs/pages/forms/overview.md +1 -1
- package/docs/pages/forms/unsaved-changes.md +198 -0
- package/docs/pages/foundations/philosophy.md +2 -1
- package/docs/pages/foundations/theming.md +2 -1
- package/docs/pages/foundations/tokens.md +1 -1
- package/docs/pages/guides/introduction.md +1 -1
- package/docs/pages/guides/progressive-enhancement.md +30 -49
- package/docs/pages/guides/upgrading.md +15 -2
- package/docs/pages/layout/choosing.md +5 -0
- package/docs/pages/layout/column-layout.md +22 -8
- package/docs/pages/layout/sidebar-shell.md +68 -0
- package/docs/pages/patterns/empty-state.md +74 -0
- package/docs/pages/patterns/hierarchical-nav.md +40 -19
- package/docs/pages/patterns/navigation-list.md +3 -60
- package/docs/pages/patterns/stat.md +61 -0
- package/docs/pages/utilities/accessibility.md +32 -10
- package/package.json +4 -1
- package/reserved-classes.json +2 -0
- package/src/css/components/busy.css +25 -0
- package/src/css/components/button.css +3 -0
- package/src/css/components/drawer.css +37 -3
- package/src/css/components/flyout.css +37 -0
- package/src/css/components/modal.css +3 -0
- package/src/css/components/navbar.css +99 -38
- package/src/css/components/rating.css +50 -5
- package/src/css/components/segmented.css +25 -2
- package/src/css/forms/color-swatch.css +38 -19
- package/src/css/forms/custom-select.css +5 -0
- package/src/css/layout/index.css +2 -0
- package/src/css/layout/sidebar-shell.css +67 -0
- package/src/js/ajax.js +148 -0
- package/src/js/dialog.js +59 -2
- package/src/js/dirty.js +140 -0
- package/src/js/dismiss.js +25 -0
- package/src/js/events.js +17 -0
- package/src/js/focus.js +12 -0
- package/src/js/form-submission.js +34 -0
- package/src/js/full.js +2 -0
- package/src/js/tab.js +16 -2
- package/src/js/validation.js +12 -4
- package/src/tooling/theme-contrast.js +3 -2
|
@@ -569,7 +569,7 @@ Selected state has three roles:
|
|
|
569
569
|
|
|
570
570
|
- `--state-selected` — the selected fill or accent: a pressed button, a checked switch, a completed step.
|
|
571
571
|
- `--state-selected-fg` — ink on that fill.
|
|
572
|
-
- `--state-selected-text` — selected ink on a regular surface: the
|
|
572
|
+
- `--state-selected-text` — selected ink on a regular surface: the selected tab, the current step's number and ring.
|
|
573
573
|
|
|
574
574
|
`--state-selected-text` falls back to `--state-selected` within each theme.
|
|
575
575
|
Set it separately when the selected fill lacks contrast as text, especially
|
|
@@ -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.17/dist/actual.full.min.css">
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
The package does not maintain separate partial bundles. Modular entrypoints map
|
|
@@ -126,6 +126,8 @@ status bar, for example:
|
|
|
126
126
|
| `actual-css/js/password` | Password reveal toggle |
|
|
127
127
|
| `actual-css/js/range` | Range fill and named values (token `range`) |
|
|
128
128
|
| `actual-css/js/validation` | Form validation (token `validation`) |
|
|
129
|
+
| `actual-css/js/dirty` | Unsaved-changes state on forms (token `dirty`) |
|
|
130
|
+
| `actual-css/js/ajax` | Form submission through `fetch` (token `ajax`) |
|
|
129
131
|
| `actual-css/js/status` | Singleton status bar on `[data-status][role="status"]` |
|
|
130
132
|
| `actual-css/js/enhancement-loader` | Declared enhancement manifests |
|
|
131
133
|
|
|
@@ -142,8 +144,9 @@ needed.
|
|
|
142
144
|
The JS is designed to run on its own, without Actual's stylesheet.
|
|
143
145
|
|
|
144
146
|
- **`data-enhance` tokens** register named behaviors. The runtime discovers
|
|
145
|
-
components through `data-enhance="tabs"`, `data-enhance="flyout"`, `data-enhance="range"`, `data-enhance="scrollspy"`,
|
|
146
|
-
`data-enhance="validation"`
|
|
147
|
+
components through `data-enhance="tabs"`, `data-enhance="flyout"`, `data-enhance="range"`, `data-enhance="scrollspy"`,
|
|
148
|
+
`data-enhance="validation"`, `data-enhance="dirty"`, and
|
|
149
|
+
`data-enhance="ajax"` — no Actual presentation class needed.
|
|
147
150
|
Self-describing attributes (`data-mask`, `data-tooltip`,
|
|
148
151
|
`data-context-menu`) stay framework-neutral by construction.
|
|
149
152
|
- **`selectors.js`** lists the state classes the runtime *writes* (`is-open`,
|
|
@@ -322,14 +325,19 @@ The runtime dispatches a small set of public `actual:*` events. All are
|
|
|
322
325
|
listenable on the document; cancelable events veto the associated action when
|
|
323
326
|
`preventDefault()` is called.
|
|
324
327
|
|
|
325
|
-
| Event | Dispatch
|
|
326
|
-
| ---------------------- |
|
|
327
|
-
| `actual:surface-open` | before a surface opens
|
|
328
|
-
| `actual:context-menu` | before a context menu opens
|
|
329
|
-
| `actual:status` | status module, or any code
|
|
330
|
-
| `actual:invalid` | after a submit was blocked
|
|
331
|
-
| `actual:
|
|
332
|
-
| `actual:
|
|
328
|
+
| Event | Dispatch | `detail` |
|
|
329
|
+
| ---------------------- | ------------------------------ | ------------------------------------ |
|
|
330
|
+
| `actual:surface-open` | before a surface opens | `{ surface, options }` |
|
|
331
|
+
| `actual:context-menu` | before a context menu opens | `{ menu, context, origin, trigger }` |
|
|
332
|
+
| `actual:status` | status module, or any code | `{ message, intent, duration }` |
|
|
333
|
+
| `actual:invalid` | after a submit was blocked | `{ form, firstInvalid, message }` |
|
|
334
|
+
| `actual:dirty-change` | after `data-dirty` flips | `{ form, dirty }` |
|
|
335
|
+
| `actual:ajax-start` | an ajax request starts | `{ form, submitter }` |
|
|
336
|
+
| `actual:ajax-response` | an ajax response arrived | `{ form, submitter, response }` |
|
|
337
|
+
| `actual:ajax-error` | an ajax request failed | `{ form, submitter, error }` |
|
|
338
|
+
| `actual:tab-change` | after the selected tab changed | `{ tab, panel, previousTab }` |
|
|
339
|
+
| `actual:dialog-cancel` | before a native cancel close | `{ dialog, sourceEvent }` |
|
|
340
|
+
| `actual:dismiss` | after a `--dismiss` dismissal | `{ trigger }` |
|
|
333
341
|
|
|
334
342
|
`actual:surface-open`, `actual:context-menu` and `actual:dialog-cancel` are
|
|
335
343
|
cancelable. `actual:status` both shows and clears the status bar — omit
|
|
@@ -379,9 +387,14 @@ or a direct dialog API call to delegate their commands to Actual.
|
|
|
379
387
|
|
|
380
388
|
### Dismiss command
|
|
381
389
|
|
|
382
|
-
The runtime includes a generic `--dismiss` command for hiding
|
|
383
|
-
|
|
384
|
-
|
|
390
|
+
The runtime includes a generic `--dismiss` command for hiding the element its
|
|
391
|
+
`commandfor` names; without a resolved target it does nothing. It prevents the
|
|
392
|
+
trigger's default action, sets `hidden`, and emits a bubbling `actual:dismiss`
|
|
393
|
+
event with the trigger in `event.detail.trigger`.
|
|
394
|
+
|
|
395
|
+
When focus was inside the target, it moves to the next tab stop after the
|
|
396
|
+
target, or to the nearest ancestor with a `tabindex` when nothing follows. A
|
|
397
|
+
listener that places focus itself keeps it.
|
|
385
398
|
On an open surface (flyout, context menu), the surface consumes the event to
|
|
386
399
|
close through its own lifecycle instead of staying hidden — by the time the
|
|
387
400
|
event reaches document listeners, `hidden` has already been lifted again and
|
|
@@ -727,42 +740,10 @@ enhance({
|
|
|
727
740
|
});
|
|
728
741
|
```
|
|
729
742
|
|
|
730
|
-
## Ajax
|
|
731
|
-
|
|
732
|
-
Keep the native form as the baseline: set `action`, `method`, fields, and submit
|
|
733
|
-
buttons normally. The enhancer can intercept submission only when JavaScript is
|
|
734
|
-
available.
|
|
735
|
-
|
|
736
|
-
```js
|
|
737
|
-
import enhance from "actual-css/js/enhance";
|
|
738
|
-
|
|
739
|
-
enhance({
|
|
740
|
-
"form[data-ajax]": (form) => {
|
|
741
|
-
const controller = new AbortController();
|
|
742
|
-
|
|
743
|
-
form.addEventListener("submit", async (event) => {
|
|
744
|
-
event.preventDefault();
|
|
745
|
-
|
|
746
|
-
const submitter = event.submitter;
|
|
747
|
-
const data = new FormData(form, submitter);
|
|
748
|
-
const response = await fetch(form.action, {
|
|
749
|
-
method: form.method || "GET",
|
|
750
|
-
body: form.method.toUpperCase() === "GET" ? null : data,
|
|
751
|
-
signal: controller.signal,
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
form.dispatchEvent(new CustomEvent("actual:ajax", {
|
|
755
|
-
bubbles: true,
|
|
756
|
-
detail: { response },
|
|
757
|
-
}));
|
|
758
|
-
}, { signal: controller.signal });
|
|
759
|
-
|
|
760
|
-
return () => controller.abort();
|
|
761
|
-
},
|
|
762
|
-
});
|
|
763
|
-
```
|
|
743
|
+
## Ajax fragments
|
|
764
744
|
|
|
765
|
-
|
|
745
|
+
Forms submit through `fetch` with the built-in [Ajax Submission](../forms/ajax.md)
|
|
746
|
+
enhancer. For a trigger that loads a fragment, keep the first version narrow: one trigger, one
|
|
766
747
|
target, one swap rule. If the behavior grows into history management, out-of-band
|
|
767
748
|
swaps, request queues, and event policies, use a dedicated library.
|
|
768
749
|
|
|
@@ -780,7 +761,7 @@ enhance({
|
|
|
780
761
|
const response = await fetch(trigger.dataset.get, {
|
|
781
762
|
signal: controller.signal,
|
|
782
763
|
});
|
|
783
|
-
target.innerHTML = await response.text();
|
|
764
|
+
if (response.ok) target.innerHTML = await response.text();
|
|
784
765
|
}, { signal: controller.signal });
|
|
785
766
|
|
|
786
767
|
return () => controller.abort();
|
|
@@ -7,6 +7,19 @@ sections in order when skipping a release.
|
|
|
7
7
|
|
|
8
8
|
**Related terms:** migration, breaking changes, update, version.
|
|
9
9
|
|
|
10
|
+
## 0.16 to 0.17
|
|
11
|
+
|
|
12
|
+
### Current nav link
|
|
13
|
+
|
|
14
|
+
The current `.nav-link` is neutral: `--text` ink on a fill one step above
|
|
15
|
+
hover, no inline-start trait outside forced colors. `--state-selected-text`
|
|
16
|
+
no longer reaches it.
|
|
17
|
+
|
|
18
|
+
- To keep a colored current link, set `--nav-current-fg` (and
|
|
19
|
+
`--nav-current-bg`) on the nav; check the pair with `actual-css contrast`.
|
|
20
|
+
- Rules that removed the trait (`.nav-list .nav-link[aria-current]::before {
|
|
21
|
+
content: none }`) now only remove the forced-colors cue: delete them.
|
|
22
|
+
|
|
10
23
|
## 0.14 to 0.15
|
|
11
24
|
|
|
12
25
|
No class or hook is removed: markup and application CSS keep working.
|
|
@@ -124,8 +137,8 @@ row, set `--step-min: 7rem` on it.
|
|
|
124
137
|
|
|
125
138
|
### Current links and rows
|
|
126
139
|
|
|
127
|
-
`.nav-link` shows its current state only for `aria-current="page"
|
|
128
|
-
`aria-current="location"`, and `a.list-item` only for `aria-current="page"` or
|
|
140
|
+
`.nav-link` shows its current state only for `aria-current="page"`,
|
|
141
|
+
`aria-current="location"` or `aria-current="true"`, and `a.list-item` only for `aria-current="page"` or
|
|
129
142
|
`aria-current="true"`. Search markup for other values on these classes and
|
|
130
143
|
use the matching one.
|
|
131
144
|
|
|
@@ -9,6 +9,7 @@ number of children visible in one mockup.
|
|
|
9
9
|
| ----------------------------------------------- | ------------------------------------------- |
|
|
10
10
|
| A normally scrolling page | Semantic landmarks, optionally `.app-shell` |
|
|
11
11
|
| Full-width bands over a centered content column | `.center` inside each landmark |
|
|
12
|
+
| Persistent sidebar + main, drawer on a phone | `.sidebar-shell` |
|
|
12
13
|
| Topbar + scrolling main + adaptive nav | `.app-layout` |
|
|
13
14
|
|
|
14
15
|
For public, marketing, and editorial pages, use semantic landmarks and add
|
|
@@ -23,6 +24,10 @@ rather than the row (see
|
|
|
23
24
|
[Marketing](../../demo/templates/marketing.html) and
|
|
24
25
|
[Blog](../../demo/templates/blog.html) compose bands this way.
|
|
25
26
|
|
|
27
|
+
Use `.sidebar-shell` for an admin or dashboard whose sidebar stays beside the
|
|
28
|
+
content on a wide screen and moves to a drawer on a phone, where the document
|
|
29
|
+
scrolls normally. See [Sidebar Shell](sidebar-shell.md).
|
|
30
|
+
|
|
26
31
|
Use `.app-layout` for a viewport-sized shell where the main region scrolls
|
|
27
32
|
independently and navigation moves from bottom to side. Follow its
|
|
28
33
|
[required structure](app-layout.md). For other arrangements, compose the
|
|
@@ -9,6 +9,9 @@ are a collection, a known density, peers that switch together, or a main region
|
|
|
9
9
|
with an aside, one of the other primitives already says so — and says it with
|
|
10
10
|
intrinsic responsive behavior this one does not have.
|
|
11
11
|
|
|
12
|
+
**Related terms:** twelve-column grid, bento, bento grid, mosaic, uneven
|
|
13
|
+
feature grid, offset column.
|
|
14
|
+
|
|
12
15
|
```css
|
|
13
16
|
.article-main {
|
|
14
17
|
--column-span: 8;
|
|
@@ -111,6 +114,23 @@ Both sections use start 3 and span 8, so their content shares a left edge and
|
|
|
111
114
|
an alignment gutter without a wrapping grid. In an application, give that pair
|
|
112
115
|
one class and reuse it.
|
|
113
116
|
|
|
117
|
+
## Uneven feature grids
|
|
118
|
+
|
|
119
|
+
A bento or mosaic layout is spans plus a row span. The canvas places columns;
|
|
120
|
+
`grid-row` on the region adds the height, as plain CSS Grid.
|
|
121
|
+
|
|
122
|
+
```html demo
|
|
123
|
+
<div class="column-layout">
|
|
124
|
+
<article class="card" style="--column-span: 6; grid-row: span 2">Featured — 6 columns, 2 rows</article>
|
|
125
|
+
<article class="card" style="--column-span: 6">6</article>
|
|
126
|
+
<article class="card" style="--column-span: 3">3</article>
|
|
127
|
+
<article class="card" style="--column-span: 3">3</article>
|
|
128
|
+
</div>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Give the tiles a class and recompose them in your container query like any
|
|
132
|
+
other region.
|
|
133
|
+
|
|
114
134
|
## The responsive contract
|
|
115
135
|
|
|
116
136
|
`.column-layout` has **no automatic collapse**. The canvas stays twelve columns
|
|
@@ -215,14 +235,8 @@ its track. Define a narrow representation where the composition needs one.
|
|
|
215
235
|
|
|
216
236
|
The primitive is horizontal only. There are no row, area, or order hooks, and no
|
|
217
237
|
breakpoint variants — those would move responsive strategy back into markup.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
```css
|
|
222
|
-
.dashboard-summary {
|
|
223
|
-
grid-row: 1 / span 2;
|
|
224
|
-
}
|
|
225
|
-
```
|
|
238
|
+
Row placement is plain CSS Grid on your own class, as in
|
|
239
|
+
[uneven feature grids](#uneven-feature-grids).
|
|
226
240
|
|
|
227
241
|
The column count is fixed at twelve and is not configurable. Twelve is what
|
|
228
242
|
makes the coordinates shared and lets `6 + 6`, `4 + 4 + 4`, `3 + 3 + 3 + 3`,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Sidebar Shell
|
|
2
|
+
|
|
3
|
+
> A persistent sidebar beside the main region on a wide screen, each scrolling on its own; a drawer on a phone.
|
|
4
|
+
|
|
5
|
+
**Related terms:** admin layout, dashboard shell, persistent sidebar, side navigation, app frame.
|
|
6
|
+
|
|
7
|
+
`.sidebar-shell` takes two direct children: an `aside`, the side region, and
|
|
8
|
+
one other element, the main region. From `64rem`, they sit side by side at the
|
|
9
|
+
height of the viewport and each scrolls on its own, so the sidebar stays put
|
|
10
|
+
while the content scrolls. Below `64rem`, the `aside` is hidden and the
|
|
11
|
+
document scrolls as any page does; the page offers the same navigation in a
|
|
12
|
+
[drawer](../components/drawer.md).
|
|
13
|
+
|
|
14
|
+
```html demo
|
|
15
|
+
<div class="sidebar-shell" style="--viewport-block: 14rem; --sidebar-shell-size: 12rem">
|
|
16
|
+
<aside class="stack" aria-label="Primary" style="padding: var(--space-40); border-inline-end: var(--border-width) solid var(--border)">
|
|
17
|
+
<strong>Product</strong>
|
|
18
|
+
<nav aria-label="Primary">
|
|
19
|
+
<ul class="nav-list">
|
|
20
|
+
<li><a class="nav-link" href="#overview" aria-current="page">Overview</a></li>
|
|
21
|
+
<li><a class="nav-link" href="#orders">Orders</a></li>
|
|
22
|
+
<li><a class="nav-link" href="#customers">Customers</a></li>
|
|
23
|
+
<li><a class="nav-link" href="#settings">Settings</a></li>
|
|
24
|
+
</ul>
|
|
25
|
+
</nav>
|
|
26
|
+
</aside>
|
|
27
|
+
<main class="stack" style="padding: var(--space-40)">
|
|
28
|
+
<h2>Overview</h2>
|
|
29
|
+
<p>The main region scrolls; the sidebar beside it does not move.</p>
|
|
30
|
+
<p>Orders, revenue and recent activity would follow here.</p>
|
|
31
|
+
<p>Keep scrolling: the content is taller than the shell.</p>
|
|
32
|
+
<p>The sidebar keeps its place.</p>
|
|
33
|
+
<p>Each region has its own scrollbar.</p>
|
|
34
|
+
<p>The page itself does not scroll.</p>
|
|
35
|
+
<p>End of the content.</p>
|
|
36
|
+
</main>
|
|
37
|
+
</div>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The demo sets `--viewport-block` to fit the page; an application leaves it to
|
|
41
|
+
the viewport. The `aside` keeps its own `display`, so `.stack` lays it out.
|
|
42
|
+
Put the topbar inside the main region: it then spans the content column only.
|
|
43
|
+
|
|
44
|
+
## Drawer on a phone
|
|
45
|
+
|
|
46
|
+
Keep the drawer outside the shell and open it from a button that only the
|
|
47
|
+
narrow layout shows. A drawer left open when the window widens past `64rem`
|
|
48
|
+
would sit over the sidebar it mirrors; close it from the page:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<script>
|
|
52
|
+
const wide = matchMedia("(width >= 64rem)");
|
|
53
|
+
wide.addEventListener("change", () => {
|
|
54
|
+
if (wide.matches) document.getElementById("main-drawer").close();
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
[App](../../demo/templates/app.html) composes the shell, its drawer and this
|
|
60
|
+
script.
|
|
61
|
+
|
|
62
|
+
## Hooks
|
|
63
|
+
|
|
64
|
+
- `--sidebar-shell-size` — width of the side region.
|
|
65
|
+
|
|
66
|
+
The breakpoint is a literal `64rem`: a custom property cannot sit in a media
|
|
67
|
+
condition. For another breakpoint, copy the two media rules of
|
|
68
|
+
`sidebar-shell.css` into the application.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Empty state
|
|
2
|
+
|
|
3
|
+
> A region with nothing to show yet: a first-run list, a cleared inbox, a
|
|
4
|
+
> search with no results. Composed from layout primitives; there is no
|
|
5
|
+
> empty-state component.
|
|
6
|
+
|
|
7
|
+
**Related terms:** blank slate, zero state, no data, no results, first run,
|
|
8
|
+
placeholder content.
|
|
9
|
+
|
|
10
|
+
## Anatomy
|
|
11
|
+
|
|
12
|
+
- An icon, decorative, with `aria-hidden="true"`.
|
|
13
|
+
- A heading at the level the page outline calls for: `<h2>` under the page
|
|
14
|
+
title, `<h3>` inside a section. Pick the level for the outline and the size
|
|
15
|
+
with a class, never the other way round.
|
|
16
|
+
- One sentence saying what belongs here or how to get it.
|
|
17
|
+
- Optional actions, the first one the way out.
|
|
18
|
+
|
|
19
|
+
```html demo
|
|
20
|
+
<section class="stack items-center text-center"
|
|
21
|
+
aria-labelledby="empty-views-title">
|
|
22
|
+
<i class="ti ti-layout-dashboard muted"
|
|
23
|
+
aria-hidden="true"
|
|
24
|
+
style="font-size: 2.5rem"></i>
|
|
25
|
+
<hgroup>
|
|
26
|
+
<h3 id="empty-views-title">No saved views yet</h3>
|
|
27
|
+
<p class="muted">Save a filtered view to come back to this work faster.</p>
|
|
28
|
+
</hgroup>
|
|
29
|
+
<menu class="cluster">
|
|
30
|
+
<li><button class="btn primary" type="button">Save current view</button></li>
|
|
31
|
+
<li><button class="btn ghost" type="button">Clear filters</button></li>
|
|
32
|
+
</menu>
|
|
33
|
+
</section>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For an icon on a tinted disc, compose an [icon slot](icon-slot.md).
|
|
37
|
+
|
|
38
|
+
## No results
|
|
39
|
+
|
|
40
|
+
An empty search names the query and offers to clear it. Clearing removes the
|
|
41
|
+
empty state and the button with it, so move focus back to the search field;
|
|
42
|
+
otherwise it falls to the page.
|
|
43
|
+
|
|
44
|
+
```html demo
|
|
45
|
+
<div class="stack">
|
|
46
|
+
<div class="field">
|
|
47
|
+
<label class="field-label" for="member-search">Search members</label>
|
|
48
|
+
<input class="input" type="search" id="member-search" value="zebra">
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<section class="stack items-center text-center"
|
|
52
|
+
id="no-results"
|
|
53
|
+
aria-labelledby="no-results-title">
|
|
54
|
+
<hgroup>
|
|
55
|
+
<h3 id="no-results-title">No members match “zebra”</h3>
|
|
56
|
+
<p class="muted">Check the spelling, or clear the search to see everyone.</p>
|
|
57
|
+
</hgroup>
|
|
58
|
+
<button class="btn outline" type="button" id="clear-member-search">
|
|
59
|
+
Clear search
|
|
60
|
+
</button>
|
|
61
|
+
</section>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<script>
|
|
65
|
+
const search = document.getElementById("member-search");
|
|
66
|
+
const noResults = document.getElementById("no-results");
|
|
67
|
+
|
|
68
|
+
document.getElementById("clear-member-search").addEventListener("click", () => {
|
|
69
|
+
search.value = "";
|
|
70
|
+
noResults.hidden = true;
|
|
71
|
+
search.focus();
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
@@ -2,25 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
App shell with a collapsible nav tree. Uses existing primitives only — no treeview component.
|
|
4
4
|
|
|
5
|
+
**Related terms:** collapsible sidebar, nav group, sub-navigation, nested menu, expandable section, sidebar tree.
|
|
6
|
+
|
|
5
7
|
```html demo
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
</
|
|
8
|
+
<nav class="scroller" data-enhance="scrollspy" aria-label="Docs">
|
|
9
|
+
<span class="overline">Documentation</span>
|
|
10
|
+
<ul class="nav-list">
|
|
11
|
+
<li>
|
|
12
|
+
<details open>
|
|
13
|
+
<summary class="nav-link">
|
|
14
|
+
<i class="ti ti-rocket" aria-hidden="true"></i> Getting started
|
|
15
|
+
</summary>
|
|
16
|
+
<ul class="nav-list">
|
|
17
|
+
<li><a class="nav-link" href="#intro">Introduction</a></li>
|
|
18
|
+
<li><a class="nav-link" href="#install">Installation</a></li>
|
|
19
|
+
</ul>
|
|
20
|
+
</details>
|
|
21
|
+
</li>
|
|
22
|
+
<li>
|
|
23
|
+
<details>
|
|
24
|
+
<summary class="nav-link">
|
|
25
|
+
<i class="ti ti-box" aria-hidden="true"></i> Components
|
|
26
|
+
</summary>
|
|
27
|
+
<ul class="nav-list">
|
|
28
|
+
<li><a class="nav-link" href="#alert">Alert</a></li>
|
|
29
|
+
<li><a class="nav-link" href="#badge">Badge</a></li>
|
|
30
|
+
</ul>
|
|
31
|
+
</details>
|
|
32
|
+
</li>
|
|
33
|
+
</ul>
|
|
34
|
+
</nav>
|
|
20
35
|
```
|
|
21
36
|
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
37
|
+
- A group is a `<details>` inside a row `<li>`, never a direct child of the
|
|
38
|
+
`<ul>`. Its `<summary class="nav-link">` takes the row, hover and focus, and
|
|
39
|
+
a chevron that follows the native `[open]` state.
|
|
40
|
+
- The group's links are a nested `.nav-list`, indented so its labels start
|
|
41
|
+
under the parent label past a 1em icon. Set `--nav-list-indent` on the nav
|
|
42
|
+
when the icons are larger.
|
|
43
|
+
- `.overline` labels a section of the nav.
|
|
44
|
+
- `<details name="…">` makes the groups an exclusive accordion, without
|
|
45
|
+
JavaScript.
|
|
46
|
+
- `data-enhance="scrollspy"` sets `aria-current="location"` while the page
|
|
47
|
+
scrolls; `.scroller` gives the nav a thin, theme-aware scrollbar.
|
|
@@ -91,66 +91,9 @@ A project may add `.site-header` when it needs a visual shell.
|
|
|
91
91
|
|
|
92
92
|
### App Shell With Sidebar
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<div class="shell-sidebar">
|
|
98
|
-
<aside class="shell-sidebar-nav" aria-label="Primary">
|
|
99
|
-
<a class="navbar-brand" href="#"><span class="avatar primary"><abbr>AC</abbr></span> Product</a>
|
|
100
|
-
<nav aria-label="Primary">
|
|
101
|
-
<ul class="nav-list">
|
|
102
|
-
<li><a class="nav-link" href="#" aria-current="page">Overview</a></li>
|
|
103
|
-
<li><a class="nav-link" href="#">Settings</a></li>
|
|
104
|
-
</ul>
|
|
105
|
-
</nav>
|
|
106
|
-
</aside>
|
|
107
|
-
|
|
108
|
-
<div class="shell-sidebar-main">
|
|
109
|
-
<header class="topbar">...</header>
|
|
110
|
-
<main class="center">...</main>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
```css
|
|
116
|
-
.shell-sidebar {
|
|
117
|
-
display: grid;
|
|
118
|
-
grid-template-columns: 1fr;
|
|
119
|
-
min-block-size: var(--viewport-block);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.shell-sidebar-nav {
|
|
123
|
-
display: none;
|
|
124
|
-
flex-direction: column;
|
|
125
|
-
gap: var(--gap);
|
|
126
|
-
inline-size: var(--shell-sidebar-size, 16rem);
|
|
127
|
-
padding: var(--space-40);
|
|
128
|
-
border-inline-end: var(--border-width) solid var(--border);
|
|
129
|
-
background: var(--surface-raised);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.shell-sidebar-main {
|
|
133
|
-
min-inline-size: 0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@media (min-width: 64rem) {
|
|
137
|
-
.shell-sidebar {
|
|
138
|
-
grid-template-columns: auto minmax(0, 1fr);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.shell-sidebar-nav {
|
|
142
|
-
display: flex;
|
|
143
|
-
position: sticky;
|
|
144
|
-
inset-block-start: 0;
|
|
145
|
-
block-size: var(--viewport-block);
|
|
146
|
-
overflow-y: auto;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
The sidebar width is the one tunable a project reaches for often, so it is exposed as `--shell-sidebar-size` rather than hard-coded — override it locally (`style="--shell-sidebar-size: 18rem"` or in a project stylesheet) instead of forking the rule. The breakpoint stays a literal `64rem` in the media query: custom properties cannot be substituted into a media condition, so a project that genuinely needs a different one copies the rule rather than fighting the token.
|
|
152
|
-
|
|
153
|
-
Below the breakpoint, mirror the sidebar into a `.drawer` (see Components Drawer) for mobile access — the two are separate elements, not a responsive transform of one.
|
|
94
|
+
A persistent sidebar beside the content — a dashboard, an admin panel — is
|
|
95
|
+
[`.sidebar-shell`](../layout/sidebar-shell.md): side by side from `64rem`, each
|
|
96
|
+
region scrolling on its own, and a drawer on a phone.
|
|
154
97
|
|
|
155
98
|
### Side Navigation
|
|
156
99
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Stat
|
|
2
|
+
|
|
3
|
+
> One figure with its label, a detail line and an optional trend: KPI tiles,
|
|
4
|
+
> dashboard summaries, metric cards. Composed from a card, a grid and a badge;
|
|
5
|
+
> there is no stat component.
|
|
6
|
+
|
|
7
|
+
**Related terms:** KPI, metric, statistic, figure, stat card, number tile,
|
|
8
|
+
delta, trend indicator.
|
|
9
|
+
|
|
10
|
+
## Anatomy
|
|
11
|
+
|
|
12
|
+
- A label.
|
|
13
|
+
- The value, in a `<data value>` when it is a formatted number.
|
|
14
|
+
- A detail line: the period, a target, a comparison.
|
|
15
|
+
- An optional trend: a badge whose sign states the direction, so it reads
|
|
16
|
+
without color. Use the minus sign `−`, which screen readers announce.
|
|
17
|
+
|
|
18
|
+
Keep the label first in source order, so each tile reads as one sentence.
|
|
19
|
+
`.grid` wraps the tiles as the width allows.
|
|
20
|
+
|
|
21
|
+
```html demo resize
|
|
22
|
+
<div class="grid" style="--grid-min: 12rem">
|
|
23
|
+
<div class="card stack">
|
|
24
|
+
<span class="muted">Revenue</span>
|
|
25
|
+
<data class="text-title" value="48902">$48,902</data>
|
|
26
|
+
<p class="cluster">
|
|
27
|
+
<span class="badge success soft">+12.4%</span>
|
|
28
|
+
<span class="muted">vs. last month</span>
|
|
29
|
+
</p>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="card stack">
|
|
33
|
+
<span class="muted">Active users</span>
|
|
34
|
+
<data class="text-title" value="1284">1,284</data>
|
|
35
|
+
<p class="cluster">
|
|
36
|
+
<span class="badge danger soft">−3.1%</span>
|
|
37
|
+
<span class="muted">vs. last month</span>
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="card stack">
|
|
42
|
+
<span class="muted">Churn</span>
|
|
43
|
+
<data class="text-title" value="0.009">0.9%</data>
|
|
44
|
+
<p class="cluster">
|
|
45
|
+
<span class="badge success soft">−0.3 pts</span>
|
|
46
|
+
<span class="muted">lower is better</span>
|
|
47
|
+
</p>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Inverted trends
|
|
53
|
+
|
|
54
|
+
When lower is better — churn, response time, open incidents — the sign keeps
|
|
55
|
+
following the number and the intent follows the outcome: a fall is `−` and
|
|
56
|
+
`success`. Say so in the detail line, as the Churn tile does, so the color is
|
|
57
|
+
never the only cue.
|
|
58
|
+
|
|
59
|
+
Promote the stat to a component only when the same markup is hand-rolled
|
|
60
|
+
across a product; until then, a local class on the card carries any
|
|
61
|
+
product-specific type or spacing.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Text hidden visually but still available to assistive technology.
|
|
4
4
|
|
|
5
|
+
**Related terms:** visually hidden, screen-reader text, hide label on mobile,
|
|
6
|
+
icon-only on small screens.
|
|
7
|
+
|
|
5
8
|
## Class reference
|
|
6
9
|
|
|
7
10
|
| Class | Kind | Description |
|
|
@@ -19,20 +22,39 @@ Use `.sr-only` for text that should be available to assistive technology but vis
|
|
|
19
22
|
</button>
|
|
20
23
|
```
|
|
21
24
|
|
|
25
|
+
### Hidden on narrow screens only
|
|
26
|
+
|
|
27
|
+
A toolbar label that shows beside its icon on wide screens and stays only as
|
|
28
|
+
the accessible name on narrow ones. `.sr-only` has no responsive variant:
|
|
29
|
+
repeat its declarations in your own query. Never use `display: none`, which
|
|
30
|
+
removes the name too.
|
|
31
|
+
|
|
22
32
|
```css
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
@media (width < 48rem) {
|
|
34
|
+
.toolbar-label {
|
|
35
|
+
position: absolute;
|
|
36
|
+
inline-size: 1px;
|
|
37
|
+
block-size: 1px;
|
|
38
|
+
margin: -1px;
|
|
39
|
+
padding: 0;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
clip-path: inset(50%);
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
border: 0;
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
```
|
|
35
47
|
|
|
48
|
+
```html
|
|
49
|
+
<button class="btn ghost" type="button">
|
|
50
|
+
<i class="ti ti-download" aria-hidden="true"></i>
|
|
51
|
+
<span class="toolbar-label">Export</span>
|
|
52
|
+
</button>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The hidden text is positioned absolutely, so give it a positioned ancestor
|
|
56
|
+
inside any scroll container, as `.table-wrap` does.
|
|
57
|
+
|
|
36
58
|
## Touch targets
|
|
37
59
|
|
|
38
60
|
`.touch-target` adds 8px of invisible hit area around a small control on coarse
|