@uncinq/css-components 1.15.2 → 1.16.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 +63 -98
- package/css/components/card.css +7 -3
- package/css/components/drawer.css +2 -0
- package/css/components/items.css +6 -2
- package/css/components/modal.css +2 -0
- package/css/components/panel.css +15 -5
- package/css/utilities/scrollsnap.css +26 -3
- package/docs/_index.md +89 -0
- package/docs/buttons.md +102 -0
- package/docs/cascade-layers.md +74 -0
- package/docs/content.md +144 -0
- package/docs/embeds.md +65 -0
- package/docs/forms.md +79 -0
- package/docs/navigation.md +92 -0
- package/docs/overlays.md +132 -0
- package/docs/utilities.md +66 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,134 +1,99 @@
|
|
|
1
1
|
# @uncinq/css-components
|
|
2
2
|
|
|
3
|
-
> Framework-agnostic CSS component implementations
|
|
3
|
+
> Framework-agnostic CSS component implementations.
|
|
4
4
|
|
|
5
5
|
<img width="1280" height="640" alt="share-css-components" src="https://github.com/user-attachments/assets/3d74df8a-e7bf-4ba5-8529-99cfef0bc176" />
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
29 components and 1 utility, written as plain CSS, reading their values from [@uncinq/component-tokens](https://github.com/uncinq/component-tokens) and adding none of their own.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Where this sits
|
|
10
10
|
|
|
11
|
-
```
|
|
12
|
-
@uncinq/design-tokens
|
|
13
|
-
@uncinq/component-tokens
|
|
14
|
-
@uncinq/css-base
|
|
15
|
-
@uncinq/css-components ←
|
|
11
|
+
```
|
|
12
|
+
@uncinq/design-tokens primitive + semantic values
|
|
13
|
+
@uncinq/component-tokens component-scoped values
|
|
14
|
+
@uncinq/css-base reset, native elements, layouts
|
|
15
|
+
@uncinq/css-components ← this package
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
## Installation
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
All four packages are required. `@uncinq/css-base` is a genuine prerequisite but is **not** declared in `peerDependencies`, so install it explicitly.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
```bash
|
|
23
|
+
npm install @uncinq/design-tokens @uncinq/component-tokens @uncinq/css-base @uncinq/css-components
|
|
24
|
+
```
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
Declare the cascade layer order once at the top of your entry stylesheet, **before any import**:
|
|
25
27
|
|
|
26
28
|
```css
|
|
27
29
|
@layer reset, tokens, libs, vendors, base, layouts, components, pages, utilities;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
This means:
|
|
31
|
-
|
|
32
|
-
- Components never bleed into base or layout styles
|
|
33
|
-
- Project-level `@layer components` rules always win over these defaults
|
|
34
|
-
- Third-party stylesheets (`libs`, e.g. Splide) sit at the bottom, and the CSS
|
|
35
|
-
that overrides them (`vendors`) right above — so a lazily loaded library
|
|
36
|
-
cannot win on source order
|
|
37
|
-
- Utilities come last, so `.scrollsnap` wins over the grid a component declares for itself
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
@import '@uncinq/design-tokens'; /* @layer tokens */
|
|
32
|
+
@import '@uncinq/css-base'; /* @layer reset, base, layouts */
|
|
33
|
+
@import '@uncinq/component-tokens'; /* @layer tokens */
|
|
34
|
+
@import '@uncinq/css-components'; /* @layer components, utilities */
|
|
35
|
+
```
|
|
42
36
|
|
|
43
|
-
|
|
37
|
+
Per component:
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
```css
|
|
40
|
+
@import '@uncinq/css-components/css/components/button.css';
|
|
41
|
+
@import '@uncinq/css-components/css/utilities/scrollsnap.css';
|
|
42
|
+
```
|
|
48
43
|
|
|
49
|
-
|
|
44
|
+
Without a build step:
|
|
50
45
|
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
@import '@uncinq/component-tokens';
|
|
54
|
-
@import '@uncinq/css-base';
|
|
55
|
-
@import '@uncinq/css-components';
|
|
46
|
+
```html
|
|
47
|
+
<link rel="stylesheet" href="https://unpkg.com/@uncinq/css-components">
|
|
56
48
|
```
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
## What's included
|
|
59
51
|
|
|
60
|
-
|
|
52
|
+
| Group | Components |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| Buttons | `.btn` with colour, size and style variants, plus `btn-close`, `btn-menu`, `btn-search`, `btn-filter`, `btn-share`, `btn-toc`, `btn-toggle-video` |
|
|
55
|
+
| Overlays | `modal`, `drawer`, `dropdown`, and the shared panel skeleton |
|
|
56
|
+
| Content | `alert`, `badge`, `banner`, `card`, `items`, `list`, `media`, `surtitle` |
|
|
57
|
+
| Navigation | `nav`, `nav-title`, `nav-accessibility`, `breadcrumb`, `pagination` |
|
|
58
|
+
| Embeds | `embed`, `video`, `map` |
|
|
59
|
+
| Forms | `form`, `form-check` and the layout helpers |
|
|
60
|
+
| Utilities | `scrollsnap` |
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
npm install @uncinq/css-components
|
|
64
|
-
# or
|
|
65
|
-
yarn add @uncinq/css-components
|
|
66
|
-
```
|
|
62
|
+
## Two import-order rules
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
`components/panel.css` is imported **last** among the components: its `.panel-inline-*` variants beat `.modal` and `.drawer` on source order, because most of the file is `:where()`-wrapped and carries no specificity.
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
@import '@uncinq/design-tokens';
|
|
72
|
-
@import '@uncinq/component-tokens';
|
|
73
|
-
@import '@uncinq/css-base';
|
|
74
|
-
@import '@uncinq/css-components';
|
|
75
|
-
```
|
|
66
|
+
`utilities/scrollsnap.css` comes after everything, in `@layer utilities`, because it has to win over the grid a component declares for itself.
|
|
76
67
|
|
|
77
|
-
|
|
68
|
+
If you import file by file rather than using the barrel, preserve both positions.
|
|
78
69
|
|
|
79
|
-
|
|
80
|
-
@import '@uncinq/design-tokens';
|
|
81
|
-
@import '@uncinq/component-tokens';
|
|
82
|
-
@import '@uncinq/css-base';
|
|
83
|
-
@import '@uncinq/css-components/css/components/nav.css';
|
|
84
|
-
@import '@uncinq/css-components/css/components/pagination.css';
|
|
85
|
-
@import '@uncinq/css-components/css/utilities/scrollsnap.css';
|
|
86
|
-
```
|
|
70
|
+
## Not included
|
|
87
71
|
|
|
88
|
-
|
|
72
|
+
- **No JavaScript.** `modal`, `drawer` and `dropdown` expect a script; each documents the classes and attributes it must toggle.
|
|
73
|
+
- **No `.item`.** This package ships `.card`, a complete implementation. `.item` lives in the Hugolify design system theme.
|
|
74
|
+
- **No pagination glyphs.** The theme supplies them through `::before` or `::after` content.
|
|
89
75
|
|
|
90
|
-
|
|
91
|
-
<link rel="stylesheet" href="https://unpkg.com/@uncinq/design-tokens/tokens/index.css">
|
|
92
|
-
<link rel="stylesheet" href="https://unpkg.com/@uncinq/component-tokens/tokens/index.css">
|
|
93
|
-
<link rel="stylesheet" href="https://unpkg.com/@uncinq/css-base/css/index.css">
|
|
94
|
-
<link rel="stylesheet" href="https://unpkg.com/@uncinq/css-components/css/index.css">
|
|
95
|
-
```
|
|
76
|
+
## Documentation
|
|
96
77
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
## File structure
|
|
100
|
-
|
|
101
|
-
```text
|
|
102
|
-
css/
|
|
103
|
-
index.css ← imports all component and utility files
|
|
104
|
-
components/
|
|
105
|
-
alert.css ← alert / notification banner
|
|
106
|
-
badge.css ← badge / pill / tag
|
|
107
|
-
banner.css ← full-width banner strip
|
|
108
|
-
breadcrumb.css ← breadcrumb navigation
|
|
109
|
-
button.css ← button (all variants)
|
|
110
|
-
card.css ← card container
|
|
111
|
-
drawer.css ← off-canvas panel / drawer
|
|
112
|
-
dropdown.css ← dropdown menu
|
|
113
|
-
embed.css ← video / iframe embed wrapper
|
|
114
|
-
list.css ← styled list
|
|
115
|
-
map.css ← embedded map
|
|
116
|
-
media.css ← media object (image + text)
|
|
117
|
-
modal.css ← centered dialog / modal
|
|
118
|
-
nav.css ← navigation bar
|
|
119
|
-
nav-accessibility.css ← accessibility skip links / focus helpers
|
|
120
|
-
nav-title.css ← navigation bar title
|
|
121
|
-
pagination.css ← pagination control
|
|
122
|
-
video.css ← native video wrapper with its play/pause control
|
|
123
|
-
utilities/
|
|
124
|
-
scrollsnap.css ← .scrollsnap[-sm|-md|-lg|-xl] — turns a grid into a snapping carousel
|
|
125
|
-
```
|
|
78
|
+
Full documentation: **[socle.uncinq.dev/docs/css-components/](https://socle.uncinq.dev/docs/css-components/)**
|
|
126
79
|
|
|
127
|
-
|
|
80
|
+
It is also versioned with the code in [`docs/`](docs/), and ships inside the npm package, so it is readable offline and from `node_modules`:
|
|
81
|
+
|
|
82
|
+
- [Cascade layers](docs/cascade-layers.md) — the two layers, and the `:where()` convention
|
|
83
|
+
- [Buttons](docs/buttons.md)
|
|
84
|
+
- [Overlays](docs/overlays.md) — the panel skeleton and the JS contracts
|
|
85
|
+
- [Content](docs/content.md)
|
|
86
|
+
- [Navigation](docs/navigation.md)
|
|
87
|
+
- [Embeds](docs/embeds.md)
|
|
88
|
+
- [Forms](docs/forms.md)
|
|
89
|
+
- [Utilities](docs/utilities.md) — `.scrollsnap` and the bleed contract
|
|
128
90
|
|
|
129
91
|
## References
|
|
130
92
|
|
|
131
|
-
- [
|
|
132
|
-
- [
|
|
133
|
-
- [@uncinq/css-base](https://github.com/uncinq/css-base) — base CSS rules
|
|
93
|
+
- [`@uncinq/component-tokens`](https://github.com/uncinq/component-tokens) — the values these components read
|
|
94
|
+
- [`@uncinq/css-base`](https://github.com/uncinq/css-base) — the foundation underneath
|
|
134
95
|
- [MDN: CSS cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT © [Un Cinq](https://uncinq.dev/)
|
package/css/components/card.css
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/* components/card.css */
|
|
2
2
|
/*
|
|
3
|
-
* .card
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* .card — self-contained content card.
|
|
4
|
+
*
|
|
5
|
+
* Historically a backwards-compatible alias for .item, but .item is NOT
|
|
6
|
+
* defined in this package (it lives in the Hugolify design system theme).
|
|
7
|
+
* Within @uncinq/css-components, .card is the complete implementation and the
|
|
8
|
+
* class to use. It reads --card-* from @uncinq/component-tokens.
|
|
9
|
+
*
|
|
6
10
|
* Structure:
|
|
7
11
|
* <article class="card">
|
|
8
12
|
* <div class="content">
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
--panel-color-background: var(--drawer-color-background);
|
|
30
30
|
--panel-color-border: var(--drawer-color-border);
|
|
31
31
|
--panel-color-text: var(--drawer-color-text);
|
|
32
|
+
--panel-color-text-active: var(--drawer-color-text-active);
|
|
33
|
+
--panel-color-text-hover: var(--drawer-color-text-hover);
|
|
32
34
|
--panel-content-padding-block: var(--drawer-content-padding-block, var(--drawer-padding-block));
|
|
33
35
|
--panel-content-padding-inline: var(--drawer-content-padding-inline, var(--drawer-padding-inline));
|
|
34
36
|
--panel-footer-padding-block: var(--drawer-footer-padding-block, var(--drawer-padding-block));
|
package/css/components/items.css
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/* components/items.css */
|
|
2
2
|
/*
|
|
3
|
-
* .items — responsive grid.
|
|
3
|
+
* .items — responsive grid. Columns are intrinsic, not breakpoint-driven:
|
|
4
|
+
* children wrap once they no longer fit at --items-min-width.
|
|
5
|
+
*
|
|
6
|
+
* The children are yours to provide. Within this package that is .card;
|
|
7
|
+
* .item is defined by the Hugolify design system theme, not here.
|
|
4
8
|
*
|
|
5
9
|
* Structure:
|
|
6
10
|
* .items
|
|
7
|
-
* .item
|
|
11
|
+
* .card | .item | any child
|
|
8
12
|
*/
|
|
9
13
|
@layer components {
|
|
10
14
|
.items {
|
package/css/components/modal.css
CHANGED
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
--panel-color-background: var(--modal-color-background);
|
|
28
28
|
--panel-color-border: var(--modal-color-border);
|
|
29
29
|
--panel-color-text: var(--modal-color-text);
|
|
30
|
+
--panel-color-text-active: var(--modal-color-text-active);
|
|
31
|
+
--panel-color-text-hover: var(--modal-color-text-hover);
|
|
30
32
|
--panel-content-padding-block: var(--modal-content-padding-block, var(--modal-padding-block));
|
|
31
33
|
--panel-content-padding-inline: var(--modal-content-padding-inline, var(--modal-padding-inline));
|
|
32
34
|
--panel-footer-padding-block: var(--modal-footer-padding-block, var(--modal-padding-block));
|
package/css/components/panel.css
CHANGED
|
@@ -60,8 +60,10 @@
|
|
|
60
60
|
|
|
61
61
|
:where(.modal, .drawer) {
|
|
62
62
|
--color-link: var(--panel-color-text);
|
|
63
|
-
--color-link-
|
|
63
|
+
--color-link-active: var(--panel-color-text-active);
|
|
64
|
+
--color-link-hover: var(--panel-color-text-hover);
|
|
64
65
|
--nav-color-text: var(--color-link);
|
|
66
|
+
--nav-color-text-active: var(--color-link-active);
|
|
65
67
|
|
|
66
68
|
background-color: var(--panel-color-background);
|
|
67
69
|
border: 0;
|
|
@@ -167,13 +169,15 @@
|
|
|
167
169
|
of the panel's chrome and takes the page's own text and link colours.
|
|
168
170
|
`inherit` on a custom property hands it back to the parent, which is
|
|
169
171
|
exactly what is wanted here — and it has to be done token by token.
|
|
170
|
-
Resetting --panel-color-text
|
|
172
|
+
Resetting the --panel-color-text-* tokens they derive from would make
|
|
171
173
|
them invalid at computed-value time rather than page-valued, and every
|
|
172
174
|
link would fall back to the surrounding text colour instead of the
|
|
173
175
|
site's link colour. Keep this list in step with the panel rule above. */
|
|
174
176
|
--color-link: inherit;
|
|
177
|
+
--color-link-active: inherit;
|
|
175
178
|
--color-link-hover: inherit;
|
|
176
179
|
--nav-color-text: inherit;
|
|
180
|
+
--nav-color-text-active: inherit;
|
|
177
181
|
|
|
178
182
|
background-color: transparent;
|
|
179
183
|
block-size: auto;
|
|
@@ -214,13 +218,15 @@
|
|
|
214
218
|
of the panel's chrome and takes the page's own text and link colours.
|
|
215
219
|
`inherit` on a custom property hands it back to the parent, which is
|
|
216
220
|
exactly what is wanted here — and it has to be done token by token.
|
|
217
|
-
Resetting --panel-color-text
|
|
221
|
+
Resetting the --panel-color-text-* tokens they derive from would make
|
|
218
222
|
them invalid at computed-value time rather than page-valued, and every
|
|
219
223
|
link would fall back to the surrounding text colour instead of the
|
|
220
224
|
site's link colour. Keep this list in step with the panel rule above. */
|
|
221
225
|
--color-link: inherit;
|
|
226
|
+
--color-link-active: inherit;
|
|
222
227
|
--color-link-hover: inherit;
|
|
223
228
|
--nav-color-text: inherit;
|
|
229
|
+
--nav-color-text-active: inherit;
|
|
224
230
|
|
|
225
231
|
background-color: transparent;
|
|
226
232
|
block-size: auto;
|
|
@@ -261,13 +267,15 @@
|
|
|
261
267
|
of the panel's chrome and takes the page's own text and link colours.
|
|
262
268
|
`inherit` on a custom property hands it back to the parent, which is
|
|
263
269
|
exactly what is wanted here — and it has to be done token by token.
|
|
264
|
-
Resetting --panel-color-text
|
|
270
|
+
Resetting the --panel-color-text-* tokens they derive from would make
|
|
265
271
|
them invalid at computed-value time rather than page-valued, and every
|
|
266
272
|
link would fall back to the surrounding text colour instead of the
|
|
267
273
|
site's link colour. Keep this list in step with the panel rule above. */
|
|
268
274
|
--color-link: inherit;
|
|
275
|
+
--color-link-active: inherit;
|
|
269
276
|
--color-link-hover: inherit;
|
|
270
277
|
--nav-color-text: inherit;
|
|
278
|
+
--nav-color-text-active: inherit;
|
|
271
279
|
|
|
272
280
|
background-color: transparent;
|
|
273
281
|
block-size: auto;
|
|
@@ -308,13 +316,15 @@
|
|
|
308
316
|
of the panel's chrome and takes the page's own text and link colours.
|
|
309
317
|
`inherit` on a custom property hands it back to the parent, which is
|
|
310
318
|
exactly what is wanted here — and it has to be done token by token.
|
|
311
|
-
Resetting --panel-color-text
|
|
319
|
+
Resetting the --panel-color-text-* tokens they derive from would make
|
|
312
320
|
them invalid at computed-value time rather than page-valued, and every
|
|
313
321
|
link would fall back to the surrounding text colour instead of the
|
|
314
322
|
site's link colour. Keep this list in step with the panel rule above. */
|
|
315
323
|
--color-link: inherit;
|
|
324
|
+
--color-link-active: inherit;
|
|
316
325
|
--color-link-hover: inherit;
|
|
317
326
|
--nav-color-text: inherit;
|
|
327
|
+
--nav-color-text-active: inherit;
|
|
318
328
|
|
|
319
329
|
background-color: transparent;
|
|
320
330
|
block-size: auto;
|
|
@@ -23,8 +23,31 @@
|
|
|
23
23
|
*
|
|
24
24
|
* Bleed: --container-bleed, published by .container in @uncinq/css-base — one
|
|
25
25
|
* gutter while the container spans the viewport, 0 once it caps, so the row
|
|
26
|
-
* never pulls out into dead space it cannot cross.
|
|
27
|
-
*
|
|
26
|
+
* never pulls out into dead space it cannot cross.
|
|
27
|
+
*
|
|
28
|
+
* The property inherits, so it reaches the row from a .container however far
|
|
29
|
+
* up it sits, and the fallback is the answer to "no .container above me at
|
|
30
|
+
* all". Margin and padding take DIFFERENT fallbacks, because outside a
|
|
31
|
+
* container they answer two different questions:
|
|
32
|
+
*
|
|
33
|
+
* margin — how far may I pull out of my parent? Unknown, so 0. Nothing
|
|
34
|
+
* published a bleed, the parent may be a card or a column with no
|
|
35
|
+
* room to give, and pulling a gutter out of it is a guess that
|
|
36
|
+
* overflows. Inside a container the published value decides, and
|
|
37
|
+
* at a capped rung that is 0 too.
|
|
38
|
+
* padding — how far in from MY edge should the first item sit? A gutter,
|
|
39
|
+
* the same breathing room every other box gets. A full-bleed block
|
|
40
|
+
* (.block-full, padding-inline: 0) spans the viewport with no
|
|
41
|
+
* inset of its own, so without this the cards touch the screen.
|
|
42
|
+
*
|
|
43
|
+
* Inside a container the two collapse back to one value — --container-bleed is
|
|
44
|
+
* defined, both read it, and the padding puts back inside the scroll box
|
|
45
|
+
* exactly what the negative margin took out, landing the first item on the
|
|
46
|
+
* container's content edge.
|
|
47
|
+
*
|
|
48
|
+
* scroll-margin-inline follows the PADDING, not the margin: it is what makes
|
|
49
|
+
* an item snap flush with the content edge instead of the padding edge, so it
|
|
50
|
+
* has to cancel the padding whatever the margin does.
|
|
28
51
|
*/
|
|
29
52
|
@layer utilities {
|
|
30
53
|
.scrollsnap,
|
|
@@ -36,7 +59,7 @@
|
|
|
36
59
|
grid-auto-flow: column;
|
|
37
60
|
grid-template-columns: none;
|
|
38
61
|
justify-content: start;
|
|
39
|
-
margin-inline: calc(var(--container-bleed,
|
|
62
|
+
margin-inline: calc(var(--container-bleed, 0px) * -1);
|
|
40
63
|
overflow-x: auto;
|
|
41
64
|
padding-inline: var(--container-bleed, var(--gutter));
|
|
42
65
|
scroll-snap-type: x mandatory;
|
package/docs/_index.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: css-components
|
|
4
|
+
description: Framework-agnostic CSS component implementations, driven entirely by component tokens and scoped to @layer components.
|
|
5
|
+
weight: 5
|
|
6
|
+
icon: grid
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`@uncinq/css-components` is the top of the stack: 29 components and 1 utility, written as plain CSS, reading their values from [@uncinq/component-tokens](../component-tokens/) and adding no values of their own.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
@uncinq/design-tokens primitive + semantic values
|
|
13
|
+
@uncinq/component-tokens component-scoped values
|
|
14
|
+
@uncinq/css-base reset, native elements, layouts
|
|
15
|
+
@uncinq/css-components ← this package
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Every rule lives in `@layer components`, except the scroll-snap utility which lives in `@layer utilities`. There is no build step, no preprocessor, and no JavaScript shipped in the package. Three components do expect a script you provide, and each one documents the contract it needs.
|
|
19
|
+
|
|
20
|
+
## The components
|
|
21
|
+
|
|
22
|
+
| Page | Covers |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| [Buttons](buttons/) | `.btn` with its colour, size and style variants, plus 7 specialised buttons |
|
|
25
|
+
| [Overlays](overlays/) | `.panel`, `.modal`, `.drawer`, `.dropdown` |
|
|
26
|
+
| [Content](content/) | `.alert`, `.badge`, `.banner`, `.card`, `.items`, `.list`, `.media`, `.surtitle` |
|
|
27
|
+
| [Navigation](navigation/) | `.nav`, `.nav-title`, `.nav-accessibility`, `.breadcrumb-wrapper`, `.pagination` |
|
|
28
|
+
| [Embeds](embeds/) | `.embed`, `.video`, `.map` |
|
|
29
|
+
| [Forms](forms/) | `.form`, `.form-check` and the form layout helpers |
|
|
30
|
+
| [Utilities](utilities/) | `.scrollsnap`, turning a grid into a snap carousel |
|
|
31
|
+
|
|
32
|
+
Read [Cascade layers](cascade-layers/) first if you are wiring this into a project for the first time.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
All three packages below are required. The tokens resolve the custom properties, and css-base provides the reset and the element styles the components build on.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install @uncinq/design-tokens @uncinq/component-tokens @uncinq/css-base @uncinq/css-components
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
@layer reset, tokens, libs, vendors, base, layouts, components, pages, utilities;
|
|
44
|
+
|
|
45
|
+
@import '@uncinq/design-tokens'; /* @layer tokens */
|
|
46
|
+
@import '@uncinq/css-base'; /* @layer reset, base, layouts */
|
|
47
|
+
@import '@uncinq/component-tokens'; /* @layer tokens */
|
|
48
|
+
@import '@uncinq/css-components'; /* @layer components, utilities */
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Per component, when you only need a few:
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
@import '@uncinq/css-components/css/components/button.css';
|
|
55
|
+
@import '@uncinq/css-components/css/components/alert.css';
|
|
56
|
+
@import '@uncinq/css-components/css/utilities/scrollsnap.css';
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Without a build step:
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<link rel="stylesheet" href="https://unpkg.com/@uncinq/css-components">
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Note that `@uncinq/css-base` is a genuine prerequisite but is **not** declared in `peerDependencies`. Install it explicitly.
|
|
66
|
+
|
|
67
|
+
## Import order inside the package
|
|
68
|
+
|
|
69
|
+
`css/index.css` imports the components alphabetically, with two deliberate exceptions.
|
|
70
|
+
|
|
71
|
+
`components/panel.css` is imported **last** among the components. Its `.panel-inline-*` variants have to beat `.modal` and `.drawer`, and they do so on source order rather than on specificity, because most of the file is wrapped in `:where()` and carries no specificity at all.
|
|
72
|
+
|
|
73
|
+
`utilities/scrollsnap.css` comes after everything, in `@layer utilities`, because it has to win over the grid a component declares for itself in `@layer components`.
|
|
74
|
+
|
|
75
|
+
If you import file by file rather than using the barrel, preserve those two positions.
|
|
76
|
+
|
|
77
|
+
## What this package does not include
|
|
78
|
+
|
|
79
|
+
**No JavaScript.** `.modal`, `.drawer` and `.dropdown` expect a script. The CSS defines the classes and attributes that script must toggle, and each page documents the contract.
|
|
80
|
+
|
|
81
|
+
**No `.item`.** Despite what a couple of source comments still suggest, `.item` is not defined here. It lives in the Hugolify design system theme. This package ships `.card`, a complete implementation in its own right, and `.items`, a grid whose children you provide. See [Content](content/).
|
|
82
|
+
|
|
83
|
+
**No icons.** Components that show a glyph, such as `.pagination` controls, expect the theme to supply it through `::before` or `::after` content.
|
|
84
|
+
|
|
85
|
+
## References
|
|
86
|
+
|
|
87
|
+
- [@uncinq/component-tokens](https://github.com/uncinq/component-tokens), the values these components read
|
|
88
|
+
- [@uncinq/css-base](https://github.com/uncinq/css-base), the foundation underneath
|
|
89
|
+
- [MDN: CSS cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers)
|
package/docs/buttons.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Buttons
|
|
4
|
+
description: The .btn base class with its colour, size and style variants, and the seven specialised buttons built on it.
|
|
5
|
+
weight: 2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## `.btn`
|
|
9
|
+
|
|
10
|
+
The base class. Works on `<button>`, `<a>` and `<input type="submit">`, and reads `--btn-*` from [@uncinq/component-tokens](../../component-tokens/reference/).
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<button class="btn">Send</button>
|
|
14
|
+
<a class="btn btn-secondary" href="/contact">Contact</a>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Colour variants
|
|
18
|
+
|
|
19
|
+
| Class | Intent |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `.btn-primary` | Primary action |
|
|
22
|
+
| `.btn-secondary` | Secondary action |
|
|
23
|
+
| `.btn-brand` | Brand-coloured |
|
|
24
|
+
| `.btn-neutral` | Neutral emphasis |
|
|
25
|
+
| `.btn-dark` | Dark surface |
|
|
26
|
+
| `.btn-light` | Light surface |
|
|
27
|
+
| `.btn-success` | Confirmation |
|
|
28
|
+
| `.btn-danger` | Destructive action |
|
|
29
|
+
| `.btn-warning` | Warning |
|
|
30
|
+
| `.btn-info` | Informational |
|
|
31
|
+
|
|
32
|
+
Each variant sets `--btn-color-background`, `--btn-color-border` and `--btn-color-text` together. The text colour always comes from the matching `--color-text-on-*` semantic token, so contrast is preserved when the underlying colour is overridden. That pairing is the reason to change `--color-brand` rather than `--btn-color-background` when rebranding.
|
|
33
|
+
|
|
34
|
+
### Sizes
|
|
35
|
+
|
|
36
|
+
| Class | Use |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `.btn-xs` | Dense UI, inline controls |
|
|
39
|
+
| `.btn-sm` | Compact |
|
|
40
|
+
| `.btn-md` | Default, can be omitted |
|
|
41
|
+
| `.btn-lg` | Prominent |
|
|
42
|
+
| `.btn-xl` | Hero call to action |
|
|
43
|
+
|
|
44
|
+
### Style variants
|
|
45
|
+
|
|
46
|
+
| Class | Effect |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `.btn-ghost` | Transparent background, visible border |
|
|
49
|
+
| `.btn-link` | Renders as a link, no background or border |
|
|
50
|
+
| `.btn-control` | Form control styling, transparent border, for buttons sitting next to inputs |
|
|
51
|
+
|
|
52
|
+
Variants compose: `class="btn btn-danger btn-sm btn-ghost"`.
|
|
53
|
+
|
|
54
|
+
## Specialised buttons
|
|
55
|
+
|
|
56
|
+
Seven single-purpose buttons. Read the second column before using one: whether `.btn` is required differs between them.
|
|
57
|
+
|
|
58
|
+
| Class | Needs `.btn` | Icon | Purpose |
|
|
59
|
+
| --- | --- | --- | --- |
|
|
60
|
+
| `.btn-close` | no | `--icon-close` | Close control, used inside panels and alerts |
|
|
61
|
+
| `.btn-menu` | no | `--icon-menu` | Menu toggle, typically the burger in a header |
|
|
62
|
+
| `.btn-search` | yes | `--icon-search` | Search toggle |
|
|
63
|
+
| `.btn-filter` | yes | `--icon-filter` | Filters toggle |
|
|
64
|
+
| `.btn-share` | yes | `--icon-share` | Share control |
|
|
65
|
+
| `.btn-toc` | yes | `--icon-toc` | Table of contents toggle |
|
|
66
|
+
| `.btn-toggle-video` | yes | child elements | Play and pause control overlaid on a video |
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<!-- self-contained -->
|
|
70
|
+
<button class="btn-close" aria-label="Close"></button>
|
|
71
|
+
|
|
72
|
+
<!-- modifier on .btn -->
|
|
73
|
+
<button class="btn btn-search" aria-label="Search"></button>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`.btn-close` and `.btn-menu` redeclare everything they need, with `--btn-close-*` and `--btn-menu-*` falling back to the matching `--btn-*` token. They therefore look consistent with `.btn` without depending on it. The other five are modifiers, and omitting the base class leaves them largely unstyled.
|
|
77
|
+
|
|
78
|
+
Six of the seven **do ship their icon**, drawn as a `mask` on `::before` from the icon tokens in [@uncinq/design-tokens](../../design-tokens/reference/#icon). Because it is a mask rather than a background image, the glyph takes `currentColor` and follows the button's text colour through every state. Size it with `--icon-size`, or per button with `--btn-close-icon-size` and its siblings.
|
|
79
|
+
|
|
80
|
+
`.btn-toggle-video` is the exception and expects two child elements, for the reason given below.
|
|
81
|
+
|
|
82
|
+
When a button has no visible text, give it an accessible name with `aria-label`, or a `.visually-hidden` span from [css-base](../../css-base/base/#accessibility-helpers). None of these buttons provides one for you.
|
|
83
|
+
|
|
84
|
+
## `.btn-toggle-video`
|
|
85
|
+
|
|
86
|
+
The one worth explaining, because its behaviour is driven by a state class rather than by CSS alone.
|
|
87
|
+
|
|
88
|
+
It is a play and pause control overlaid on a video that autoplays without native controls, which WCAG requires to be pausable. It stays transparent so the video shows through, and the `.is-playing` class, toggled by whatever script drives the video, decides which of the two icons is shown.
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<div class="video">
|
|
92
|
+
<video autoplay muted loop playsinline></video>
|
|
93
|
+
<button class="btn btn-toggle-video is-playing" aria-label="Pause">
|
|
94
|
+
<span class="icon-pause"></span>
|
|
95
|
+
<span class="icon-play"></span>
|
|
96
|
+
</button>
|
|
97
|
+
</div>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The `.video` wrapper is what positions it. See [Embeds](../embeds/).
|
|
101
|
+
|
|
102
|
+
Your script owns two things: toggling `.is-playing` in step with the video's actual state, and keeping the accessible name in sync, since the control means "pause" while playing and "play" while paused.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Cascade layers
|
|
4
|
+
description: The two layers this package owns, why panel.css is imported last, and how to override a component cleanly.
|
|
5
|
+
weight: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
This package writes to two layers.
|
|
9
|
+
|
|
10
|
+
| Layer | Contents |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `@layer components` | All 29 components |
|
|
13
|
+
| `@layer utilities` | `.scrollsnap`, the only utility |
|
|
14
|
+
|
|
15
|
+
The full order, including layers owned by the sibling packages and by the project itself, is the **consuming project's** responsibility. Declare it once, at the very top of your entry stylesheet, before any `@import`:
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
@layer reset, tokens, libs, vendors, base, layouts, components, pages, utilities;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
CSS fixes a layer's position the first time its name is seen, and later re-declarations do not reorder it. If that line comes after an import, it is already too late. See [the css-base page](../../css-base/cascade-layers/) for the full explanation, including why `libs` and `vendors` are a pair.
|
|
22
|
+
|
|
23
|
+
## Why `utilities` is last
|
|
24
|
+
|
|
25
|
+
`.scrollsnap` changes the `grid-template-columns` that a component such as `.items` declares for itself in `@layer components`. A later layer beats an earlier one regardless of specificity, so putting it in `utilities` is what lets a single class opt an existing component into carousel behaviour without rewriting the component.
|
|
26
|
+
|
|
27
|
+
This is also why it is a utility rather than a component rule: it is a modifier applied to something else, not a thing of its own.
|
|
28
|
+
|
|
29
|
+
## Why `panel.css` is imported last
|
|
30
|
+
|
|
31
|
+
Inside `@layer components`, source order breaks ties between rules of equal specificity. Two facts combine here:
|
|
32
|
+
|
|
33
|
+
1. Most of `panel.css` is wrapped in `:where()`, so it carries **zero specificity**. That is deliberate: it lets `.modal`, `.drawer` and your own overrides win without escalating.
|
|
34
|
+
2. The `.panel-inline-*` variants must beat `.modal` and `.drawer`, and they are plain class selectors.
|
|
35
|
+
|
|
36
|
+
Because those variants have no specificity advantage over the host components, they rely on arriving later in the file. Hence `@import 'components/panel.css';` sits last among the component imports in `css/index.css`.
|
|
37
|
+
|
|
38
|
+
If you import files individually, keep `panel.css` after `modal.css` and `drawer.css`.
|
|
39
|
+
|
|
40
|
+
## Overriding a component
|
|
41
|
+
|
|
42
|
+
Write to the same layer after the imports:
|
|
43
|
+
|
|
44
|
+
```css
|
|
45
|
+
@layer components {
|
|
46
|
+
.alert {
|
|
47
|
+
--alert-border-radius: 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Prefer redefining the token over rewriting the declaration. Almost every value in this package comes from a `--component-*` custom property, so an override usually needs no selector work at all.
|
|
53
|
+
|
|
54
|
+
Better still, when the change is contextual rather than global, set the property on an ancestor and let it inherit:
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
.sidebar {
|
|
58
|
+
--alert-padding-inline: var(--spacing-sm);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
That is a normal declaration on a normal selector, competing on specificity like any other rule, not on layer order. It restyles a region without adding a variant class to the system.
|
|
63
|
+
|
|
64
|
+
## Overriding a `:where()` rule
|
|
65
|
+
|
|
66
|
+
Because `panel.css` uses `:where()` throughout, its rules have zero specificity and a single class selector of yours already outranks them:
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
.modal {
|
|
70
|
+
border-radius: 0;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
No `!important`, no repeated class, no `:is()` trick. This is the main practical benefit of the `:where()` convention, and it is worth preserving if you contribute to the package.
|
package/docs/content.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Content
|
|
4
|
+
description: Alerts, badges, banners, cards, the items grid, labelled lists, media objects and surtitles.
|
|
5
|
+
weight: 4
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## `.alert`
|
|
9
|
+
|
|
10
|
+
An inline notification block.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<div class="alert alert-info">
|
|
14
|
+
<p class="alert-heading">Heads up</p>
|
|
15
|
+
<p>Your changes were saved.</p>
|
|
16
|
+
</div>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Variants: `.alert-primary`, `.alert-secondary`, `.alert-brand`, `.alert-neutral`, `.alert-dark`, `.alert-light`, `.alert-success`, `.alert-danger`, `.alert-warning`, `.alert-info`.
|
|
20
|
+
|
|
21
|
+
Each sets the background, border and text colour from the matching `-muted` and `-strong` semantic tokens, so the pairing stays legible if the underlying colour changes.
|
|
22
|
+
|
|
23
|
+
Two behaviours are worth knowing. `--color-link` is reassigned to the alert's own text colour, so links inside an alert do not fall back to the page link colour against a tinted background. And an alert whose first child is an `.icon`, with no `.alert-heading`, switches to a horizontal layout automatically.
|
|
24
|
+
|
|
25
|
+
`.container` inside an alert inherits the same flex layout, which is what lets a full-bleed alert keep its content aligned with the rest of the page.
|
|
26
|
+
|
|
27
|
+
## `.banner`
|
|
28
|
+
|
|
29
|
+
A thin variation on the alert, centred rather than start-aligned. It sets `--alert-align: center` and flattens paragraph margins, and nothing else.
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<div class="alert banner">
|
|
33
|
+
<p>Site-wide announcement.</p>
|
|
34
|
+
</div>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
It is a modifier on `.alert`, so use both classes.
|
|
38
|
+
|
|
39
|
+
## `.badge`
|
|
40
|
+
|
|
41
|
+
A small inline label.
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<span class="badge badge-success">Published</span>
|
|
45
|
+
<a class="badge" href="/tag/css">css</a>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Variants mirror the alert set: `.badge-primary`, `.badge-secondary`, `.badge-brand`, `.badge-neutral`, `.badge-dark`, `.badge-light`, `.badge-success`, `.badge-danger`, `.badge-warning`, `.badge-info`.
|
|
49
|
+
|
|
50
|
+
Hover styles apply only to `a.badge`, guarded by `@media (hover: hover) and (pointer: fine)`, so a static badge never looks interactive.
|
|
51
|
+
|
|
52
|
+
## `.card`
|
|
53
|
+
|
|
54
|
+
A self-contained content card.
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<article class="card">
|
|
58
|
+
<div class="content">
|
|
59
|
+
<p class="surtitle">Category</p>
|
|
60
|
+
<p class="title">Card title</p>
|
|
61
|
+
<p class="description">Short description.</p>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="media">
|
|
64
|
+
<picture>...</picture>
|
|
65
|
+
</div>
|
|
66
|
+
</article>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The media block sits first visually, through `--card-media-order: -1`, regardless of its position in the markup. Put it after the content so that screen readers and search engines reach the text first.
|
|
70
|
+
|
|
71
|
+
Wrapping the content in `a.content` makes the whole card clickable, using a `::before` overlay that covers the card. Focus is then handled on the card itself with `:has(a.content:focus-visible)`, so the focus ring outlines the card rather than an invisible box. Nested interactive elements inside such a card will be unreachable, which is the known trade-off of this pattern.
|
|
72
|
+
|
|
73
|
+
Sizing with `--card-max-width` and `--card-width` is unset by default. Prefer `ch` units, so the width tracks the text measure.
|
|
74
|
+
|
|
75
|
+
{{< alert-block state="info" >}}
|
|
76
|
+
The source comment in `card.css` describes `.card` as a backwards-compatible alias for `.item` and recommends using `.item` directly. That is misleading for anyone consuming this package on its own: **`.item` is not defined here**. It lives in the Hugolify design system theme. Within `@uncinq/css-components`, `.card` is a complete implementation and the class to use.
|
|
77
|
+
{{< /alert-block >}}
|
|
78
|
+
|
|
79
|
+
## `.items`
|
|
80
|
+
|
|
81
|
+
A responsive grid, and the usual container for cards.
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<div class="items">
|
|
85
|
+
<article class="card">...</article>
|
|
86
|
+
<article class="card">...</article>
|
|
87
|
+
</div>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The column count is intrinsic rather than breakpoint-driven:
|
|
91
|
+
|
|
92
|
+
```css
|
|
93
|
+
grid-template-columns: repeat(
|
|
94
|
+
var(--items-cols, auto-fill),
|
|
95
|
+
minmax(min(var(--items-min-width, var(--max-width-item)), 100%), 1fr)
|
|
96
|
+
);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Items wrap when they no longer fit at `--items-min-width`, with no media query involved. Set `--items-cols` to a number to force a fixed count instead.
|
|
100
|
+
|
|
101
|
+
It also declares `container-type: inline-size` and `container-name: items`, so children can use container queries against the grid rather than the viewport.
|
|
102
|
+
|
|
103
|
+
Pair it with [`.scrollsnap`](../utilities/) to turn the grid into a horizontal carousel below a given breakpoint.
|
|
104
|
+
|
|
105
|
+
## `.list`
|
|
106
|
+
|
|
107
|
+
A compact labelled list with dash markers.
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<div class="list">
|
|
111
|
+
<p>Optional label</p>
|
|
112
|
+
<ul>
|
|
113
|
+
<li>First</li>
|
|
114
|
+
<li>Second</li>
|
|
115
|
+
</ul>
|
|
116
|
+
</div>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The wrapper is a `div`, with the label as a sibling of the list rather than inside it. Either `ul` or `ol` works.
|
|
120
|
+
|
|
121
|
+
## `.media`
|
|
122
|
+
|
|
123
|
+
The structural base for media blocks, controlling aspect ratio, background and border.
|
|
124
|
+
|
|
125
|
+
| Class | Use |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `.media` | Base, for a picture or video |
|
|
128
|
+
| `.media-logo` | Logo, typically contained rather than cropped |
|
|
129
|
+
| `.media-icon` | Icon, sized from `--icon-size` |
|
|
130
|
+
|
|
131
|
+
`.media-logo` and `.media-icon` build on `.media`. Inside a `.card`, the card reassigns `--media-color-background` and `--media-ratio` from its own `--card-media-*` tokens, so a media block adapts to its context without a variant class.
|
|
132
|
+
|
|
133
|
+
A `.video` inside a `.media` is stretched to fill it. See [Embeds](../embeds/).
|
|
134
|
+
|
|
135
|
+
## `.surtitle`
|
|
136
|
+
|
|
137
|
+
An eyebrow label above a heading.
|
|
138
|
+
|
|
139
|
+
```html
|
|
140
|
+
<p class="surtitle">Category</p>
|
|
141
|
+
<h2>Main title</h2>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Inside a `.card` it gets a negative `--surtitle-margin-block-end`, pulling it closer to the title so the pair reads as one unit.
|
package/docs/embeds.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Embeds
|
|
4
|
+
description: Aspect-ratio wrappers for third-party embeds, native video and maps.
|
|
5
|
+
weight: 6
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## `.embed`
|
|
9
|
+
|
|
10
|
+
A responsive container for third-party embeds, holding an aspect ratio so the page does not reflow once the iframe loads.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<div class="embed">
|
|
14
|
+
<iframe src="https://..." title="Video title" allowfullscreen></iframe>
|
|
15
|
+
</div>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Accepts `iframe`, `video`, `embed` or `object` as its child. The ratio comes from `--embed-ratio`, which defaults to the video ratio token. Override it per instance for a square or portrait embed:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<div class="embed" style="--embed-ratio: 1">...</div>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Always give the `iframe` a `title`. It is the only accessible name an embedded frame has.
|
|
25
|
+
|
|
26
|
+
## `.video`
|
|
27
|
+
|
|
28
|
+
A wrapper for a **native** `<video>`, as opposed to an embedded player.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<div class="video">
|
|
32
|
+
<video autoplay muted loop playsinline></video>
|
|
33
|
+
<button class="btn btn-toggle-video is-playing" aria-label="Pause">
|
|
34
|
+
<span class="icon-pause"></span>
|
|
35
|
+
<span class="icon-play"></span>
|
|
36
|
+
</button>
|
|
37
|
+
</div>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The wrapper positions the optional toggle control over the video. Inside a `.media`, the wrapper is stretched to fill it, so a video and an image are interchangeable within a card.
|
|
41
|
+
|
|
42
|
+
The control is there for a reason rather than for decoration. A video that autoplays without native controls must be pausable to meet WCAG, which is exactly what `.btn-toggle-video` provides. If your video carries `controls`, you do not need it. See [Buttons](../buttons/#btn-toggle-video) for the `.is-playing` contract.
|
|
43
|
+
|
|
44
|
+
## `.map`
|
|
45
|
+
|
|
46
|
+
A map container, driven by Leaflet through a `js-map` hook.
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<div class="map js-map"
|
|
50
|
+
data-markers="[...]"
|
|
51
|
+
data-zoom="12"
|
|
52
|
+
data-tile="3"
|
|
53
|
+
data-marker-hidden="false"></div>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
| Attribute | Role |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `data-markers` | The markers to plot |
|
|
59
|
+
| `data-zoom` | Initial zoom level |
|
|
60
|
+
| `data-tile` | Tile layer selection |
|
|
61
|
+
| `data-marker-hidden` | Whether markers start hidden |
|
|
62
|
+
|
|
63
|
+
This package provides the container only: sizing, background and border. Leaflet itself, its stylesheet and the script reading those attributes are yours to supply.
|
|
64
|
+
|
|
65
|
+
Leaflet's own CSS is a good example of why the layer order matters. Import it into `@layer libs` and any adjustments you write into `@layer vendors`, so that a lazily loaded Leaflet cannot outrank your own rules on source order. See [Cascade layers](../cascade-layers/).
|
package/docs/forms.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Forms
|
|
4
|
+
description: The .form grid, its layout helpers, and where the actual control styling lives.
|
|
5
|
+
weight: 7
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Form **controls** are styled by [@uncinq/css-base](../../css-base/base/#forms), on the native elements themselves. There is no `.input` or `.select` class to apply.
|
|
9
|
+
|
|
10
|
+
This package adds only what css-base cannot: the layout around those controls.
|
|
11
|
+
|
|
12
|
+
## `.form`
|
|
13
|
+
|
|
14
|
+
A responsive two-column grid that collapses to one column when there is not enough room.
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<form class="form">
|
|
18
|
+
<div>
|
|
19
|
+
<label for="first">First name</label>
|
|
20
|
+
<input id="first" type="text">
|
|
21
|
+
</div>
|
|
22
|
+
<div>
|
|
23
|
+
<label for="last">Last name</label>
|
|
24
|
+
<input id="last" type="text">
|
|
25
|
+
</div>
|
|
26
|
+
<div class="full">
|
|
27
|
+
<label for="message">Message</label>
|
|
28
|
+
<textarea id="message"></textarea>
|
|
29
|
+
<p class="help">Markdown is supported.</p>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="actions">
|
|
32
|
+
<button class="btn" type="submit">Send</button>
|
|
33
|
+
</div>
|
|
34
|
+
</form>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The column rule is worth reading once:
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
grid-template-columns: repeat(
|
|
41
|
+
auto-fill,
|
|
42
|
+
minmax(max(var(--form-col-min-width, 25ch), calc(50% - var(--gap) / 2)), 1fr)
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The `max()` sets a floor of `25ch` **and** caps the result at half the width. The effect is a form that is one column or two, never three, however wide the container gets. A three-column form is almost never what you want, because it breaks the vertical reading order of a sequence of fields.
|
|
47
|
+
|
|
48
|
+
Change the floor with `--form-col-min-width`.
|
|
49
|
+
|
|
50
|
+
## Layout helpers
|
|
51
|
+
|
|
52
|
+
| Class | Effect |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `.full` | Spans both columns, `grid-column: 1 / -1` |
|
|
55
|
+
| `.actions` | Spans both columns and stacks its children vertically |
|
|
56
|
+
| `.help` | Help text under a field |
|
|
57
|
+
| `.form-check` | A checkbox or radio laid out inline with its label |
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<div class="form-check">
|
|
61
|
+
<input id="terms" type="checkbox">
|
|
62
|
+
<label for="terms">I accept the terms</label>
|
|
63
|
+
</div>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`.form-check` is deliberately minimal, just `display: flex`. The checkbox and radio appearance, including the gap with the adjacent label, comes from css-base, which styles `[type='checkbox'] + label` directly.
|
|
67
|
+
|
|
68
|
+
## Accessibility
|
|
69
|
+
|
|
70
|
+
Nothing here supplies an accessible name. Every control needs a `<label for>` pointing at its `id`, or a `.visually-hidden` label when the design has no room for a visible one.
|
|
71
|
+
|
|
72
|
+
Tie `.help` text to its field with `aria-describedby`, otherwise it is visible but never announced:
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<input id="message" aria-describedby="message-help">
|
|
76
|
+
<p class="help" id="message-help">Markdown is supported.</p>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For error states, use `aria-invalid="true"` on the control and point `aria-describedby` at the error message.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Navigation
|
|
4
|
+
description: Navigation lists, skip links, breadcrumbs and pagination.
|
|
5
|
+
weight: 5
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## `.nav`
|
|
9
|
+
|
|
10
|
+
The base navigation list, vertical by default.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<ul class="nav">
|
|
14
|
+
<li><a href="/">Home</a></li>
|
|
15
|
+
<li><a href="/about">About</a></li>
|
|
16
|
+
</ul>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Works on `ul` or `ol`. **Direction is set by context, not by a modifier class**: a header lays its nav out horizontally by setting `flex-direction: row` on it. That keeps the component free of layout variants that would only ever be used in one place.
|
|
20
|
+
|
|
21
|
+
## `.nav-title`
|
|
22
|
+
|
|
23
|
+
A title within a navigation block, for labelling a group of links.
|
|
24
|
+
|
|
25
|
+
## `.nav-accessibility`
|
|
26
|
+
|
|
27
|
+
Skip links, for keyboard and assistive technology users.
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<ul class="nav nav-accessibility">
|
|
31
|
+
<li><a href="#main">Skip to content</a></li>
|
|
32
|
+
<li><a href="#navigation">Skip to navigation</a></li>
|
|
33
|
+
<li><a href="#footer">Skip to footer</a></li>
|
|
34
|
+
</ul>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Three things matter here, and getting any of them wrong defeats the purpose:
|
|
38
|
+
|
|
39
|
+
**It must be the first focusable element in `<body>`.** A skip link that comes after the navigation it skips is useless.
|
|
40
|
+
|
|
41
|
+
**It is hidden off-screen, not hidden.** It slides into view when a child receives focus. Using `display: none` would remove it from the tab order entirely.
|
|
42
|
+
|
|
43
|
+
**It requires the `.nav` base class** alongside it.
|
|
44
|
+
|
|
45
|
+
The targets must exist and be focusable. An `id` on a non-interactive element needs `tabindex="-1"` for the jump to move focus rather than just scroll.
|
|
46
|
+
|
|
47
|
+
## `.breadcrumb-wrapper`
|
|
48
|
+
|
|
49
|
+
The breadcrumb trail. Note that the class goes on the **wrapper**, not on the list itself.
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<nav class="breadcrumb-wrapper" aria-label="Breadcrumb">
|
|
53
|
+
<ol>
|
|
54
|
+
<li><a href="/">Home</a></li>
|
|
55
|
+
<li><a href="/docs">Docs</a></li>
|
|
56
|
+
<li aria-current="page">Navigation</li>
|
|
57
|
+
</ol>
|
|
58
|
+
</nav>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The separator is drawn from `--breadcrumb-separator`, which defaults to `"/"`. Mark the current page with `aria-current="page"` rather than relying on it being last.
|
|
62
|
+
|
|
63
|
+
## `.pagination`
|
|
64
|
+
|
|
65
|
+
A page navigation list.
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<nav role="navigation" aria-label="Pagination">
|
|
69
|
+
<ul class="pagination">
|
|
70
|
+
<li class="disabled"><a class="first">First</a></li>
|
|
71
|
+
<li><a class="previous">Previous</a></li>
|
|
72
|
+
<li class="item active"><a href="?page=1">1</a></li>
|
|
73
|
+
<li class="item item-adjacent"><a href="?page=2">2</a></li>
|
|
74
|
+
<li><a class="next">Next</a></li>
|
|
75
|
+
<li><a class="last">Last</a></li>
|
|
76
|
+
</ul>
|
|
77
|
+
</nav>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
| Class | Role |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `.first`, `.previous`, `.next`, `.last` | Navigation controls, on the `a` |
|
|
83
|
+
| `.item` | A page number, on the `li` |
|
|
84
|
+
| `.item-adjacent` | A page number next to the current one |
|
|
85
|
+
| `.active` | The current page |
|
|
86
|
+
| `.disabled` | An unavailable control, on the `li` |
|
|
87
|
+
|
|
88
|
+
`.item-adjacent` exists so that a responsive paginator can hide distant page numbers while keeping the immediate neighbours visible, which is the usual mobile treatment.
|
|
89
|
+
|
|
90
|
+
**The glyphs for `.first`, `.last`, `.previous` and `.next` are not provided.** This package positions and spaces them; the theme supplies the arrow through `a::before` or `a::after` content. A paginator with no theme styling will show the text labels only, which is a reasonable fallback but rarely what you want visually.
|
|
91
|
+
|
|
92
|
+
Note that `.item` here means a pagination entry, and is unrelated to the `.item` card unit mentioned in [Content](../content/).
|
package/docs/overlays.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Overlays
|
|
4
|
+
description: The shared panel skeleton behind .modal and .drawer, the two opening strategies, and the .dropdown contract.
|
|
5
|
+
weight: 3
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## The shared panel skeleton
|
|
9
|
+
|
|
10
|
+
`.modal` and `.drawer` are the same panel. Same structure (header, content, footer), same open and closed contract, same backdrop. They differ only in where they sit: modal centres them, drawer sticks them to an edge.
|
|
11
|
+
|
|
12
|
+
`components/panel.css` owns every rule. The two variants are **pure configuration**: `modal.css` and `drawer.css` declare nothing but `--panel-*` tokens.
|
|
13
|
+
|
|
14
|
+
There is **no `.panel` class to apply.** The file targets `:where(.modal, .drawer)` directly, so the skeleton arrives with either variant class. `panel` names the shared concept and the token namespace, not a class.
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<dialog class="modal" id="contact" aria-labelledby="contactLabel">
|
|
18
|
+
<div class="header">
|
|
19
|
+
<p class="title" id="contactLabel">Contact</p>
|
|
20
|
+
<button class="btn-close js-dialog-close" aria-label="Close"></button>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="content">...</div>
|
|
23
|
+
<div class="footer">...</div>
|
|
24
|
+
</dialog>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Each variant aliases `--panel-*` from its own namespace, so `--modal-*` and `--drawer-*` remain the public API. Override those, not `--panel-*`.
|
|
28
|
+
|
|
29
|
+
## Two ways to open a panel
|
|
30
|
+
|
|
31
|
+
**The tag picks the strategy, not the class.** Either variant works both ways.
|
|
32
|
+
|
|
33
|
+
### `<dialog>` with `showModal()`
|
|
34
|
+
|
|
35
|
+
The browser handles Escape, the focus trap and making the rest of the page inert. You get `[open]`, the native `::backdrop` and the top layer for free.
|
|
36
|
+
|
|
37
|
+
This is the right choice when the panel is **always** a dialog.
|
|
38
|
+
|
|
39
|
+
### `popover="auto"` with `showPopover()`
|
|
40
|
+
|
|
41
|
+
Same top layer, same native `::backdrop`, but the element carries no implicit role.
|
|
42
|
+
|
|
43
|
+
Use this when the panel becomes a static region of the page above a breakpoint, which is what the `.panel-inline-*` variants do. The reason is an accessibility one: a `<dialog>` is exposed as `role="dialog"` even when it is only styled as a sidebar, whereas a script can set that role solely while the panel is actually open.
|
|
44
|
+
|
|
45
|
+
## `.modal`
|
|
46
|
+
|
|
47
|
+
A centred panel. Size a single instance by overriding `--modal-max-width` on the element itself.
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<dialog class="modal" style="--modal-max-width: 40rem">...</dialog>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## `.drawer`
|
|
54
|
+
|
|
55
|
+
A panel sliding in from an edge.
|
|
56
|
+
|
|
57
|
+
| Class | Edge |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `.drawer-start` | Inline start, left in a left-to-right document |
|
|
60
|
+
| `.drawer-end` | Inline end |
|
|
61
|
+
| `.drawer-top` | Top |
|
|
62
|
+
| `.drawer-bottom` | Bottom |
|
|
63
|
+
|
|
64
|
+
## `.panel-inline-*`
|
|
65
|
+
|
|
66
|
+
Turns a panel into an ordinary region of the page from a breakpoint upwards, while it stays an overlay below.
|
|
67
|
+
|
|
68
|
+
| Class | Becomes inline at |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `.panel-inline-sm` | `--sm`, 768px |
|
|
71
|
+
| `.panel-inline-md` | `--md`, 1024px |
|
|
72
|
+
| `.panel-inline-lg` | `--lg`, 1440px |
|
|
73
|
+
| `.panel-inline-xl` | `--xl`, 1600px |
|
|
74
|
+
|
|
75
|
+
This is the case that calls for `popover="auto"` rather than `<dialog>`. A filters sidebar that is a drawer on mobile and a column on desktop should not announce itself as a dialog while it is a column.
|
|
76
|
+
|
|
77
|
+
These variants beat `.modal` and `.drawer` on **source order**, not specificity, which is why `panel.css` is imported last. See [Cascade layers](../cascade-layers/).
|
|
78
|
+
|
|
79
|
+
## `.panel-trigger-*`
|
|
80
|
+
|
|
81
|
+
The companion to `.panel-inline-*`, applied to the **trigger button** rather than to the panel. It hides the trigger at the breakpoint where the panel stops being an overlay.
|
|
82
|
+
|
|
83
|
+
| Class | Trigger hidden from |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `.panel-trigger-sm` | `--sm`, 768px |
|
|
86
|
+
| `.panel-trigger-md` | `--md`, 1024px |
|
|
87
|
+
| `.panel-trigger-lg` | `--lg`, 1440px |
|
|
88
|
+
| `.panel-trigger-xl` | `--xl`, 1600px |
|
|
89
|
+
|
|
90
|
+
Pair the suffixes: a panel carrying `.panel-inline-md` needs its button carrying `.panel-trigger-md`, otherwise a button that opens nothing remains on screen at desktop width.
|
|
91
|
+
|
|
92
|
+
The reason this is a second class rather than something CSS derives on its own is worth knowing, because it looks like a redundancy. Nothing structurally connects a trigger to its panel: the only link is `data-target` matching an `id`, and no selector can compare two attribute values. A positional rule would work only until somebody moved the markup, and a filter button typically lives in the page heading rather than beside the panel it opens. In practice both classes come from the same configuration value, so the pair cannot disagree.
|
|
93
|
+
|
|
94
|
+
## The JavaScript contract
|
|
95
|
+
|
|
96
|
+
This package ships no JavaScript. `.modal` and `.drawer` expect a script that provides:
|
|
97
|
+
|
|
98
|
+
| Hook | Role |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `.js-dialog-toggle[data-target="#id"]` | Opens the panel it points at |
|
|
101
|
+
| `.js-dialog-close` | Any element inside the panel that closes it |
|
|
102
|
+
|
|
103
|
+
Closing must also work on Escape and on a click outside. With `<dialog>` and `showModal()` the browser already does both. With `popover="auto"` the platform handles light dismiss and Escape too, so in practice the script mainly manages the role and the open call.
|
|
104
|
+
|
|
105
|
+
## `.dropdown`
|
|
106
|
+
|
|
107
|
+
A contextual menu, with a tighter JavaScript contract because it animates.
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<div class="dropdown">
|
|
111
|
+
<button class="js-dropdown-toggle" aria-expanded="false">Label</button>
|
|
112
|
+
<ul class="dropdown-menu" role="menu">
|
|
113
|
+
<li><a class="dropdown-item" href="#">Item</a></li>
|
|
114
|
+
<li><hr class="dropdown-divider"></li>
|
|
115
|
+
<li><a class="dropdown-item" href="#">Item</a></li>
|
|
116
|
+
</ul>
|
|
117
|
+
</div>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The trigger is `.js-dropdown-toggle`, and its **next element sibling must be** `.dropdown-menu`.
|
|
121
|
+
|
|
122
|
+
The script toggles three classes on the menu, in this sequence:
|
|
123
|
+
|
|
124
|
+
| Class | Meaning |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| `.showing` | Opening transition has started |
|
|
127
|
+
| `.show` | Fully open |
|
|
128
|
+
| `.hiding` | Closing transition has started |
|
|
129
|
+
|
|
130
|
+
It must also keep `aria-expanded` on the toggle in sync. The three-class sequence exists so the menu can animate out before being removed from the flow; a single `.show` class would make the closing transition impossible.
|
|
131
|
+
|
|
132
|
+
`.dropdown-menu-end` aligns the menu to the inline end of its trigger rather than the start.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
isIndex: false
|
|
3
|
+
title: Utilities
|
|
4
|
+
description: The .scrollsnap utility, which turns a grid into a horizontal snap carousel below a breakpoint.
|
|
5
|
+
weight: 8
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## `.scrollsnap`
|
|
9
|
+
|
|
10
|
+
Turns a grid into a horizontal carousel with snap points. Items keep their own width, the grid stops wrapping, and the row scrolls sideways, bleeding into the gutter so the next item peeks in.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<div class="items scrollsnap-md">
|
|
14
|
+
<article class="card">...</article>
|
|
15
|
+
<article class="card">...</article>
|
|
16
|
+
<article class="card">...</article>
|
|
17
|
+
</div>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
It is opt-in, applied to the element that owns the grid, so the same component is a carousel in one context and a plain grid in another.
|
|
21
|
+
|
|
22
|
+
## The suffix names where the carousel stops
|
|
23
|
+
|
|
24
|
+
This is the one thing to get right, and it reads backwards from most responsive utilities.
|
|
25
|
+
|
|
26
|
+
| Class | Carousel below | Grid from |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `.scrollsnap` | every width | never |
|
|
29
|
+
| `.scrollsnap-sm` | `--sm`, 768px | 768px |
|
|
30
|
+
| `.scrollsnap-md` | `--md`, 1024px | 1024px |
|
|
31
|
+
| `.scrollsnap-lg` | `--lg`, 1440px | 1440px |
|
|
32
|
+
| `.scrollsnap-xl` | `--xl`, 1600px | 1600px |
|
|
33
|
+
|
|
34
|
+
**The suffix names the rung where the carousel STOPS and the grid comes back.** `.scrollsnap-md` is a carousel on mobile and tablet, and a grid from 1024px up.
|
|
35
|
+
|
|
36
|
+
## Why it is a utility
|
|
37
|
+
|
|
38
|
+
It has to win over the `grid-template-columns` that a component such as `.items` declares for itself in `@layer components`. `@layer utilities` comes later in the order, so it wins regardless of specificity. See [Cascade layers](../cascade-layers/).
|
|
39
|
+
|
|
40
|
+
## Item width
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
grid-auto-columns: min(
|
|
44
|
+
var(--items-min-width, var(--max-width-item)),
|
|
45
|
+
var(--items-carousel-max-width, 75vw)
|
|
46
|
+
);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Items take `--items-min-width`, the same value that drives the grid, capped by `--items-carousel-max-width` (default `75vw`). The cap is what guarantees the next item always peeks in, which is the affordance that tells a reader the row scrolls at all. Without it, a wide item on a narrow screen would fill the viewport and the carousel would look like a static card.
|
|
50
|
+
|
|
51
|
+
## The bleed, and why margin and padding disagree
|
|
52
|
+
|
|
53
|
+
The row pulls out to the screen edge using `--container-bleed`, published by `.container` in [css-base](../../css-base/layouts/#the-container-bleed-contract). The property inherits, so it reaches the row from a `.container` however far up it sits.
|
|
54
|
+
|
|
55
|
+
Outside a container there is no published value, and the two `var()` fallbacks differ **on purpose**, because margin and padding answer different questions:
|
|
56
|
+
|
|
57
|
+
| | Question | Fallback |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `margin` | How far may I pull out of my parent? | `0`, since nothing published a bleed. The parent may be a card or a column with no room to give, and pulling a gutter out of it would overflow |
|
|
60
|
+
| `padding` | How far in from my own edge should the first item sit? | `var(--gutter)`, the breathing room every other box gets, so a full-bleed block does not let the cards touch the screen |
|
|
61
|
+
|
|
62
|
+
Inside a container the two collapse to one value: both read the published bleed, and the padding puts back inside the scroll box exactly what the negative margin took out. The first item lands on the container's content edge, aligned with everything else on the page.
|
|
63
|
+
|
|
64
|
+
`scroll-margin-inline` follows the **padding**, not the margin. It is what makes an item snap flush with the content edge rather than the padding edge, so it has to cancel the padding whatever the margin does.
|
|
65
|
+
|
|
66
|
+
This is the same reasoning as the `--container-bleed` contract itself, applied to a scroll container. If you write your own full-bleed component, copy the pair rather than picking one fallback for both.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uncinq/css-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Framework-agnostic CSS component implementations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"cascade-layers"
|
|
20
20
|
],
|
|
21
21
|
"files": [
|
|
22
|
-
"css/"
|
|
22
|
+
"css/",
|
|
23
|
+
"docs/"
|
|
23
24
|
],
|
|
24
25
|
"exports": {
|
|
25
26
|
".": "./css/index.css",
|