@cngx/common 0.0.1-rc.0 → 0.1.0-rc.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/a11y/README.md +13 -16
- package/card/README.md +2 -21
- package/chart/README.md +5 -8
- package/data/README.md +45 -47
- package/dialog/README.md +12 -15
- package/display/README.md +5 -9
- package/fesm2022/cngx-common-a11y.mjs +140 -40
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +157 -69
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +389 -92
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +311 -151
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +167 -29
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +445 -110
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2025 -435
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +188 -31
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +711 -90
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +1258 -60
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +247 -41
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +5 -5
- package/layout/README.md +2 -2
- package/package.json +5 -4
- package/popover/README.md +8 -34
- package/stepper/README.md +49 -8
- package/tabs/README.md +6 -6
- package/theming/components/cngx-async.css +74 -0
- package/theming/components/cngx-backdrop.css +73 -0
- package/theming/components/cngx-badge.css +340 -0
- package/theming/components/cngx-bottom-sheet.css +201 -0
- package/theming/components/cngx-button-toggle.css +99 -0
- package/theming/components/cngx-dialog.css +358 -0
- package/theming/components/cngx-divider.css +145 -0
- package/theming/components/cngx-listbox.css +220 -0
- package/theming/components/cngx-menu.css +371 -0
- package/theming/components/cngx-ripple.css +116 -0
- package/theming/components/cngx-tooltip.css +265 -0
- package/theming/system-tokens.css +24 -0
- package/types/cngx-common-a11y.d.ts +136 -36
- package/types/cngx-common-card.d.ts +137 -22
- package/types/cngx-common-chart.d.ts +337 -40
- package/types/cngx-common-data.d.ts +277 -45
- package/types/cngx-common-dialog.d.ts +162 -22
- package/types/cngx-common-display.d.ts +422 -78
- package/types/cngx-common-interactive.d.ts +1862 -305
- package/types/cngx-common-layout.d.ts +191 -28
- package/types/cngx-common-popover.d.ts +632 -87
- package/types/cngx-common-stepper.d.ts +1110 -38
- package/types/cngx-common-tabs.d.ts +306 -32
- package/types/cngx-common.d.ts +1 -1
- package/README.md +0 -18
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @overview
|
|
3
|
+
* Theming bridge for the `CngxDialog` directive. Targets
|
|
4
|
+
* `<dialog cngxDialog>` and the sibling `[cngxDialogDraggable]`
|
|
5
|
+
* variant. The directive toggles transition classes
|
|
6
|
+
* (`cngx-dialog--opening` / `-open` / `-closing`) on the host;
|
|
7
|
+
* this stylesheet only paints. The `::backdrop` pseudo is part of
|
|
8
|
+
* the `<dialog>` element itself, so no separate overlay node ships.
|
|
9
|
+
*
|
|
10
|
+
* **State modifiers**
|
|
11
|
+
*
|
|
12
|
+
* - `--opening` - opacity 0, translateY(8px) scale(0.98)
|
|
13
|
+
* - `--open` - opacity 1, translateY(0) scale(1)
|
|
14
|
+
* - `--closing` - opacity 0, translateY(8px) scale(0.98)
|
|
15
|
+
*
|
|
16
|
+
* Suppressed under `prefers-reduced-motion: reduce` (host + backdrop).
|
|
17
|
+
*
|
|
18
|
+
* **Draggable variant**
|
|
19
|
+
*
|
|
20
|
+
* `[cngxDialogDraggable]` applies the same opacity / scale curve plus
|
|
21
|
+
* a `translate(--cngx-dialog-x, --cngx-dialog-y)` the directive
|
|
22
|
+
* updates from pointer position. `.cngx-dialog--dragging` disables
|
|
23
|
+
* the transition so the surface tracks the pointer 1:1.
|
|
24
|
+
*
|
|
25
|
+
* **Backdrop**
|
|
26
|
+
*
|
|
27
|
+
* The `::backdrop` pseudo reads three inheriting tokens off the
|
|
28
|
+
* dialog host so `CngxDialogStack` can suppress the inner scrim
|
|
29
|
+
* inline while a parent dialog is open:
|
|
30
|
+
*
|
|
31
|
+
* - `--cngx-dialog-backdrop-bg` - default 50% black
|
|
32
|
+
* - `--cngx-dialog-backdrop-blur` - default 0px (frosted-glass opt-in)
|
|
33
|
+
* - `--cngx-dialog-backdrop-opacity` - default 1; stack toggles
|
|
34
|
+
* - `--cngx-dialog-backdrop-transition` - default `none` so stack
|
|
35
|
+
* swaps snap (a fade would flash inner dialogs through half-scrim)
|
|
36
|
+
*
|
|
37
|
+
* **Inheritance**
|
|
38
|
+
*
|
|
39
|
+
* Surface and shadow track the foundation:
|
|
40
|
+
*
|
|
41
|
+
* - `--cngx-dialog-bg` -> `--cngx-color-surface`
|
|
42
|
+
* - `--cngx-dialog-color` -> `currentColor`
|
|
43
|
+
* - `--cngx-dialog-border` -> `none` (Material outlined opts in)
|
|
44
|
+
*
|
|
45
|
+
* **Dark mode**
|
|
46
|
+
*
|
|
47
|
+
* Three hooks (`prefers-color-scheme: dark`, `[data-color-scheme="dark"]`,
|
|
48
|
+
* `.dark`) deepen `--cngx-dialog-shadow` from 12% to 50% black so the
|
|
49
|
+
* dialog still reads as elevated against the dark page. Surface bg
|
|
50
|
+
* rides the foundation cascade unchanged.
|
|
51
|
+
*
|
|
52
|
+
* **Pair with**
|
|
53
|
+
*
|
|
54
|
+
* - `@cngx/themes/material/dialog-theme` - Material 3 surface + elevation
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
@layer cngx.tokens {
|
|
58
|
+
/**
|
|
59
|
+
* Dialog surface color. Falls back through `--cngx-color-surface`.
|
|
60
|
+
* @group Surface
|
|
61
|
+
* @see [[--cngx-color-surface]]
|
|
62
|
+
*/
|
|
63
|
+
@property --cngx-dialog-bg {
|
|
64
|
+
syntax: '<color>';
|
|
65
|
+
inherits: true;
|
|
66
|
+
initial-value: oklch(1 0 0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Dialog text color. Defaults to `currentColor`.
|
|
71
|
+
* @group Surface
|
|
72
|
+
*/
|
|
73
|
+
@property --cngx-dialog-color {
|
|
74
|
+
syntax: '*';
|
|
75
|
+
inherits: true;
|
|
76
|
+
initial-value: currentColor;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Drop-shadow shorthand for the dialog. `inherits: true` so the
|
|
81
|
+
* :root dark-mode override reaches the open dialog element.
|
|
82
|
+
* @group Surface
|
|
83
|
+
*/
|
|
84
|
+
@property --cngx-dialog-shadow {
|
|
85
|
+
syntax: '*';
|
|
86
|
+
inherits: true;
|
|
87
|
+
initial-value: 0 8px 32px oklch(0 0 0 / 0.12);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Border shorthand of the dialog. `none` by default; brand themes or
|
|
92
|
+
* Material outlined variants set this to a 1px ring without forking
|
|
93
|
+
* the component CSS.
|
|
94
|
+
* @group Surface
|
|
95
|
+
*/
|
|
96
|
+
@property --cngx-dialog-border {
|
|
97
|
+
syntax: '*';
|
|
98
|
+
inherits: false;
|
|
99
|
+
initial-value: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Corner radius of the dialog.
|
|
104
|
+
* @group Layout
|
|
105
|
+
*/
|
|
106
|
+
@property --cngx-dialog-border-radius {
|
|
107
|
+
syntax: '<length>';
|
|
108
|
+
inherits: false;
|
|
109
|
+
initial-value: 8px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Padding shorthand inside the dialog.
|
|
114
|
+
* @group Layout
|
|
115
|
+
*/
|
|
116
|
+
@property --cngx-dialog-padding {
|
|
117
|
+
syntax: '<length>';
|
|
118
|
+
inherits: false;
|
|
119
|
+
initial-value: 24px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Maximum inline size of the dialog. `<length-percentage>` so
|
|
124
|
+
* consumers (e.g. CngxBottomSheet) can override with `100%`
|
|
125
|
+
* without falling back to the initial-value via syntax rejection.
|
|
126
|
+
* @group Layout
|
|
127
|
+
*/
|
|
128
|
+
@property --cngx-dialog-max-width {
|
|
129
|
+
syntax: '<length-percentage>';
|
|
130
|
+
inherits: false;
|
|
131
|
+
initial-value: 560px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Maximum block size of the dialog.
|
|
136
|
+
* @group Layout
|
|
137
|
+
*/
|
|
138
|
+
@property --cngx-dialog-max-height {
|
|
139
|
+
syntax: '*';
|
|
140
|
+
inherits: false;
|
|
141
|
+
initial-value: 80vh;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Background of the `::backdrop` pseudo-element. `inherits: true`
|
|
146
|
+
* so a consumer override on `dialog[cngxDialog]` reaches the
|
|
147
|
+
* `::backdrop` pseudo (pseudo-elements inherit from the originating
|
|
148
|
+
* element, but only when the registered property allows it).
|
|
149
|
+
* @group Surface
|
|
150
|
+
*/
|
|
151
|
+
@property --cngx-dialog-backdrop-bg {
|
|
152
|
+
syntax: '<color>';
|
|
153
|
+
inherits: true;
|
|
154
|
+
initial-value: oklch(0 0 0 / 0.5);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Blur radius applied to the `::backdrop`. Zero by default; bump to
|
|
159
|
+
* apply a frosted-glass effect. `inherits: true` so the override
|
|
160
|
+
* cascades to the `::backdrop` pseudo.
|
|
161
|
+
* @group Surface
|
|
162
|
+
*/
|
|
163
|
+
@property --cngx-dialog-backdrop-blur {
|
|
164
|
+
syntax: '<length>';
|
|
165
|
+
inherits: true;
|
|
166
|
+
initial-value: 0px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Opacity of the `::backdrop`. `CngxDialogStack` uses this to
|
|
171
|
+
* suppress the inner backdrop while a parent dialog is also open
|
|
172
|
+
* (avoids stacked scrim). `inherits: true` is load-bearing - the
|
|
173
|
+
* directive sets this token inline on the dialog element, and the
|
|
174
|
+
* `::backdrop` pseudo only reads it if the registered property
|
|
175
|
+
* inherits from the originating element.
|
|
176
|
+
* @group Surface
|
|
177
|
+
*/
|
|
178
|
+
@property --cngx-dialog-backdrop-opacity {
|
|
179
|
+
syntax: '<number>';
|
|
180
|
+
inherits: true;
|
|
181
|
+
initial-value: 1;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Transition shorthand applied to the `::backdrop`. Default `none`
|
|
186
|
+
* keeps the snap-in behaviour `CngxDialogStack` depends on (toggling
|
|
187
|
+
* backdrop-opacity between nested dialogs must not animate, or the
|
|
188
|
+
* inner dialog open flashes through a half-opacity scrim). Single
|
|
189
|
+
* non-stacked dialogs can opt in to a fade by setting this to e.g.
|
|
190
|
+
* `opacity 150ms ease`. `inherits: true` so the override cascades
|
|
191
|
+
* to the `::backdrop` pseudo from the dialog host.
|
|
192
|
+
* @group Motion
|
|
193
|
+
*/
|
|
194
|
+
@property --cngx-dialog-backdrop-transition {
|
|
195
|
+
syntax: '*';
|
|
196
|
+
inherits: true;
|
|
197
|
+
initial-value: none;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Duration of the open / close transition.
|
|
202
|
+
* @group Motion
|
|
203
|
+
*/
|
|
204
|
+
@property --cngx-dialog-transition-duration {
|
|
205
|
+
syntax: '<time>';
|
|
206
|
+
inherits: false;
|
|
207
|
+
initial-value: 200ms;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Easing curve of the open / close transition.
|
|
212
|
+
* @group Motion
|
|
213
|
+
*/
|
|
214
|
+
@property --cngx-dialog-transition-easing {
|
|
215
|
+
syntax: '*';
|
|
216
|
+
inherits: false;
|
|
217
|
+
initial-value: ease;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Cursor shown over the draggable variant while resting.
|
|
222
|
+
* @group State / Draggable
|
|
223
|
+
*/
|
|
224
|
+
@property --cngx-dialog-drag-cursor {
|
|
225
|
+
syntax: '*';
|
|
226
|
+
inherits: false;
|
|
227
|
+
initial-value: grab;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Cursor shown over the draggable variant while dragging.
|
|
232
|
+
* @group State / Draggable
|
|
233
|
+
*/
|
|
234
|
+
@property --cngx-dialog-dragging-cursor {
|
|
235
|
+
syntax: '*';
|
|
236
|
+
inherits: false;
|
|
237
|
+
initial-value: grabbing;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Focus-ring shorthand applied via `outline` on `:focus-visible` of
|
|
242
|
+
* the dialog host itself. Relevant when no autofocus target exists
|
|
243
|
+
* inside the dialog and AT focuses the `<dialog>` element directly.
|
|
244
|
+
* Default `auto` keeps the browser-native focus indicator.
|
|
245
|
+
* @group State / Focus
|
|
246
|
+
*/
|
|
247
|
+
@property --cngx-dialog-focus-outline {
|
|
248
|
+
syntax: '*';
|
|
249
|
+
inherits: false;
|
|
250
|
+
initial-value: auto;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* Delegating tokens - :root pulls foundation surface so the dialog
|
|
254
|
+
* bg follows whichever light/dark value the foundation has resolved. */
|
|
255
|
+
:root {
|
|
256
|
+
--cngx-dialog-bg: var(--cngx-color-surface);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* Dark-mode swap - shadow deepens so the dialog still reads as
|
|
260
|
+
* elevated over the dark page (a 12% black wash disappears on
|
|
261
|
+
* dark surfaces). */
|
|
262
|
+
@media (prefers-color-scheme: dark) {
|
|
263
|
+
:root:not([data-color-scheme='light']):not(.light) {
|
|
264
|
+
--cngx-dialog-shadow: 0 8px 32px oklch(0 0 0 / 0.5);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
[data-color-scheme='dark'],
|
|
268
|
+
.dark {
|
|
269
|
+
--cngx-dialog-shadow: 0 8px 32px oklch(0 0 0 / 0.5);
|
|
270
|
+
}
|
|
271
|
+
[data-color-scheme='light'],
|
|
272
|
+
.light {
|
|
273
|
+
--cngx-dialog-shadow: 0 8px 32px oklch(0 0 0 / 0.12);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
@layer cngx.components {
|
|
278
|
+
@scope (dialog[cngxDialog]) {
|
|
279
|
+
:scope {
|
|
280
|
+
border: var(--cngx-dialog-border, none);
|
|
281
|
+
border-radius: var(--cngx-dialog-border-radius, 8px);
|
|
282
|
+
padding: var(--cngx-dialog-padding, 24px);
|
|
283
|
+
max-width: var(--cngx-dialog-max-width, 560px);
|
|
284
|
+
max-height: var(--cngx-dialog-max-height, 80vh);
|
|
285
|
+
width: 100%;
|
|
286
|
+
background: var(--cngx-dialog-bg, var(--cngx-color-surface, oklch(1 0 0)));
|
|
287
|
+
color: var(--cngx-dialog-color, inherit);
|
|
288
|
+
box-shadow: var(--cngx-dialog-shadow, 0 8px 32px oklch(0 0 0 / 0.12));
|
|
289
|
+
overflow: auto;
|
|
290
|
+
scrollbar-gutter: stable both-edges;
|
|
291
|
+
transition:
|
|
292
|
+
opacity var(--cngx-dialog-transition-duration, 200ms)
|
|
293
|
+
var(--cngx-dialog-transition-easing, ease),
|
|
294
|
+
transform var(--cngx-dialog-transition-duration, 200ms)
|
|
295
|
+
var(--cngx-dialog-transition-easing, ease);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
:scope:focus-visible {
|
|
299
|
+
outline: var(--cngx-dialog-focus-outline, auto);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* Backdrop is part of the dialog element itself (::backdrop pseudo).
|
|
303
|
+
The opacity token controls visibility (CngxDialogStack uses this for
|
|
304
|
+
nesting). Default transition is `none` so toggling backdrop-opacity
|
|
305
|
+
between stacked dialogs snaps - a fade here would flash the inner
|
|
306
|
+
dialog through a half-opacity scrim. Single dialogs can opt in via
|
|
307
|
+
--cngx-dialog-backdrop-transition. */
|
|
308
|
+
:scope::backdrop {
|
|
309
|
+
background: var(--cngx-dialog-backdrop-bg, oklch(0 0 0 / 0.5));
|
|
310
|
+
opacity: var(--cngx-dialog-backdrop-opacity, 1);
|
|
311
|
+
backdrop-filter: blur(var(--cngx-dialog-backdrop-blur, 0px));
|
|
312
|
+
transition: var(--cngx-dialog-backdrop-transition, none);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
:scope.cngx-dialog--opening {
|
|
316
|
+
opacity: 0;
|
|
317
|
+
transform: translateY(8px) scale(0.98);
|
|
318
|
+
}
|
|
319
|
+
:scope.cngx-dialog--open {
|
|
320
|
+
opacity: 1;
|
|
321
|
+
transform: translateY(0) scale(1);
|
|
322
|
+
}
|
|
323
|
+
:scope.cngx-dialog--closing {
|
|
324
|
+
opacity: 0;
|
|
325
|
+
transform: translateY(8px) scale(0.98);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
@media (prefers-reduced-motion: reduce) {
|
|
329
|
+
:scope {
|
|
330
|
+
transition: none;
|
|
331
|
+
}
|
|
332
|
+
:scope::backdrop {
|
|
333
|
+
transition: none;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
@scope (dialog[cngxDialogDraggable]) {
|
|
339
|
+
:scope {
|
|
340
|
+
transform: translate(var(--cngx-dialog-x, 0px), var(--cngx-dialog-y, 0px));
|
|
341
|
+
}
|
|
342
|
+
:scope.cngx-dialog--opening {
|
|
343
|
+
transform: translate(var(--cngx-dialog-x, 0px), var(--cngx-dialog-y, 0px)) scale(0.98);
|
|
344
|
+
opacity: 0;
|
|
345
|
+
}
|
|
346
|
+
:scope.cngx-dialog--open {
|
|
347
|
+
transform: translate(var(--cngx-dialog-x, 0px), var(--cngx-dialog-y, 0px)) scale(1);
|
|
348
|
+
opacity: 1;
|
|
349
|
+
}
|
|
350
|
+
:scope.cngx-dialog--closing {
|
|
351
|
+
transform: translate(var(--cngx-dialog-x, 0px), var(--cngx-dialog-y, 0px)) scale(0.98);
|
|
352
|
+
opacity: 0;
|
|
353
|
+
}
|
|
354
|
+
:scope.cngx-dialog--dragging {
|
|
355
|
+
transition: none;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @overview
|
|
3
|
+
* Theming bridge for the `CngxDivider` directive. The directive sets
|
|
4
|
+
* `cngx-divider` plus the `--vertical` and `--inset` modifier classes
|
|
5
|
+
* from its inputs and communicates orientation to AT via
|
|
6
|
+
* `aria-orientation`; this stylesheet paints the line.
|
|
7
|
+
*
|
|
8
|
+
* **Variants**
|
|
9
|
+
*
|
|
10
|
+
* - default - horizontal hairline, `margin-block` breathing room
|
|
11
|
+
* - `--vertical` - inline-block column, `margin-inline` breathing room,
|
|
12
|
+
* `align-self: stretch` so it fills its flex parent
|
|
13
|
+
* - `--inset` - drops the line in from the start/end edge to align
|
|
14
|
+
* with indented list content; stacks with `--vertical`
|
|
15
|
+
*
|
|
16
|
+
* **Inheritance**
|
|
17
|
+
*
|
|
18
|
+
* Stroke color tracks the foundation neutral instead of carrying its
|
|
19
|
+
* own tone:
|
|
20
|
+
*
|
|
21
|
+
* - `--cngx-divider-color` -> `--cngx-color-border`
|
|
22
|
+
* - `--cngx-divider-spacing` -> `--cngx-space-sm`
|
|
23
|
+
* - `--cngx-divider-inset-amount` -> `--cngx-space-md`
|
|
24
|
+
*
|
|
25
|
+
* **Dark mode**
|
|
26
|
+
*
|
|
27
|
+
* Three hooks (`prefers-color-scheme: dark`, `[data-color-scheme="dark"]`,
|
|
28
|
+
* `.dark`) override `--cngx-divider-color` to a brighter neutral
|
|
29
|
+
* (~3.2:1 against the dark surface). The foundation `--cngx-color-border`
|
|
30
|
+
* is tuned conservatively (~1.7:1) and would fail WCAG 1.4.11 for a
|
|
31
|
+
* graphical separator; other border consumers keep the conservative
|
|
32
|
+
* default.
|
|
33
|
+
*
|
|
34
|
+
* **Pair with**
|
|
35
|
+
*
|
|
36
|
+
* - `@cngx/themes/material/divider-theme` - Material 3 outline-variant
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
@layer cngx.tokens {
|
|
40
|
+
/**
|
|
41
|
+
* Stroke thickness of the divider line. 1px reads as a hairline at
|
|
42
|
+
* the default zoom; bump to 2px for emphasis without going to a
|
|
43
|
+
* heavier shape.
|
|
44
|
+
* @group Layout
|
|
45
|
+
*/
|
|
46
|
+
@property --cngx-divider-thickness {
|
|
47
|
+
syntax: '<length>';
|
|
48
|
+
inherits: false;
|
|
49
|
+
initial-value: 1px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Stroke color. Falls back through `--cngx-color-border` so the
|
|
54
|
+
* divider tracks the foundation neutral instead of carrying its own
|
|
55
|
+
* tone.
|
|
56
|
+
* @group Surface
|
|
57
|
+
* @see [[--cngx-color-border]]
|
|
58
|
+
*/
|
|
59
|
+
@property --cngx-divider-color {
|
|
60
|
+
syntax: '<color>';
|
|
61
|
+
inherits: true;
|
|
62
|
+
initial-value: oklch(0.9 0.01 250);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Breathing room around the divider - `margin-block` for horizontal,
|
|
67
|
+
* `margin-inline` for vertical. Defaults to `--cngx-space-sm`.
|
|
68
|
+
* @group Layout
|
|
69
|
+
*/
|
|
70
|
+
@property --cngx-divider-spacing {
|
|
71
|
+
syntax: '<length>';
|
|
72
|
+
inherits: false;
|
|
73
|
+
initial-value: 8px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Inset distance applied by the `.cngx-divider--inset` modifier -
|
|
78
|
+
* drops the line in from the start/end edge so it visually aligns
|
|
79
|
+
* with indented list content.
|
|
80
|
+
* @group Variant / Inset
|
|
81
|
+
*/
|
|
82
|
+
@property --cngx-divider-inset-amount {
|
|
83
|
+
syntax: '<length>';
|
|
84
|
+
inherits: false;
|
|
85
|
+
initial-value: 16px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Delegating token - :root pulls foundation border so the divider
|
|
89
|
+
* tracks whichever light/dark value the foundation has resolved. */
|
|
90
|
+
:root {
|
|
91
|
+
--cngx-divider-color: var(--cngx-color-border);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Dark-mode contrast lift - the foundation `--cngx-color-border` is
|
|
95
|
+
* tuned conservatively (browser-native aesthetic) and resolves to
|
|
96
|
+
* roughly 1.7:1 against the dark surface, which fails WCAG 2.1 SC
|
|
97
|
+
* 1.4.11 (Non-text Contrast 3:1) for a separator. Dividers are
|
|
98
|
+
* graphical UI components, so we override locally with a brighter
|
|
99
|
+
* neutral that lands around 3.2:1 against `--cngx-color-surface` in
|
|
100
|
+
* dark mode. Other border consumers keep the conservative default. */
|
|
101
|
+
@media (prefers-color-scheme: dark) {
|
|
102
|
+
:root:not([data-color-scheme='light']):not(.light) {
|
|
103
|
+
--cngx-divider-color: oklch(0.45 0.005 250);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
[data-color-scheme='dark'],
|
|
107
|
+
.dark {
|
|
108
|
+
--cngx-divider-color: oklch(0.45 0.005 250);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@layer cngx.components {
|
|
113
|
+
@scope (.cngx-divider) {
|
|
114
|
+
/* Horizontal default - full-width thin line, vertical breathing room. */
|
|
115
|
+
:scope {
|
|
116
|
+
display: block;
|
|
117
|
+
box-sizing: border-box;
|
|
118
|
+
width: 100%;
|
|
119
|
+
height: var(--cngx-divider-thickness, 1px);
|
|
120
|
+
margin-block: var(--cngx-divider-spacing, var(--cngx-space-sm, 8px));
|
|
121
|
+
margin-inline: 0;
|
|
122
|
+
border: 0;
|
|
123
|
+
background: var(--cngx-divider-color, var(--cngx-color-border, oklch(0.9 0.01 250)));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Vertical variant - thin column, horizontal breathing room. */
|
|
127
|
+
:scope.cngx-divider--vertical {
|
|
128
|
+
display: inline-block;
|
|
129
|
+
width: var(--cngx-divider-thickness, 1px);
|
|
130
|
+
height: 1em;
|
|
131
|
+
margin-block: 0;
|
|
132
|
+
margin-inline: var(--cngx-divider-spacing, var(--cngx-space-sm, 8px));
|
|
133
|
+
align-self: stretch;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Inset variant - drops the line in from the start/end edge. */
|
|
137
|
+
:scope.cngx-divider--inset {
|
|
138
|
+
margin-inline: var(--cngx-divider-inset-amount, var(--cngx-space-md, 16px));
|
|
139
|
+
}
|
|
140
|
+
:scope.cngx-divider--vertical.cngx-divider--inset {
|
|
141
|
+
margin-block: var(--cngx-divider-inset-amount, var(--cngx-space-md, 16px));
|
|
142
|
+
margin-inline: var(--cngx-divider-spacing, var(--cngx-space-sm, 8px));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|