@voidable/theme 0.6.0 → 0.8.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/README.md +133 -8
- package/package.json +66 -8
- package/src/app-shell/detail.css +7 -5
- package/src/app-shell/subtable.css +7 -6
- package/src/base.css +28 -0
- package/src/components/accordion.css +96 -19
- package/src/components/action-input.css +51 -61
- package/src/components/alert.css +63 -23
- package/src/components/avatar.css +0 -2
- package/src/components/badge.css +35 -25
- package/src/components/banner.css +60 -19
- package/src/components/bar-chart.css +75 -0
- package/src/components/breadcrumbs.css +20 -16
- package/src/components/button.css +130 -55
- package/src/components/calendar.css +40 -17
- package/src/components/card.css +122 -23
- package/src/components/carousel.css +85 -118
- package/src/components/checkbox-group.css +3 -1
- package/src/components/checkbox.css +18 -23
- package/src/components/collapsible.css +95 -29
- package/src/components/color-picker.css +10 -10
- package/src/components/combobox.css +47 -29
- package/src/components/compose-input.css +3 -3
- package/src/components/dialog.css +115 -41
- package/src/components/divider.css +7 -4
- package/src/components/donut-chart.css +105 -0
- package/src/components/drawer.css +135 -68
- package/src/components/dropdown-menu.css +21 -43
- package/src/components/editable.css +7 -7
- package/src/components/error-fallback.css +48 -27
- package/src/components/field.css +12 -5
- package/src/components/file-upload.css +2 -1
- package/src/components/gauge.css +194 -0
- package/src/components/hamburger.css +10 -10
- package/src/components/hover-card.css +13 -113
- package/src/components/indicator.css +22 -18
- package/src/components/input.css +15 -12
- package/src/components/line-chart.css +137 -0
- package/src/components/list.css +28 -7
- package/src/components/menu.css +48 -33
- package/src/components/multiselect.css +57 -40
- package/src/components/nav-bar.css +23 -14
- package/src/components/nav-menu.css +31 -22
- package/src/components/number-input.css +85 -62
- package/src/components/overlay.css +215 -0
- package/src/components/pagination.css +42 -31
- package/src/components/panel.css +37 -11
- package/src/components/pin-input.css +23 -22
- package/src/components/popover.css +19 -35
- package/src/components/progress.css +19 -10
- package/src/components/radio-group.css +2 -1
- package/src/components/radio.css +15 -20
- package/src/components/scroll-area.css +3 -3
- package/src/components/segmented-control.css +46 -29
- package/src/components/select.css +99 -31
- package/src/components/sidebar.css +8 -4
- package/src/components/skeleton.css +8 -3
- package/src/components/slider.css +4 -2
- package/src/components/spinner.css +5 -4
- package/src/components/stat.css +59 -52
- package/src/components/status-dot.css +0 -1
- package/src/components/switch.css +18 -26
- package/src/components/table.css +443 -16
- package/src/components/tabs.css +92 -29
- package/src/components/tag.css +44 -20
- package/src/components/tags-input.css +43 -55
- package/src/components/textarea.css +15 -12
- package/src/components/toast.css +84 -22
- package/src/components/toggle.css +35 -42
- package/src/components/tooltip.css +19 -38
- package/src/core.css +98 -0
- package/src/forced-colors.css +134 -0
- package/src/index.css +4 -71
- package/src/knobs.css +101 -0
- package/src/layers.css +38 -0
- package/src/media/media.css +258 -0
- package/src/media/surface.css +143 -0
- package/src/patterns/data.css +461 -0
- package/src/patterns/page.css +348 -0
- package/src/patterns/shell.css +371 -0
- package/src/pre-upgrade.css +202 -0
- package/src/primitives.css +44 -71
- package/src/reset.css +45 -21
- package/src/skins/loft.css +114 -0
- package/src/skins/slab.css +107 -0
- package/src/themes/aurora.css +16 -0
- package/src/themes/capsule.css +16 -0
- package/src/themes/console.css +16 -0
- package/src/themes/dune.css +16 -0
- package/src/themes/iris.css +16 -0
- package/src/themes/orbit.css +16 -0
- package/src/themes/paper.css +18 -0
- package/src/themes/void.css +16 -0
- package/src/tokens.css +552 -98
- package/src/type.css +103 -0
package/README.md
CHANGED
|
@@ -10,32 +10,157 @@ npm install @voidable/theme
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
Import the full theme (
|
|
13
|
+
Import the full theme (tokens, scoped reset, and all component styles):
|
|
14
14
|
|
|
15
15
|
```css
|
|
16
16
|
@import '@voidable/theme';
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Or import
|
|
19
|
+
Or import parts of it, or one component at a time (always with the tokens):
|
|
20
20
|
|
|
21
21
|
```css
|
|
22
|
-
@import '@voidable/theme/primitives';
|
|
23
22
|
@import '@voidable/theme/tokens';
|
|
24
|
-
@import '@voidable/theme/
|
|
23
|
+
@import '@voidable/theme/base'; /* html and body; in the full theme already */
|
|
24
|
+
@import '@voidable/theme/components/button.css';
|
|
25
|
+
@import '@voidable/theme/patterns/page.css';
|
|
25
26
|
```
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
Without a bundler, link the built file directly:
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
```html
|
|
31
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@voidable/theme/dist/void.min.css" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Everything is in named cascade layers (`components.void.reset`, `components.void.tokens`, `components.void.components` and so on), so an unlayered rule in your app overrides the theme without `!important`. See Theming on the docs site.
|
|
35
|
+
|
|
36
|
+
In a JavaScript entry point processed by a bundler (for example Vite), `import '@voidable/theme';` also works.
|
|
37
|
+
|
|
38
|
+
## Before components load
|
|
39
|
+
|
|
40
|
+
Until a component's script has loaded, its tag is an unknown element and the page can flash or jump. `src/pre-upgrade.css`, part of the main entry, styles the not-yet-defined state with `:not(:defined)` rules: closed overlays, inactive tab panels and option lists stay hidden, and the space of inputs, selects, tab lists and similar is reserved. The rules stop applying when the element is defined. See [Loading components](https://voidable.dev/getting-started/loading/#before-a-component-loads).
|
|
41
|
+
|
|
42
|
+
## Dark and light
|
|
43
|
+
|
|
44
|
+
There is no fixed default scheme. With no `data-theme`, the page follows the operating system (`prefers-color-scheme`; dark where the browser cannot say), unless a theme or skin states a preferred scheme (Loft and Slab prefer light), which then wins over the operating system. Set the `data-theme` attribute on `<html>`, or on any element, to choose a scheme explicitly: `dark` or `light` always win, and `system` follows the operating system even over a theme or skin's preference. Dark is a true black page, light a true white one.
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<html data-theme="light">
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Retheming: the knobs
|
|
51
|
+
|
|
52
|
+
The whole theme is derived from about a dozen inputs, in plain CSS, in both colour schemes. To retheme, set knobs; do not edit individual tokens.
|
|
53
|
+
|
|
54
|
+
```css
|
|
55
|
+
:root {
|
|
56
|
+
--void-accent-hue: 250; /* OKLCH hue in degrees */
|
|
57
|
+
--void-accent-chroma: 0.16; /* 0 = monochrome (default) */
|
|
58
|
+
--void-radius: 8px;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
| Knob | Default | Changes |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| `--void-accent-hue`, `--void-accent-chroma` | `250`, `0` | Accent colour. Chroma 0 is no accent: primary actions are the inverse of the page |
|
|
65
|
+
| `--void-neutral-hue`, `--void-neutral-chroma` | `60`, `0.004` | Tint of text, borders and surfaces |
|
|
66
|
+
| `--void-page-tint` | `0` | 0 is a pure black or white page; 1 is a soft, tinted page |
|
|
67
|
+
| `--void-contrast` | `0.2` | Strength of secondary text and control borders, 0 to 1. Never below WCAG AA |
|
|
68
|
+
| `--void-chrome` | `0.3` | Strength of divider lines and container fills, 0 to 1 |
|
|
69
|
+
| `--void-radius` | `4px` | Corner radius of a control; other radii scale from it |
|
|
70
|
+
| `--void-density` | `1` | Control height (36px at 1), padding and the spacing scale |
|
|
71
|
+
| `--void-rhythm` | `1` | Space between groups and sections |
|
|
72
|
+
| `--void-font-size` | `0.875rem` | Body text size; other sizes scale from it |
|
|
73
|
+
| `--void-font-sans`, `--void-font-mono` | Inter, JetBrains Mono | Typefaces (no font files are shipped) |
|
|
74
|
+
| `--void-anim-scale` | `1` | Multiplies every duration; 0 is off |
|
|
75
|
+
|
|
76
|
+
They are documented in full in [`src/knobs.css`](./src/knobs.css).
|
|
77
|
+
|
|
78
|
+
### Themes
|
|
79
|
+
|
|
80
|
+
Turn them on a real application in the [theme builder](https://voidable.dev/theme/) and copy the result. A link to the builder is a theme: every knob is a query parameter named after it without `--void-` (`https://voidable.dev/theme/?accent-hue=162&accent-chroma=0.19&radius=8`).
|
|
81
|
+
|
|
82
|
+
A theme is a file that sets knobs and nothing else. Eight ship, each about a dozen lines: `void` (the default), `dune` (warm, rounded, comfortable), `console` (dense, sharp, monospace), `orbit` (monochrome, very airy), `capsule` (pill controls), `aurora` (a vivid green accent), `iris` (violet, on a tinted page) and `paper` (a serif, editorial).
|
|
83
|
+
|
|
84
|
+
### Skins
|
|
85
|
+
|
|
86
|
+
A skin changes structure, which knobs cannot. It is one rule of token assignments and combines with any theme and any knobs. Two ship: `loft` is soft and elevated (a tinted page, white cards with shadows, no hairlines); `slab` is dense, square and ruled (heavy ink lines, framed boxes with hard offset shadows, an inverted current link). Both prefer the light scheme; `data-theme` still decides when it is set.
|
|
87
|
+
|
|
88
|
+
```css
|
|
89
|
+
@import '@voidable/theme';
|
|
90
|
+
@import '@voidable/theme/skins/loft.css';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```html
|
|
94
|
+
<html data-void-skin="loft">
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
To write your own, see [Build a skin](https://voidable.dev/getting-started/skins/): one `[data-void-skin="mine"] { … }` rule, expanded for nested regions with `expandSkin()` from `@voidable/theme/skin`.
|
|
98
|
+
|
|
99
|
+
### Component tokens
|
|
100
|
+
|
|
101
|
+
Below the knobs and the derived semantic tokens sit **component tokens**: per-component override points named `--void-<component>-<part?>-<property>-<state?>`, each defaulting to a semantic or role token. The theme never declares them, so one declaration wins anywhere, with no `!important`:
|
|
102
|
+
|
|
103
|
+
```css
|
|
104
|
+
:root { --void-card-shadow: var(--void-shadow-sm); } /* every card */
|
|
105
|
+
.billing { --void-card-radius: 0; } /* the cards of one region */
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Role tokens restyle a whole kind of component: `--void-container-*`, `--void-float-*`, `--void-control-*`, `--void-field-*`, `--void-item-*-selected` and the `--void-rule*` lines. The full list with defaults is in the [theming guide](https://voidable.dev/getting-started/theming/#component-token-reference) and in `@voidable/theme/component-tokens.json`.
|
|
109
|
+
|
|
110
|
+
### Tokens as data
|
|
111
|
+
|
|
112
|
+
Every token, resolved for each theme and skin in both colour schemes, for tools that cannot run CSS:
|
|
113
|
+
|
|
114
|
+
| Import | Contents |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `@voidable/theme/dtcg/<theme>.<scheme>.tokens.json` | [Design Tokens Community Group](https://www.designtokens.org/TR/2025.10/format/) format, Format Module 2025.10 (Tokens Studio, Style Dictionary) |
|
|
117
|
+
| `@voidable/theme/dtcg/voidable.resolver.json` | A DTCG resolver document listing those files |
|
|
118
|
+
| `@voidable/theme/json/<theme>.<scheme>.json` | `{ "--void-color-bg": "#000000", ... }`: custom property to resolved CSS value |
|
|
119
|
+
| `@voidable/theme/knobs.json` | The knobs as data: range, step, unit, default, description, and each shipped theme's values |
|
|
120
|
+
| `@voidable/theme/component-tokens.json` | Component tokens grouped by component (name, default, what it styles), the role tokens and the naming vocabulary |
|
|
121
|
+
| `@voidable/theme/names` | `tokenNames`, `roleTokenNames`, `componentTokenNames`, `componentTokens`, `knobNames`, `themeNames`, `skinNames`, `cssVar()`, and the types `TokenName`, `RoleTokenName`, `ComponentTokenName`, `KnobName`, `ThemeName`, `SkinName` |
|
|
122
|
+
| `@voidable/theme/skin` | `expandSkin(css, name)`: a skin source written out for every scope of the theme |
|
|
123
|
+
|
|
124
|
+
`<theme>` is a theme or skin name, `<scheme>` is `dark` or `light`: `@voidable/theme/dtcg/dune.light.tokens.json`. The values are computed at build time and tested to equal what Chromium computes from the CSS.
|
|
125
|
+
|
|
126
|
+
```css
|
|
127
|
+
@import '@voidable/theme';
|
|
128
|
+
@import '@voidable/theme/themes/dune.css';
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<html data-void-theme="dune">
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Part of a page
|
|
136
|
+
|
|
137
|
+
Knobs take effect on `:root` and on any element that carries `data-void-theme` (named or empty):
|
|
138
|
+
|
|
139
|
+
```html
|
|
140
|
+
<section data-void-theme style="--void-radius: 0px">…</section>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
A knob set on an element without that attribute changes nothing below it, because the derived tokens are only recomputed on `:root`, `[data-theme]`, `[data-void-theme]` and `[data-shape]`.
|
|
144
|
+
|
|
145
|
+
### Type roles
|
|
146
|
+
|
|
147
|
+
`data-void-type` applies a named text role: `label`, `value`, `unit`, `caption`, `heading`, `title`, `display`, `lede`, `body`, `code`. Components use the same `--void-type-<role>-*` tokens, so restyling a role restyles it everywhere.
|
|
30
148
|
|
|
31
149
|
```html
|
|
32
|
-
<
|
|
150
|
+
<span data-void-type="label">Uptime</span>
|
|
151
|
+
<span data-void-type="value">99.98</span> <span data-void-type="unit">%</span>
|
|
33
152
|
```
|
|
34
153
|
|
|
154
|
+
### Browser support
|
|
155
|
+
|
|
156
|
+
`oklch()`, `color-mix()` and `calc()` inside both: Chrome 111, Firefox 113, Safari 16.2.
|
|
157
|
+
|
|
35
158
|
## Documentation
|
|
36
159
|
|
|
37
|
-
- [
|
|
160
|
+
- [Docs](https://voidable.dev)
|
|
161
|
+
- [Storybook](https://voidable.dev/storybook/)
|
|
38
162
|
- [GitHub](https://github.com/VoidableUI/Voidable)
|
|
163
|
+
- [npm](https://www.npmjs.com/package/@voidable/theme)
|
|
39
164
|
|
|
40
165
|
## License
|
|
41
166
|
|
package/package.json
CHANGED
|
@@ -1,20 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidable/theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "CSS custom properties, design tokens, reset and component styles for Voidable UI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"css",
|
|
7
|
+
"design-tokens",
|
|
8
|
+
"theme",
|
|
9
|
+
"custom-properties",
|
|
10
|
+
"dark-mode",
|
|
11
|
+
"design-system",
|
|
12
|
+
"void-ui"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://voidable.dev",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/VoidableUI/Voidable/issues"
|
|
17
|
+
},
|
|
4
18
|
"type": "module",
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"*.css"
|
|
21
|
+
],
|
|
5
22
|
"license": "MIT",
|
|
23
|
+
"style": "./dist/void.css",
|
|
6
24
|
"exports": {
|
|
7
|
-
".":
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
25
|
+
".": {
|
|
26
|
+
"style": "./dist/void.css",
|
|
27
|
+
"default": "./dist/void.css"
|
|
28
|
+
},
|
|
29
|
+
"./core": "./dist/core.css",
|
|
30
|
+
"./tokens": "./dist/tokens.css",
|
|
31
|
+
"./base": "./dist/base.css",
|
|
32
|
+
"./layers": "./dist/layers.css",
|
|
33
|
+
"./primitives": "./dist/primitives.css",
|
|
34
|
+
"./knobs": "./dist/knobs.css",
|
|
35
|
+
"./reset": "./dist/reset.css",
|
|
36
|
+
"./type": "./dist/type.css",
|
|
37
|
+
"./components/*": "./dist/components/*",
|
|
38
|
+
"./patterns/*": "./dist/patterns/*",
|
|
39
|
+
"./themes/*": "./dist/themes/*",
|
|
40
|
+
"./dist/*": "./dist/*",
|
|
41
|
+
"./src/*": "./src/*",
|
|
42
|
+
"./skins/*": "./dist/skins/*",
|
|
43
|
+
"./dtcg/*": "./dist/dtcg/*",
|
|
44
|
+
"./json/*": "./dist/json/*",
|
|
45
|
+
"./knobs.json": "./dist/knobs.json",
|
|
46
|
+
"./component-tokens.json": "./dist/component-tokens.json",
|
|
47
|
+
"./skin": {
|
|
48
|
+
"types": "./dist/skin.d.ts",
|
|
49
|
+
"default": "./dist/skin.js"
|
|
50
|
+
},
|
|
51
|
+
"./names": {
|
|
52
|
+
"types": "./dist/names.d.ts",
|
|
53
|
+
"default": "./dist/names.js"
|
|
54
|
+
}
|
|
11
55
|
},
|
|
12
56
|
"files": [
|
|
13
|
-
"src"
|
|
57
|
+
"src",
|
|
58
|
+
"dist"
|
|
14
59
|
],
|
|
15
60
|
"repository": {
|
|
16
61
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/VoidableUI/Voidable",
|
|
62
|
+
"url": "git+https://github.com/VoidableUI/Voidable.git",
|
|
18
63
|
"directory": "packages/theme"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"lightningcss": "^1.32.0",
|
|
70
|
+
"postcss": "^8.5.12",
|
|
71
|
+
"postcss-selector-parser": "^6.1.2"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "node scripts/build.mjs && node scripts/export-tokens.mjs",
|
|
75
|
+
"test": "node --test \"test/*.test.mjs\"",
|
|
76
|
+
"generate": "node scripts/build.mjs --generated-only"
|
|
19
77
|
}
|
|
20
|
-
}
|
|
78
|
+
}
|
package/src/app-shell/detail.css
CHANGED
|
@@ -46,11 +46,13 @@
|
|
|
46
46
|
gap: var(--void-space-1);
|
|
47
47
|
}
|
|
48
48
|
.info-grid-label {
|
|
49
|
-
font-
|
|
50
|
-
font-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
font-family: var(--void-type-label-family);
|
|
50
|
+
font-size: var(--void-type-label-size);
|
|
51
|
+
line-height: var(--void-type-label-leading);
|
|
52
|
+
font-weight: var(--void-type-label-weight);
|
|
53
|
+
letter-spacing: var(--void-type-label-tracking);
|
|
54
|
+
text-transform: var(--void-type-label-case);
|
|
55
|
+
color: var(--void-type-label-color);
|
|
54
56
|
}
|
|
55
57
|
.info-grid-value {
|
|
56
58
|
font-size: var(--void-text-sm);
|
|
@@ -30,13 +30,14 @@
|
|
|
30
30
|
.subtable th {
|
|
31
31
|
text-align: left;
|
|
32
32
|
padding: var(--void-space-2) var(--void-space-3);
|
|
33
|
-
font-
|
|
34
|
-
font-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
font-family: var(--void-type-label-family);
|
|
34
|
+
font-size: var(--void-type-label-size);
|
|
35
|
+
line-height: var(--void-type-label-leading);
|
|
36
|
+
font-weight: var(--void-type-label-weight);
|
|
37
|
+
letter-spacing: var(--void-type-label-tracking);
|
|
38
|
+
text-transform: var(--void-type-label-case);
|
|
39
|
+
color: var(--void-type-label-color);
|
|
38
40
|
border-bottom: 1px solid var(--void-color-border);
|
|
39
|
-
font-weight: var(--void-weight-medium);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
.subtable td {
|
package/src/base.css
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* ============================================================
|
|
2
|
+
@voidable/theme — Base
|
|
3
|
+
The only styling the theme applies to the page itself rather than to
|
|
4
|
+
`void-*` elements and what is inside them: the colour scheme, the page
|
|
5
|
+
background and the default text of the document. Every other element
|
|
6
|
+
selector in the theme is scoped to the inside of a theme element
|
|
7
|
+
(reset.css), so the theme does not restyle an application's own markup.
|
|
8
|
+
|
|
9
|
+
Optional. `@voidable/theme` includes it; `@voidable/theme/core` leaves it
|
|
10
|
+
out, for an application that sets its own body and html. Without it, set
|
|
11
|
+
`color-scheme`, `background` and `color` on your own page.
|
|
12
|
+
============================================================ */
|
|
13
|
+
|
|
14
|
+
html {
|
|
15
|
+
color-scheme: var(--void-color-scheme);
|
|
16
|
+
-webkit-font-smoothing: antialiased;
|
|
17
|
+
-moz-osx-font-smoothing: grayscale;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
body {
|
|
21
|
+
margin: 0;
|
|
22
|
+
font-family: var(--void-type-body-family);
|
|
23
|
+
font-size: var(--void-type-body-size);
|
|
24
|
+
line-height: var(--void-type-body-leading);
|
|
25
|
+
font-weight: var(--void-type-body-weight);
|
|
26
|
+
color: var(--void-type-body-color);
|
|
27
|
+
background: var(--void-color-bg);
|
|
28
|
+
}
|
|
@@ -3,14 +3,30 @@ void-accordion {
|
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
/* Each item is a two-row grid, the trigger and then the content, and the
|
|
7
|
+
content row is 0fr closed and 1fr open: the row animates between them, so
|
|
8
|
+
content of any height opens and closes smoothly with no script measuring it
|
|
9
|
+
(animating grid rows is baseline widely available; where it is not, the
|
|
10
|
+
content just appears and disappears). */
|
|
6
11
|
void-accordion-item {
|
|
7
|
-
|
|
12
|
+
display: grid;
|
|
13
|
+
grid-template-rows: auto 0fr;
|
|
14
|
+
border-bottom: var(--void-rule-between);
|
|
15
|
+
transition: grid-template-rows var(--void-duration-normal) var(--void-ease-in-out);
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
void-accordion-item[open] {
|
|
19
|
+
grid-template-rows: auto 1fr;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* The trigger part is the button (role="button", a tab stop, written by the
|
|
23
|
+
item); the chevron is drawn here, so it shows before the script loads. */
|
|
24
|
+
void-accordion-trigger {
|
|
11
25
|
display: flex;
|
|
12
26
|
align-items: center;
|
|
13
27
|
justify-content: space-between;
|
|
28
|
+
gap: var(--void-space-2);
|
|
29
|
+
box-sizing: border-box;
|
|
14
30
|
width: 100%;
|
|
15
31
|
padding: var(--void-space-3) var(--void-space-4);
|
|
16
32
|
border: none;
|
|
@@ -21,38 +37,99 @@ void-accordion-item {
|
|
|
21
37
|
font-weight: var(--void-weight-medium);
|
|
22
38
|
text-align: left;
|
|
23
39
|
cursor: pointer;
|
|
40
|
+
user-select: none;
|
|
41
|
+
outline: none;
|
|
24
42
|
transition: background var(--void-duration-fast) var(--void-ease-in-out);
|
|
25
43
|
}
|
|
26
44
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.void-accordion-trigger:focus-visible {
|
|
32
|
-
outline: 2px solid var(--void-color-border);
|
|
33
|
-
outline-offset: -2px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.void-accordion-chevron {
|
|
45
|
+
void-accordion-trigger::after {
|
|
46
|
+
content: '';
|
|
37
47
|
width: 1rem;
|
|
38
48
|
height: 1rem;
|
|
39
49
|
flex-shrink: 0;
|
|
40
|
-
|
|
50
|
+
background: var(--void-color-text-secondary);
|
|
51
|
+
/* token-ok: the chevron's shape; its colour is the background token above */
|
|
52
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M6 4l4 4-4 4' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
41
53
|
transition: transform var(--void-duration-fast) var(--void-ease-in-out);
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
void-accordion-
|
|
56
|
+
void-accordion-trigger:hover {
|
|
57
|
+
background: var(--void-color-bg-hover);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void-accordion-trigger:focus-visible {
|
|
61
|
+
outline: var(--void-focus-ring-width) solid var(--void-focus-ring-color);
|
|
62
|
+
outline-offset: calc(var(--void-focus-ring-width) * -1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void-accordion-item[open] > void-accordion-trigger::after {
|
|
45
66
|
transform: rotate(90deg);
|
|
46
67
|
}
|
|
47
68
|
|
|
48
|
-
|
|
49
|
-
|
|
69
|
+
void-accordion-trigger {
|
|
70
|
+
grid-row: 1;
|
|
50
71
|
}
|
|
51
72
|
|
|
52
|
-
|
|
73
|
+
/* The content is the second row. Closed, its box is empty (no block padding,
|
|
74
|
+
which would keep the row open) and it is visibility:hidden, so it is out of
|
|
75
|
+
the accessibility tree, the tab order and find-in-page, all from the item's
|
|
76
|
+
own attribute and before any script loads. The visibility change waits for
|
|
77
|
+
the closing animation to finish and happens at once on opening. The item
|
|
78
|
+
then also marks closed content hidden="until-found" (see accordion.ts),
|
|
79
|
+
which keeps it hidden from assistive technology and lets find-in-page open
|
|
80
|
+
it where the browser supports that. Same mechanism as the collapsible. */
|
|
81
|
+
void-accordion-content {
|
|
82
|
+
grid-row: 2;
|
|
53
83
|
display: block;
|
|
54
|
-
|
|
84
|
+
min-height: 0;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
padding: 0 var(--void-space-4);
|
|
87
|
+
visibility: hidden;
|
|
55
88
|
color: var(--void-color-text);
|
|
56
89
|
font-family: var(--void-font-sans);
|
|
57
|
-
font-size: var(--void-
|
|
90
|
+
font-size: var(--void-type-body-size);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
void-accordion-item[open] > void-accordion-content {
|
|
94
|
+
padding-block: var(--void-space-3) var(--void-space-4);
|
|
95
|
+
visibility: visible;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* hidden="until-found" hides through content-visibility; find-in-page only
|
|
99
|
+
searches it when it is not also visibility:hidden. */
|
|
100
|
+
void-accordion-content[hidden="until-found"] {
|
|
101
|
+
visibility: visible;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Only once the element is defined: a page whose stylesheet arrives after the
|
|
105
|
+
first paint must not animate its open items into place. The visibility
|
|
106
|
+
change waits for the closing animation and happens at once on opening. */
|
|
107
|
+
void-accordion-item:defined {
|
|
108
|
+
transition: grid-template-rows var(--void-duration-normal) var(--void-ease-in-out);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void-accordion-item:defined > void-accordion-content {
|
|
112
|
+
transition: padding-block var(--void-duration-normal) var(--void-ease-in-out),
|
|
113
|
+
visibility 0s linear var(--void-duration-normal);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void-accordion-item[open]:defined > void-accordion-content {
|
|
117
|
+
transition: padding-block var(--void-duration-normal) var(--void-ease-in-out),
|
|
118
|
+
visibility 0s linear 0s;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* The until-found mark is put on once the content has closed; taking the delay
|
|
122
|
+
off here keeps visibility from lagging behind an opening that follows it. */
|
|
123
|
+
void-accordion-item:defined > void-accordion-content[hidden="until-found"] {
|
|
124
|
+
transition: padding-block var(--void-duration-normal) var(--void-ease-in-out),
|
|
125
|
+
visibility 0s linear 0s;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@media (prefers-reduced-motion: reduce) {
|
|
129
|
+
void-accordion-item:defined,
|
|
130
|
+
void-accordion-item:defined > void-accordion-content,
|
|
131
|
+
void-accordion-item:defined > void-accordion-content[hidden="until-found"],
|
|
132
|
+
void-accordion-item[open]:defined > void-accordion-content {
|
|
133
|
+
transition: none;
|
|
134
|
+
}
|
|
58
135
|
}
|