@cngx/common 0.0.1-rc.0 → 0.1.0-rc.1

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.
Files changed (61) hide show
  1. package/a11y/README.md +13 -16
  2. package/card/README.md +2 -21
  3. package/chart/README.md +5 -8
  4. package/data/README.md +45 -47
  5. package/dialog/README.md +12 -15
  6. package/display/README.md +5 -9
  7. package/fesm2022/cngx-common-a11y.mjs +164 -51
  8. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  9. package/fesm2022/cngx-common-card.mjs +157 -69
  10. package/fesm2022/cngx-common-card.mjs.map +1 -1
  11. package/fesm2022/cngx-common-chart.mjs +389 -92
  12. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  13. package/fesm2022/cngx-common-data.mjs +311 -151
  14. package/fesm2022/cngx-common-data.mjs.map +1 -1
  15. package/fesm2022/cngx-common-dialog.mjs +167 -29
  16. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  17. package/fesm2022/cngx-common-display.mjs +445 -110
  18. package/fesm2022/cngx-common-display.mjs.map +1 -1
  19. package/fesm2022/cngx-common-interactive.mjs +2059 -435
  20. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  21. package/fesm2022/cngx-common-layout.mjs +188 -31
  22. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  23. package/fesm2022/cngx-common-popover.mjs +711 -90
  24. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  25. package/fesm2022/cngx-common-stepper.mjs +1479 -73
  26. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  27. package/fesm2022/cngx-common-tabs.mjs +1144 -85
  28. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  29. package/fesm2022/cngx-common.mjs +2 -2
  30. package/fesm2022/cngx-common.mjs.map +1 -1
  31. package/interactive/README.md +5 -5
  32. package/layout/README.md +2 -2
  33. package/package.json +7 -6
  34. package/popover/README.md +8 -34
  35. package/stepper/README.md +69 -8
  36. package/tabs/README.md +6 -6
  37. package/theming/components/cngx-async.css +74 -0
  38. package/theming/components/cngx-backdrop.css +73 -0
  39. package/theming/components/cngx-badge.css +340 -0
  40. package/theming/components/cngx-bottom-sheet.css +201 -0
  41. package/theming/components/cngx-button-toggle.css +99 -0
  42. package/theming/components/cngx-dialog.css +358 -0
  43. package/theming/components/cngx-divider.css +145 -0
  44. package/theming/components/cngx-listbox.css +220 -0
  45. package/theming/components/cngx-menu.css +371 -0
  46. package/theming/components/cngx-ripple.css +116 -0
  47. package/theming/components/cngx-tooltip.css +265 -0
  48. package/theming/system-tokens.css +24 -0
  49. package/types/cngx-common-a11y.d.ts +159 -38
  50. package/types/cngx-common-card.d.ts +137 -22
  51. package/types/cngx-common-chart.d.ts +337 -40
  52. package/types/cngx-common-data.d.ts +277 -45
  53. package/types/cngx-common-dialog.d.ts +162 -22
  54. package/types/cngx-common-display.d.ts +422 -78
  55. package/types/cngx-common-interactive.d.ts +1880 -305
  56. package/types/cngx-common-layout.d.ts +191 -28
  57. package/types/cngx-common-popover.d.ts +632 -87
  58. package/types/cngx-common-stepper.d.ts +1360 -45
  59. package/types/cngx-common-tabs.d.ts +1139 -56
  60. package/types/cngx-common.d.ts +1 -1
  61. package/README.md +0 -18
@@ -0,0 +1,340 @@
1
+ /**
2
+ * @overview
3
+ * Theming bridge for the `CngxBadge` directive. The directive injects
4
+ * a `<span class="cngx-badge-indicator …">` into the host and toggles
5
+ * modifier classes for color, position, and dot mode. Importing this
6
+ * file paints the defaults; consumers who want their own visuals
7
+ * style `.cngx-badge-indicator` directly.
8
+ *
9
+ * **Color variants**
10
+ *
11
+ * - `--primary` - foundation primary, white text
12
+ * - `--error` - foundation danger, white text
13
+ * - `--warning` - foundation warning, dark text
14
+ * - `--neutral` - muted grey, white text
15
+ *
16
+ * **Position variants**
17
+ *
18
+ * - `--inline` - flows next to host content, borderless
19
+ * - `--above-start`, `--above-end` - top corner anchor, translated
20
+ * half-out via `transform`
21
+ * - `--below-start`, `--below-end` - bottom corner anchor, same
22
+ * half-out translate
23
+ *
24
+ * Corner variants get the `--cngx-badge-border` ring; `inline` is
25
+ * always borderless.
26
+ *
27
+ * **Dot mode**
28
+ *
29
+ * `.cngx-badge-indicator--dot` shrinks to a fixed `--cngx-badge-dot-size`
30
+ * pill with zero padding for textless status indicators.
31
+ *
32
+ * **Inheritance**
33
+ *
34
+ * Variant tokens fall back to the foundation semantic palette:
35
+ *
36
+ * - `--cngx-badge-primary-bg` -> `--cngx-color-primary`
37
+ * - `--cngx-badge-error-bg` -> `--cngx-color-danger`
38
+ * - `--cngx-badge-warning-bg` -> `--cngx-color-warning`
39
+ * - `--cngx-badge-neutral-bg` -> static neutral (no foundation token)
40
+ *
41
+ * **Dark mode**
42
+ *
43
+ * Three hooks (`prefers-color-scheme: dark`, `[data-color-scheme="dark"]`,
44
+ * `.dark`) repaint `--cngx-badge-border` when consumers opt in to a
45
+ * cut-out ring via `--cngx-badge-border-dark` / `-light`. Default
46
+ * border is `0` (no ring), so the dark-mode block is a no-op until
47
+ * a consumer sets the ring tokens.
48
+ */
49
+
50
+ @layer cngx.tokens {
51
+ /**
52
+ * Diameter (and minimum width) of the indicator pill in text mode.
53
+ * @group Layout
54
+ */
55
+ @property --cngx-badge-size {
56
+ syntax: '<length>';
57
+ inherits: false;
58
+ initial-value: 16px;
59
+ }
60
+
61
+ /**
62
+ * Diameter of the indicator in `--dot` mode (no text).
63
+ * @group Variant / Dot
64
+ */
65
+ @property --cngx-badge-dot-size {
66
+ syntax: '<length>';
67
+ inherits: false;
68
+ initial-value: 8px;
69
+ }
70
+
71
+ /**
72
+ * Inline padding around the badge text. Capped at 3px so a single-digit
73
+ * count fits within the 16px min-width and renders as a true circle;
74
+ * multi-character content widens the pill naturally.
75
+ * @group Layout
76
+ */
77
+ @property --cngx-badge-padding-inline {
78
+ syntax: '<length>';
79
+ inherits: false;
80
+ initial-value: 3px;
81
+ }
82
+
83
+ /**
84
+ * Corner radius. Defaults to the pill radius via `--cngx-radius-pill`.
85
+ * @group Layout
86
+ */
87
+ @property --cngx-badge-radius {
88
+ syntax: '<length>';
89
+ inherits: false;
90
+ initial-value: 999px;
91
+ }
92
+
93
+ /**
94
+ * Gap between the host content and the indicator in the `inline`
95
+ * position variant. Has no effect on corner anchors.
96
+ * @group Layout / Inline
97
+ */
98
+ @property --cngx-badge-inline-gap {
99
+ syntax: '*';
100
+ inherits: false;
101
+ initial-value: 0.375rem;
102
+ }
103
+
104
+ /**
105
+ * Font-size of the badge text.
106
+ * @group Typography
107
+ */
108
+ @property --cngx-badge-font-size {
109
+ syntax: '*';
110
+ inherits: false;
111
+ initial-value: 0.6875rem;
112
+ }
113
+
114
+ /**
115
+ * Font-weight of the badge text.
116
+ * @group Typography
117
+ */
118
+ @property --cngx-badge-font-weight {
119
+ syntax: '*';
120
+ inherits: false;
121
+ initial-value: 600;
122
+ }
123
+
124
+ /**
125
+ * Ring around the badge. Defaults to `0` so the indicator reads as a
126
+ * solid pill that sits flush on its host (the dot variant in
127
+ * particular would shrink to a single visible pixel under a 2px ring).
128
+ * Set a non-zero border at consumer level when the badge needs to
129
+ * cut out from a busy host surface - e.g. `--cngx-badge-border: 2px
130
+ * solid var(--mat-sys-surface)`. Only applied in the corner variants
131
+ * (`above-*` / `below-*`); the `inline` variant is borderless either
132
+ * way. `inherits: true` so a single `:root` override reaches every
133
+ * indicator span at once.
134
+ * @group Surface
135
+ */
136
+ @property --cngx-badge-border {
137
+ syntax: '*';
138
+ inherits: true;
139
+ initial-value: 0;
140
+ }
141
+
142
+ /**
143
+ * Background of the primary variant. Falls back to
144
+ * `--cngx-color-primary`.
145
+ * @group Variant / Primary
146
+ * @see [[--cngx-color-primary]]
147
+ */
148
+ @property --cngx-badge-primary-bg {
149
+ syntax: '<color>';
150
+ inherits: true;
151
+ initial-value: oklch(0.66 0.19 50);
152
+ }
153
+
154
+ /**
155
+ * Text color of the primary variant.
156
+ * @group Variant / Primary
157
+ */
158
+ @property --cngx-badge-primary-color {
159
+ syntax: '<color>';
160
+ inherits: true;
161
+ initial-value: oklch(1 0 0);
162
+ }
163
+
164
+ /**
165
+ * Background of the error variant. Falls back to `--cngx-color-danger`.
166
+ * @group Variant / Error
167
+ * @see [[--cngx-color-danger]]
168
+ */
169
+ @property --cngx-badge-error-bg {
170
+ syntax: '<color>';
171
+ inherits: true;
172
+ initial-value: oklch(0.62 0.22 25);
173
+ }
174
+
175
+ /**
176
+ * Text color of the error variant.
177
+ * @group Variant / Error
178
+ */
179
+ @property --cngx-badge-error-color {
180
+ syntax: '<color>';
181
+ inherits: true;
182
+ initial-value: oklch(1 0 0);
183
+ }
184
+
185
+ /**
186
+ * Background of the warning variant. Falls back to `--cngx-color-warning`.
187
+ * @group Variant / Warning
188
+ * @see [[--cngx-color-warning]]
189
+ */
190
+ @property --cngx-badge-warning-bg {
191
+ syntax: '<color>';
192
+ inherits: true;
193
+ initial-value: oklch(0.65 0.2 70);
194
+ }
195
+
196
+ /**
197
+ * Text color of the warning variant.
198
+ * @group Variant / Warning
199
+ */
200
+ @property --cngx-badge-warning-color {
201
+ syntax: '<color>';
202
+ inherits: true;
203
+ initial-value: oklch(0.2 0.01 250);
204
+ }
205
+
206
+ /**
207
+ * Background of the neutral variant.
208
+ * @group Variant / Neutral
209
+ */
210
+ @property --cngx-badge-neutral-bg {
211
+ syntax: '<color>';
212
+ inherits: true;
213
+ initial-value: oklch(0.68 0.01 240);
214
+ }
215
+
216
+ /**
217
+ * Text color of the neutral variant.
218
+ * @group Variant / Neutral
219
+ */
220
+ @property --cngx-badge-neutral-color {
221
+ syntax: '<color>';
222
+ inherits: true;
223
+ initial-value: oklch(1 0 0);
224
+ }
225
+
226
+ /* Theming hook - `--cngx-badge-border` defaults to `0` (no ring) so
227
+ * the indicator reads as a flat pill on its host. Consumers that
228
+ * want a cut-out ring against a busy host surface can opt in at the
229
+ * root, e.g.:
230
+ *
231
+ * :root { --cngx-badge-border: 2px solid var(--mat-sys-surface); }
232
+ *
233
+ * Once opted in, the dark / light selectors below repaint the ring
234
+ * for the active color-scheme so it stays in contrast with the
235
+ * background. They are no-ops at the library default. */
236
+ @media (prefers-color-scheme: dark) {
237
+ :root:not([data-color-scheme='light']):not(.light) {
238
+ --cngx-badge-border: var(--cngx-badge-border-dark, var(--cngx-badge-border, 0));
239
+ }
240
+ }
241
+ [data-color-scheme='dark'],
242
+ .dark {
243
+ --cngx-badge-border: var(--cngx-badge-border-dark, var(--cngx-badge-border, 0));
244
+ }
245
+ [data-color-scheme='light'],
246
+ .light {
247
+ --cngx-badge-border: var(--cngx-badge-border-light, var(--cngx-badge-border, 0));
248
+ }
249
+ }
250
+
251
+ @layer cngx.components {
252
+ @scope (.cngx-badge-host) {
253
+ :scope {
254
+ position: relative;
255
+ }
256
+ }
257
+
258
+ /* The indicator lives outside the host class scope (it's a child of
259
+ * the host element, marked by the cngx-badge-host class) but ARIA
260
+ * conventions allow the indicator span to be scoped on its own. */
261
+ @scope (.cngx-badge-indicator) {
262
+ :scope {
263
+ display: inline-flex;
264
+ align-items: center;
265
+ justify-content: center;
266
+ box-sizing: border-box;
267
+ min-width: var(--cngx-badge-size, 16px);
268
+ height: var(--cngx-badge-size, 16px);
269
+ padding: 0 var(--cngx-badge-padding-inline, 3px);
270
+ border-radius: var(--cngx-badge-radius, var(--cngx-radius-pill, 999px));
271
+ font-size: var(--cngx-badge-font-size, 0.6875rem);
272
+ font-weight: var(--cngx-badge-font-weight, 600);
273
+ line-height: 1;
274
+ pointer-events: none;
275
+ user-select: none;
276
+ }
277
+
278
+ /* Dot mode - no text, fixed size */
279
+ :scope.cngx-badge-indicator--dot {
280
+ min-width: var(--cngx-badge-dot-size, 8px);
281
+ width: var(--cngx-badge-dot-size, 8px);
282
+ height: var(--cngx-badge-dot-size, 8px);
283
+ padding: 0;
284
+ }
285
+
286
+ /* Color variants */
287
+ :scope.cngx-badge-indicator--primary {
288
+ background: var(--cngx-badge-primary-bg, var(--cngx-color-primary, oklch(0.66 0.19 50)));
289
+ color: var(--cngx-badge-primary-color, oklch(1 0 0));
290
+ }
291
+ :scope.cngx-badge-indicator--error {
292
+ background: var(--cngx-badge-error-bg, var(--cngx-color-danger, oklch(0.62 0.22 25)));
293
+ color: var(--cngx-badge-error-color, oklch(1 0 0));
294
+ }
295
+ :scope.cngx-badge-indicator--warning {
296
+ background: var(--cngx-badge-warning-bg, var(--cngx-color-warning, oklch(0.65 0.2 70)));
297
+ color: var(--cngx-badge-warning-color, oklch(0.2 0.01 250));
298
+ }
299
+ :scope.cngx-badge-indicator--neutral {
300
+ background: var(--cngx-badge-neutral-bg, oklch(0.68 0.01 240));
301
+ color: var(--cngx-badge-neutral-color, oklch(1 0 0));
302
+ }
303
+
304
+ /* Position variants - corner anchors for non-inline placements,
305
+ * border ring contrasts the indicator against the host surface. */
306
+ :scope.cngx-badge-indicator--inline {
307
+ position: static;
308
+ border: 0;
309
+ margin-inline-start: var(--cngx-badge-inline-gap, 0.375rem);
310
+ }
311
+ :scope.cngx-badge-indicator--above-start {
312
+ position: absolute;
313
+ top: 0;
314
+ inset-inline-start: 0;
315
+ transform: translate(-50%, -50%);
316
+ border: var(--cngx-badge-border, 0);
317
+ }
318
+ :scope.cngx-badge-indicator--above-end {
319
+ position: absolute;
320
+ top: 0;
321
+ inset-inline-end: 0;
322
+ transform: translate(50%, -50%);
323
+ border: var(--cngx-badge-border, 0);
324
+ }
325
+ :scope.cngx-badge-indicator--below-start {
326
+ position: absolute;
327
+ bottom: 0;
328
+ inset-inline-start: 0;
329
+ transform: translate(-50%, 50%);
330
+ border: var(--cngx-badge-border, 0);
331
+ }
332
+ :scope.cngx-badge-indicator--below-end {
333
+ position: absolute;
334
+ bottom: 0;
335
+ inset-inline-end: 0;
336
+ transform: translate(50%, 50%);
337
+ border: var(--cngx-badge-border, 0);
338
+ }
339
+ }
340
+ }
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @overview
3
+ * Theming bridge for the `CngxBottomSheet` directive. Targets
4
+ * `<dialog class="cngx-bottom-sheet">` (used together with
5
+ * `cngxDialog`), overrides the UA top-layer centering for a
6
+ * bottom-anchored sheet, and paints a drag-handle pill via
7
+ * `::before`.
8
+ *
9
+ * **State modifiers**
10
+ *
11
+ * The `CngxDialog` state classes drive the slide-in transition:
12
+ *
13
+ * - `cngx-dialog--opening` - translateY(100%), opacity 0
14
+ * - `cngx-dialog--open` - translateY(0), opacity 1
15
+ * - `cngx-dialog--closing` - translateY(100%), opacity 0
16
+ *
17
+ * Suppressed under `prefers-reduced-motion: reduce`.
18
+ *
19
+ * **Inheritance**
20
+ *
21
+ * The scope re-pins the parent dialog tokens so the cngx-dialog
22
+ * shadow / transition rules reach the sheet without forking:
23
+ *
24
+ * - `--cngx-dialog-border-radius` <- `--cngx-bottom-sheet-radius`
25
+ * - `--cngx-dialog-padding` <- `--cngx-bottom-sheet-padding`
26
+ * - `--cngx-dialog-max-width` <- `--cngx-bottom-sheet-max-width`
27
+ * - `--cngx-dialog-max-height` <- `--cngx-bottom-sheet-max-height`
28
+ *
29
+ * **Dark mode**
30
+ *
31
+ * Three hooks (`prefers-color-scheme: dark`, `[data-color-scheme="dark"]`,
32
+ * `.dark`) flip `--cngx-bottom-sheet-handle-color` to a mid-tone grey
33
+ * so the drag affordance stays visible against the dark surface.
34
+ *
35
+ * **Pair with**
36
+ *
37
+ * - `@cngx/themes/material/bottom-sheet-theme` - Material 3 surface
38
+ */
39
+
40
+ @layer cngx.tokens {
41
+ /**
42
+ * Corner radius of the sheet. Defaults to rounded top corners only,
43
+ * matching the bottom-anchored anatomy.
44
+ * @group Layout
45
+ */
46
+ @property --cngx-bottom-sheet-radius {
47
+ syntax: '*';
48
+ inherits: false;
49
+ initial-value: 16px 16px 0 0;
50
+ }
51
+
52
+ /**
53
+ * Padding shorthand inside the sheet.
54
+ * @group Layout
55
+ */
56
+ @property --cngx-bottom-sheet-padding {
57
+ syntax: '<length>';
58
+ inherits: false;
59
+ initial-value: 24px;
60
+ }
61
+
62
+ /**
63
+ * Maximum inline size - full viewport by default.
64
+ * @group Layout
65
+ */
66
+ @property --cngx-bottom-sheet-max-width {
67
+ syntax: '*';
68
+ inherits: false;
69
+ initial-value: 100%;
70
+ }
71
+
72
+ /**
73
+ * Maximum block size - 80vh by default so the dismiss gesture has
74
+ * room above the sheet.
75
+ * @group Layout
76
+ */
77
+ @property --cngx-bottom-sheet-max-height {
78
+ syntax: '*';
79
+ inherits: false;
80
+ initial-value: 80vh;
81
+ }
82
+
83
+ /**
84
+ * Width of the drag handle pill.
85
+ * @group Layout
86
+ */
87
+ @property --cngx-bottom-sheet-handle-width {
88
+ syntax: '<length>';
89
+ inherits: false;
90
+ initial-value: 40px;
91
+ }
92
+
93
+ /**
94
+ * Height of the drag handle pill.
95
+ * @group Layout
96
+ */
97
+ @property --cngx-bottom-sheet-handle-height {
98
+ syntax: '<length>';
99
+ inherits: false;
100
+ initial-value: 4px;
101
+ }
102
+
103
+ /**
104
+ * Color of the drag handle pill. `inherits: true` so the :root
105
+ * cascade reaches the `::before` pseudo on the open dialog.
106
+ * @group Surface
107
+ */
108
+ @property --cngx-bottom-sheet-handle-color {
109
+ syntax: '<color>';
110
+ inherits: true;
111
+ initial-value: oklch(0.8 0.005 250);
112
+ }
113
+
114
+ /**
115
+ * Corner radius of the drag handle pill.
116
+ * @group Layout
117
+ */
118
+ @property --cngx-bottom-sheet-handle-radius {
119
+ syntax: '<length>';
120
+ inherits: false;
121
+ initial-value: 2px;
122
+ }
123
+
124
+ /**
125
+ * Margin shorthand around the drag handle - centres it horizontally
126
+ * and pushes the sheet content down.
127
+ * @group Layout
128
+ */
129
+ @property --cngx-bottom-sheet-handle-margin {
130
+ syntax: '*';
131
+ inherits: false;
132
+ initial-value: 0 auto 16px;
133
+ }
134
+
135
+ /* Dark-mode swap - handle inverts to a mid-tone gray so the drag
136
+ * affordance stays visible against the dark sheet surface. */
137
+ @media (prefers-color-scheme: dark) {
138
+ :root:not([data-color-scheme='light']):not(.light) {
139
+ --cngx-bottom-sheet-handle-color: oklch(0.5 0.005 250);
140
+ }
141
+ }
142
+ [data-color-scheme='dark'],
143
+ .dark {
144
+ --cngx-bottom-sheet-handle-color: oklch(0.5 0.005 250);
145
+ }
146
+ [data-color-scheme='light'],
147
+ .light {
148
+ --cngx-bottom-sheet-handle-color: oklch(0.8 0.005 250);
149
+ }
150
+ }
151
+
152
+ @layer cngx.components {
153
+ @scope (dialog.cngx-bottom-sheet) {
154
+ :scope {
155
+ margin: 0;
156
+ inset: auto 0 0 0;
157
+ width: 100%;
158
+ max-width: var(--cngx-bottom-sheet-max-width, 100%);
159
+ max-height: var(--cngx-bottom-sheet-max-height, 80vh);
160
+ border-radius: var(--cngx-bottom-sheet-radius, 16px 16px 0 0);
161
+ padding: var(--cngx-bottom-sheet-padding, 24px);
162
+
163
+ /* Rewrite parent dialog tokens so the cngx-dialog default styling
164
+ (transition, shadow, etc.) picks up bottom-sheet geometry. */
165
+ --cngx-dialog-border-radius: var(--cngx-bottom-sheet-radius, 16px 16px 0 0);
166
+ --cngx-dialog-padding: var(--cngx-bottom-sheet-padding, 24px);
167
+ --cngx-dialog-max-width: var(--cngx-bottom-sheet-max-width, 100%);
168
+ --cngx-dialog-max-height: var(--cngx-bottom-sheet-max-height, 80vh);
169
+ }
170
+
171
+ /* Drag handle. */
172
+ :scope::before {
173
+ content: '';
174
+ display: block;
175
+ width: var(--cngx-bottom-sheet-handle-width, 40px);
176
+ height: var(--cngx-bottom-sheet-handle-height, 4px);
177
+ background: var(--cngx-bottom-sheet-handle-color, oklch(0.8 0.005 250));
178
+ border-radius: var(--cngx-bottom-sheet-handle-radius, 2px);
179
+ margin: var(--cngx-bottom-sheet-handle-margin, 0 auto 16px);
180
+ }
181
+
182
+ :scope.cngx-dialog--opening {
183
+ opacity: 0;
184
+ transform: translateY(100%);
185
+ }
186
+ :scope.cngx-dialog--open {
187
+ opacity: 1;
188
+ transform: translateY(0);
189
+ }
190
+ :scope.cngx-dialog--closing {
191
+ opacity: 0;
192
+ transform: translateY(100%);
193
+ }
194
+
195
+ @media (prefers-reduced-motion: reduce) {
196
+ :scope {
197
+ transition: none;
198
+ }
199
+ }
200
+ }
201
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @overview
3
+ * Theming bridge for the `cngxButtonToggle` directive. `cngx.reset`
4
+ * strips native `<button>` chrome (border, padding, background) so
5
+ * components can layer their own; the button-toggle leaf is the
6
+ * chrome for both `<cngx-button-toggle-group>` (single-select) and
7
+ * `<cngx-button-multi-toggle-group>` (multi-select). Without this
8
+ * stylesheet the toggles render as bare text.
9
+ *
10
+ * **State modifiers**
11
+ *
12
+ * - `--checked` - primary fill, on-primary text, primary border
13
+ * - `--disabled` - opacity 0.5, `cursor: not-allowed`
14
+ * - `:hover:not(--disabled)` - 8% primary tint over the surface
15
+ *
16
+ * **Segmented-control geometry**
17
+ *
18
+ * The group container is a zero-gap flex row, so adjacent toggles
19
+ * share an edge:
20
+ *
21
+ * - `:scope + :scope` - collapses the inner border
22
+ * - `:first-child` - rounded start corners only
23
+ * - `:last-child` - rounded end corners only
24
+ *
25
+ * **Inheritance**
26
+ *
27
+ * Surface tokens chain through the foundation so dark-mode and
28
+ * consumer-theme swaps cascade without per-component overrides:
29
+ *
30
+ * - background -> `--cngx-color-surface`
31
+ * - color -> `--cngx-color-text`
32
+ * - border -> `--cngx-color-border`
33
+ * - checked fill -> `--cngx-color-primary` / `--cngx-color-on-primary`
34
+ * - corner radius -> `--cngx-radius-md`
35
+ * - font-size -> `--cngx-font-size-sm`
36
+ */
37
+
38
+ @layer cngx.tokens {
39
+ @property --cngx-button-toggle-padding-block {
40
+ syntax: '*';
41
+ inherits: false;
42
+ initial-value: 0.4rem;
43
+ }
44
+ @property --cngx-button-toggle-padding-inline {
45
+ syntax: '*';
46
+ inherits: false;
47
+ initial-value: 0.875rem;
48
+ }
49
+ }
50
+
51
+ @layer cngx.components {
52
+ @scope (.cngx-button-toggle) {
53
+ :scope {
54
+ display: inline-flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ gap: 0.375rem;
58
+ padding: var(--cngx-button-toggle-padding-block, 0.4rem) var(--cngx-button-toggle-padding-inline, 0.875rem);
59
+ border: 1px solid var(--cngx-color-border, oklch(0.88 0.005 250));
60
+ background: var(--cngx-color-surface, oklch(1 0 0));
61
+ color: var(--cngx-color-text, oklch(0.2 0.01 250));
62
+ font: inherit;
63
+ font-size: var(--cngx-font-size-sm, 0.8125rem);
64
+ cursor: pointer;
65
+ transition: background-color 0.12s, border-color 0.12s, color 0.12s;
66
+ }
67
+
68
+ /* Segmented-control geometry: collapse adjacent borders inside the
69
+ * group so the row reads as one control. The group container is a
70
+ * flex row with zero gap (its default), so adjacent buttons share
71
+ * an edge. */
72
+ :scope + :scope {
73
+ border-inline-start-width: 0;
74
+ }
75
+ :scope:first-child {
76
+ border-start-start-radius: var(--cngx-radius-md, 0.375rem);
77
+ border-end-start-radius: var(--cngx-radius-md, 0.375rem);
78
+ }
79
+ :scope:last-child {
80
+ border-start-end-radius: var(--cngx-radius-md, 0.375rem);
81
+ border-end-end-radius: var(--cngx-radius-md, 0.375rem);
82
+ }
83
+
84
+ :scope:hover:not(.cngx-button-toggle--disabled) {
85
+ background: color-mix(in oklch, var(--cngx-color-primary, oklch(0.66 0.19 50)) 8%, var(--cngx-color-surface, oklch(1 0 0)));
86
+ }
87
+
88
+ :scope.cngx-button-toggle--checked {
89
+ background: var(--cngx-color-primary, oklch(0.66 0.19 50));
90
+ color: var(--cngx-color-on-primary, oklch(0.99 0.01 250));
91
+ border-color: var(--cngx-color-primary, oklch(0.66 0.19 50));
92
+ }
93
+
94
+ :scope.cngx-button-toggle--disabled {
95
+ opacity: 0.5;
96
+ cursor: not-allowed;
97
+ }
98
+ }
99
+ }