@cngx/common 0.1.0-rc.8 → 0.3.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.
Files changed (90) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +42 -2
  4. package/data/README.md +15 -12
  5. package/fesm2022/cngx-common-a11y.mjs +1076 -319
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +99 -77
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-button.mjs +1084 -0
  10. package/fesm2022/cngx-common-button.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +138 -78
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +799 -327
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +101 -25
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +861 -423
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +198 -160
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +693 -329
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7303 -2774
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2174 -442
  26. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  27. package/fesm2022/cngx-common-menu-button.mjs +557 -0
  28. package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
  29. package/fesm2022/cngx-common-popover.mjs +2109 -557
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +548 -419
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +442 -331
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +44 -71
  36. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  37. package/fesm2022/cngx-common.mjs +10 -10
  38. package/fesm2022/cngx-common.mjs.map +1 -1
  39. package/interactive/README.md +30 -19
  40. package/layout/README.md +17 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +31 -8
  43. package/popover/README.md +81 -4
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/collection.json +9 -0
  46. package/schematics/ng-add/index.js +9 -0
  47. package/schematics/ng-add/schema.json +96 -0
  48. package/schematics/package.json +3 -0
  49. package/stepper/README.md +5 -5
  50. package/theming/components/cngx-accordion.css +36 -7
  51. package/theming/components/cngx-async.css +185 -37
  52. package/theming/components/cngx-backdrop.css +3 -1
  53. package/theming/components/cngx-badge.css +20 -5
  54. package/theming/components/cngx-bottom-sheet.css +2 -0
  55. package/theming/components/cngx-breadcrumb.css +3 -1
  56. package/theming/components/cngx-button-group.css +325 -0
  57. package/theming/components/cngx-button-toggle.css +55 -23
  58. package/theming/components/cngx-button.css +975 -0
  59. package/theming/components/cngx-data-grid.css +2 -0
  60. package/theming/components/cngx-dialog.css +3 -1
  61. package/theming/components/cngx-divider.css +24 -9
  62. package/theming/components/cngx-drawer.css +153 -0
  63. package/theming/components/cngx-icon-glyph.css +76 -0
  64. package/theming/components/cngx-listbox.css +79 -25
  65. package/theming/components/cngx-menu.css +112 -52
  66. package/theming/components/cngx-nav.css +1220 -0
  67. package/theming/components/cngx-popover-sheet.css +434 -0
  68. package/theming/components/cngx-popover.css +37 -9
  69. package/theming/components/cngx-recycler-placeholder.css +2 -0
  70. package/theming/components/cngx-ripple.css +74 -16
  71. package/theming/components/cngx-sidebar.css +71 -0
  72. package/theming/components/cngx-slider.css +3 -1
  73. package/theming/components/cngx-tooltip.css +2 -0
  74. package/timeline/README.md +2 -2
  75. package/types/cngx-common-a11y.d.ts +488 -112
  76. package/types/cngx-common-audio.d.ts +60 -88
  77. package/types/cngx-common-button.d.ts +698 -0
  78. package/types/cngx-common-card.d.ts +104 -78
  79. package/types/cngx-common-chart.d.ts +677 -389
  80. package/types/cngx-common-command.d.ts +55 -41
  81. package/types/cngx-common-data.d.ts +506 -360
  82. package/types/cngx-common-dialog.d.ts +94 -127
  83. package/types/cngx-common-display.d.ts +475 -300
  84. package/types/cngx-common-interactive.d.ts +4383 -1721
  85. package/types/cngx-common-layout.d.ts +1399 -288
  86. package/types/cngx-common-menu-button.d.ts +382 -0
  87. package/types/cngx-common-popover.d.ts +990 -268
  88. package/types/cngx-common-stepper.d.ts +374 -465
  89. package/types/cngx-common-tabs.d.ts +309 -403
  90. package/types/cngx-common-timeline.d.ts +50 -109
@@ -0,0 +1,325 @@
1
+ /**
2
+ * @overview
3
+ * Segment geometry for the `cngxButtonGroup` directive. Directives carry no
4
+ * `styleUrl`, so this sheet ships in the global `cngx.css` bundle. The host
5
+ * carries `.cngx-button-group`, `role="group"`, `data-orientation` and, when
6
+ * a size is set, `data-size`.
7
+ *
8
+ * **Attached segments (default)**
9
+ *
10
+ * Every direct child is a segment, whatever it is (a `cngxButton`, a
11
+ * `cngxIconButton`, an addon, an app component):
12
+ *
13
+ * - seams collapse: each segment after the first overlaps its predecessor by
14
+ * one border width, so neighbouring borders draw one line
15
+ * - an overlapped segment floors at `--cngx-target-min` plus one border
16
+ * width along the group axis, so the seam never shrinks its exclusive hit
17
+ * span below the touch target (inert on a fine pointer)
18
+ * - only the two outer ends keep the radius, on logical corners, so the
19
+ * frame follows `dir="rtl"` and `data-orientation="vertical"`
20
+ * - a hovered segment is lifted above its neighbours (`z-index: 1`), a
21
+ * focused one above that (`z-index: 2`), so neither a border nor the focus
22
+ * ring is clipped at a seam
23
+ * - a solid `primary` / `danger` segment after another one gets a seam line
24
+ * mixed from the on-tone colour, since their fill and border share one
25
+ * colour
26
+ * - an `[aria-live]` child (the sr-only status `cngxAsyncClick` inserts next
27
+ * to its host) is not a segment and never counts as first or last
28
+ *
29
+ * **Toolbar (a group of groups)**
30
+ *
31
+ * A group whose direct children are groups spaces them by
32
+ * `--cngx-button-group-gap`, floored to `--cngx-target-gap` so a coarse
33
+ * pointer keeps 8px between sub-groups (WCAG 2.5.8). One group child is
34
+ * enough: a loose button next to sub-groups then gets no segment geometry,
35
+ * so wrap it in a group of its own.
36
+ *
37
+ * **Parts**
38
+ *
39
+ * - `.cngx-button-group__addon` - a non-interactive segment box: the group's
40
+ * border, the button row of its `data-size` (the button's padding and
41
+ * type tokens), content centred. Media children (`img`, `svg`, `picture`,
42
+ * `video`, `canvas`, `cngx-icon`, `cngx-avatar`) are capped to the addon's
43
+ * label line, so a 24px avatar never stretches a 20px-line row
44
+ * - `.cngx-button-group__separator` - a divider drawn as a border (survives
45
+ * forced colors); it never collapses into its neighbours
46
+ *
47
+ * **Inheritance**
48
+ *
49
+ * - toolbar gap -> `--cngx-space-sm` (SET, so `[data-density]` re-scales)
50
+ * - addon padding and type -> the button's `--cngx-button-padding-*` /
51
+ * `--cngx-button-font-*` tokens (`--cngx-space-*` per size)
52
+ * - addon media cap -> `1lh` of the addon (its font size times its line
53
+ * height), so size, `[data-density]` and a bridge that re-sets the label
54
+ * type move it with the row
55
+ * - end radius -> `--cngx-radius-md`, the same rung as `--cngx-button-radius`
56
+ * - addon and separator colour -> `--cngx-color-border` /
57
+ * `--cngx-color-surface` / `--cngx-color-text`
58
+ *
59
+ * @themes CngxButtonGroup
60
+ */
61
+
62
+ @layer cngx.tokens {
63
+ /**
64
+ * Space between the sub-groups of a group of groups. Floored to
65
+ * `--cngx-target-gap` at the use site.
66
+ * @group Layout
67
+ */
68
+ @property --cngx-button-group-gap {
69
+ syntax: '*';
70
+ inherits: false;
71
+ initial-value: 0.5rem;
72
+ }
73
+
74
+ /**
75
+ * Inline padding of an addon segment.
76
+ * @group Layout
77
+ */
78
+ @property --cngx-button-group-addon-padding-inline {
79
+ syntax: '*';
80
+ inherits: false;
81
+ initial-value: 1rem;
82
+ }
83
+
84
+ /**
85
+ * Largest block size of a media child of an addon (`img`, `svg`,
86
+ * `cngx-icon`, `cngx-avatar`, ...). SET to `1lh` on the addon; registered
87
+ * as a length so `1lh` resolves against the addon's line box, not the
88
+ * child's, and the children inherit that pixel value. The initial value
89
+ * is the md label line and only shows where `lh` is unsupported.
90
+ * @group Layout
91
+ */
92
+ @property --cngx-button-group-addon-media-size {
93
+ syntax: '<length>';
94
+ inherits: true;
95
+ initial-value: 24px;
96
+ }
97
+
98
+ /**
99
+ * Radius of the two outer ends. Inherits, so a value set on the group
100
+ * reaches the segments that read it.
101
+ * @group Layout
102
+ */
103
+ @property --cngx-button-group-radius {
104
+ syntax: '*';
105
+ inherits: true;
106
+ initial-value: 0.5rem;
107
+ }
108
+
109
+ /* SET from the scale on the host; the registered initial-value would beat a
110
+ * read-site fallback. */
111
+ :where(.cngx-button-group) {
112
+ --cngx-button-group-gap: var(--cngx-space-sm);
113
+ --cngx-button-group-radius: var(--cngx-radius-md, 0.5rem);
114
+ }
115
+ /* Derived from the button's inline padding (SET per size from the scale by
116
+ * the button sheet), so the addon pads like its sibling buttons. */
117
+ :where(.cngx-button-group__addon) {
118
+ --cngx-button-group-addon-padding-inline: var(--cngx-button-padding-inline, var(--cngx-space-md));
119
+ --cngx-button-group-addon-media-size: 1lh;
120
+ }
121
+ }
122
+
123
+ @layer cngx.components {
124
+ @scope (.cngx-button-group) {
125
+ :scope {
126
+ display: inline-flex;
127
+ flex-direction: row;
128
+ align-items: stretch;
129
+ vertical-align: middle;
130
+ /* The z-index lift of a hovered or focused segment stays inside the group. */
131
+ isolation: isolate;
132
+ }
133
+ :scope[data-orientation='vertical'] {
134
+ flex-direction: column;
135
+ }
136
+
137
+ /* A group of groups: sub-groups sit apart. */
138
+ :scope:has(> .cngx-button-group) {
139
+ gap: max(var(--cngx-button-group-gap, 0.5rem), var(--cngx-target-gap, 0px));
140
+ }
141
+
142
+ /* Attached segments. The :not(:has()) compound lifts these rules to at least
143
+ * (0,2,0), above the (0,1,0) `:scope` base of the button sheet, whose own
144
+ * @scope root is closer and would win a specificity tie. Live regions are
145
+ * not segments: `cngxAsyncClick` inserts its sr-only status next to its
146
+ * host, so first / last / seam count only the other children. */
147
+ :scope:not(:has(> .cngx-button-group)) > :not([aria-live]) {
148
+ position: relative;
149
+ margin: 0;
150
+ border-radius: 0;
151
+ }
152
+ :scope:not(:has(> .cngx-button-group)) > :nth-child(n + 2 of :not([aria-live])) {
153
+ margin-inline-start: calc(-1 * var(--cngx-button-border-width, 1px));
154
+ }
155
+ /* A segment its successor overlaps keeps the full touch target as its
156
+ * exclusive span. Separators (a 0-width border) and addons (no target)
157
+ * are left alone. */
158
+ :scope:not(:has(> .cngx-button-group))
159
+ > :nth-last-child(n + 2 of :not([aria-live])):not(
160
+ .cngx-button-group__separator,
161
+ .cngx-button-group__addon
162
+ ) {
163
+ min-inline-size: calc(var(--cngx-target-min, 0px) + var(--cngx-button-border-width, 1px));
164
+ }
165
+ :scope:not(:has(> .cngx-button-group)) > :nth-child(1 of :not([aria-live])) {
166
+ border-start-start-radius: var(--cngx-button-group-radius, 0.5rem);
167
+ border-end-start-radius: var(--cngx-button-group-radius, 0.5rem);
168
+ }
169
+ :scope:not(:has(> .cngx-button-group)) > :nth-last-child(1 of :not([aria-live])) {
170
+ border-start-end-radius: var(--cngx-button-group-radius, 0.5rem);
171
+ border-end-end-radius: var(--cngx-button-group-radius, 0.5rem);
172
+ }
173
+
174
+ :scope[data-orientation='vertical']:not(:has(> .cngx-button-group)) > :nth-child(n + 2 of :not([aria-live])) {
175
+ margin-inline-start: 0;
176
+ margin-block-start: calc(-1 * var(--cngx-button-border-width, 1px));
177
+ }
178
+ :scope[data-orientation='vertical']:not(:has(> .cngx-button-group))
179
+ > :nth-last-child(n + 2 of :not([aria-live])):not(
180
+ .cngx-button-group__separator,
181
+ .cngx-button-group__addon
182
+ ) {
183
+ min-block-size: calc(var(--cngx-target-min, 0px) + var(--cngx-button-border-width, 1px));
184
+ }
185
+ :scope[data-orientation='vertical']:not(:has(> .cngx-button-group)) > :nth-child(1 of :not([aria-live])) {
186
+ border-radius: 0;
187
+ border-start-start-radius: var(--cngx-button-group-radius, 0.5rem);
188
+ border-start-end-radius: var(--cngx-button-group-radius, 0.5rem);
189
+ }
190
+ :scope[data-orientation='vertical']:not(:has(> .cngx-button-group)) > :nth-last-child(1 of :not([aria-live])) {
191
+ border-radius: 0;
192
+ border-end-start-radius: var(--cngx-button-group-radius, 0.5rem);
193
+ border-end-end-radius: var(--cngx-button-group-radius, 0.5rem);
194
+ }
195
+ :scope[data-orientation='vertical']:not(:has(> .cngx-button-group)) > :nth-child(1 of :not([aria-live])):nth-last-child(1 of :not([aria-live])) {
196
+ border-radius: var(--cngx-button-group-radius, 0.5rem);
197
+ }
198
+
199
+ /* A separator keeps its neighbours apart instead of collapsing the seam.
200
+ * The `:nth-child(n of ...)` compound always matches; it only lifts the
201
+ * rule above the segment margins. */
202
+ :scope:not(:has(> .cngx-button-group)) > .cngx-button-group__separator + :nth-child(n of :not([aria-live])) {
203
+ margin-inline-start: 0;
204
+ margin-block-start: 0;
205
+ }
206
+
207
+ /* Lift above the neighbours: hover over rest, focus over hover. */
208
+ :scope > :hover {
209
+ z-index: 1;
210
+ }
211
+ :scope > :is(:focus-visible, :has(:focus-visible)) {
212
+ z-index: 2;
213
+ }
214
+
215
+ /* Solid primary / danger segments share fill and border colour (the
216
+ * solid fill token, as on the button itself); a seam
217
+ * line mixed from the on-tone colour keeps them apart. Mixed in oklab:
218
+ * an oklch mix would swing the hue between the two colours. */
219
+ :scope:not(:has(> .cngx-button-group))
220
+ > [data-variant='solid']:not([data-tone='neutral'])
221
+ ~ [data-variant='solid']:not([data-tone='neutral'], [aria-disabled='true']) {
222
+ border-inline-start-color: color-mix(
223
+ in oklab,
224
+ var(--cngx-button-on-tone, Canvas) 40%,
225
+ var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor))
226
+ );
227
+ }
228
+ :scope[data-orientation='vertical']:not(:has(> .cngx-button-group))
229
+ > [data-variant='solid']:not([data-tone='neutral'])
230
+ ~ [data-variant='solid']:not([data-tone='neutral'], [aria-disabled='true']) {
231
+ border-inline-start-color: var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor));
232
+ border-block-start-color: color-mix(
233
+ in oklab,
234
+ var(--cngx-button-on-tone, Canvas) 40%,
235
+ var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor))
236
+ );
237
+ }
238
+
239
+ /* Addon: a non-interactive segment box on the row of the buttons beside
240
+ * it. It carries the button `data-size` and reads the button's own metric
241
+ * and type tokens (SET per size by the button sheet's shared metrics
242
+ * block), so size, [data-density] and a theme that re-sets those tokens
243
+ * reach the addon and the buttons alike. Without the button sheet the
244
+ * fallbacks give the md row. Weight stays inherited unless a theme sets
245
+ * --cngx-button-font-weight. */
246
+ .cngx-button-group__addon {
247
+ display: inline-flex;
248
+ align-items: center;
249
+ justify-content: center;
250
+ gap: var(--cngx-space-xs, 4px);
251
+ box-sizing: border-box;
252
+ padding-block: var(--cngx-button-padding-block, var(--cngx-space-sm, 0.5rem));
253
+ padding-inline: var(--cngx-button-group-addon-padding-inline, 1rem);
254
+ border: var(--cngx-button-border-width, 1px) solid var(--cngx-color-border, oklch(0.88 0.005 250));
255
+ background: color-mix(
256
+ in oklab,
257
+ var(--cngx-color-text, oklch(0.2 0.01 250)) 4%,
258
+ var(--cngx-color-surface, oklch(1 0 0))
259
+ );
260
+ color: var(--cngx-color-text, oklch(0.2 0.01 250));
261
+ font-size: var(--cngx-button-font-size, var(--cngx-font-size-control, 1rem));
262
+ font-weight: var(--cngx-button-font-weight, inherit);
263
+ line-height: var(--cngx-line-height-base, 1.5);
264
+ white-space: nowrap;
265
+ }
266
+
267
+ /* Addon media stay inside the label line, like a slot icon in the
268
+ * button: taller media would grow the addon and the group would stretch
269
+ * every button to it. A replaced element caps its block size and keeps
270
+ * its ratio (auto inline size); an avatar is square, so both axes cap;
271
+ * an icon caps its font size, which sizes its svg or mat-icon glyph. */
272
+ .cngx-button-group__addon > :is(img, svg, picture, video, canvas) {
273
+ max-block-size: var(--cngx-button-group-addon-media-size);
274
+ inline-size: auto;
275
+ }
276
+ .cngx-button-group__addon > cngx-avatar {
277
+ max-block-size: var(--cngx-button-group-addon-media-size);
278
+ max-inline-size: var(--cngx-button-group-addon-media-size);
279
+ }
280
+ .cngx-button-group__addon > cngx-icon {
281
+ font-size: min(var(--cngx-icon-size, 1.25em), var(--cngx-button-group-addon-media-size));
282
+ }
283
+
284
+ /* Separator: a border, so forced colors keep it. The `:nth-child(n of
285
+ * ...)` compound lifts it above the segment margins. */
286
+ :scope:not(:has(> .cngx-button-group)) > .cngx-button-group__separator:nth-child(n of :not([aria-live])) {
287
+ flex: none;
288
+ align-self: stretch;
289
+ inline-size: 0;
290
+ margin-block: var(--cngx-space-xs, 4px);
291
+ margin-inline: var(--cngx-space-xs, 4px);
292
+ border: 0;
293
+ border-inline-start: 1px solid var(--cngx-color-border, oklch(0.88 0.005 250));
294
+ }
295
+ :scope[data-orientation='vertical']:not(:has(> .cngx-button-group)) > .cngx-button-group__separator:nth-child(n of :not([aria-live])) {
296
+ inline-size: auto;
297
+ block-size: 0;
298
+ border-inline-start: 0;
299
+ border-block-start: 1px solid var(--cngx-color-border, oklch(0.88 0.005 250));
300
+ }
301
+
302
+ /* More contrast: the addon frame takes the text colour like the outline
303
+ * buttons beside it. */
304
+ [data-contrast='more'] :scope > .cngx-button-group__addon {
305
+ border-color: currentColor;
306
+ }
307
+ }
308
+ }
309
+
310
+ /* forced-colors (WHCM): the button sheet paints a solid primary / danger
311
+ * segment with Highlight fill and border (`!important`), so two of them merge.
312
+ * A HighlightText seam keeps them apart. Unlayered, outside @scope,
313
+ * `!important` to beat the button's own forced rule. */
314
+ @media (forced-colors: active) {
315
+ .cngx-button-group:not([data-orientation='vertical'])
316
+ > .cngx-button[data-variant='solid']:is([data-tone='primary'], [data-tone='danger'])
317
+ ~ .cngx-button[data-variant='solid']:is([data-tone='primary'], [data-tone='danger']) {
318
+ border-inline-start-color: HighlightText !important;
319
+ }
320
+ .cngx-button-group[data-orientation='vertical']
321
+ > .cngx-button[data-variant='solid']:is([data-tone='primary'], [data-tone='danger'])
322
+ ~ .cngx-button[data-variant='solid']:is([data-tone='primary'], [data-tone='danger']) {
323
+ border-block-start-color: HighlightText !important;
324
+ }
325
+ }
@@ -9,21 +9,22 @@
9
9
  *
10
10
  * **State modifiers**
11
11
  *
12
- * - `--checked` - primary fill, on-primary text, primary border
12
+ * - `--checked` - strong primary fill and border, on-primary-strong text
13
13
  * - `--disabled` - `cursor: not-allowed`; 38% text on a faint text tint,
14
14
  * a checked segment fills with the disabled colour; GrayText under
15
15
  * forced colors
16
16
  * - `:hover:not(--disabled):not(--checked)` - 8% primary tint over the surface
17
- * - `--checked:hover:not(--disabled)` - primary fill darkened for feedback,
18
- * keeping the on-primary text contrast (an unguarded plain hover would drop
19
- * a checked segment to the pale tint under near-white text)
17
+ * - `--checked:hover:not(--disabled)` - strong fill shaded away from its ink,
18
+ * keeping the label contrast (an unguarded plain hover would drop a checked
19
+ * segment to the pale tint under its ink)
20
20
  *
21
21
  * **Segmented-control geometry**
22
22
  *
23
23
  * The group container is a zero-gap flex row, so adjacent toggles
24
24
  * share an edge:
25
25
  *
26
- * - `:scope + :scope` - collapses the inner border
26
+ * - `.cngx-button-toggle + :scope` in a horizontal group - collapses the
27
+ * inner border
27
28
  * - `:first-child` - rounded start corners only
28
29
  * - `:last-child` - rounded end corners only
29
30
  *
@@ -35,9 +36,11 @@
35
36
  * - background -> `--cngx-color-surface`
36
37
  * - color -> `--cngx-color-text`
37
38
  * - border -> `--cngx-color-border`
38
- * - checked fill -> `--cngx-color-primary` / `--cngx-color-on-primary`
39
+ * - checked fill -> `--cngx-color-primary-strong` / `--cngx-color-on-primary-strong`
39
40
  * - corner radius -> `--cngx-radius-md`
40
41
  * - font-size -> `--cngx-font-size-sm`
42
+ *
43
+ * @themes CngxButtonToggle
41
44
  */
42
45
 
43
46
  @layer cngx.tokens {
@@ -83,8 +86,12 @@
83
86
  /* Segmented-control geometry: collapse adjacent borders inside the
84
87
  * group so the row reads as one control. The group container is a
85
88
  * flex row with zero gap (its default), so adjacent buttons share
86
- * an edge. */
87
- :scope + :scope {
89
+ * an edge. The previous sibling sits outside this scope: `:scope +
90
+ * :scope` would need the root to be its own sibling and never matched.
91
+ * Row groups only; a column group stacks on the block axis. */
92
+ :is(.cngx-button-toggle-group--horizontal, .cngx-button-multi-toggle-group--horizontal)
93
+ > .cngx-button-toggle
94
+ + :scope {
88
95
  border-inline-start-width: 0;
89
96
  }
90
97
  :scope:first-child {
@@ -100,25 +107,49 @@
100
107
  * `:not(--checked)` guard is load-bearing - this rule sets only the
101
108
  * background, and it out-specifies the checked rule below (0,3,0 vs 0,2,0),
102
109
  * so without the guard a hovered checked segment would drop to the pale
103
- * tint while keeping its on-primary (near-white) text: white-on-pale, an
110
+ * tint while keeping its on-primary-strong ink: white-on-pale in light, an
104
111
  * invisible label. Checked hover is handled by its own rule. */
105
112
  :scope:hover:not(.cngx-button-toggle--disabled):not(.cngx-button-toggle--checked) {
106
113
  background: color-mix(in oklch, var(--cngx-color-primary, oklch(0.66 0.19 50)) 8%, var(--cngx-color-surface, oklch(1 0 0)));
107
114
  }
108
115
 
109
116
  :scope.cngx-button-toggle--checked {
110
- background: var(--cngx-color-primary, oklch(0.66 0.19 50));
111
- color: var(--cngx-color-on-primary, oklch(0.99 0.01 250));
112
- border-color: var(--cngx-color-primary, oklch(0.66 0.19 50));
117
+ background: var(
118
+ --cngx-color-primary-strong,
119
+ oklch(from var(--cngx-color-primary, oklch(0.66 0.19 50)) 0.58 c h)
120
+ );
121
+ color: var(--cngx-color-on-primary-strong, oklch(1 0 0));
122
+ border-color: var(
123
+ --cngx-color-primary-strong,
124
+ oklch(from var(--cngx-color-primary, oklch(0.66 0.19 50)) 0.58 c h)
125
+ );
113
126
  }
114
127
 
115
- /* Hover on a CHECKED segment: keep the primary fill (so the on-primary text
116
- * stays legible) and darken it a touch for feedback. Darkening toward black
117
- * only deepens the fill, so the on-primary text contrast is preserved in
118
- * light and dark. */
128
+ /* Hover on a CHECKED segment: keep the strong fill and shade it 12% away
129
+ * from its ink. The shade is the ink's opposite lightness (round(1 - l)):
130
+ * dark under the light-scheme white ink, light under the dark-scheme dark
131
+ * ink, so the fill moves away from the label and the strong pair keeps
132
+ * 4.5:1 in both schemes. The same pair and derivation as a solid primary
133
+ * button (`--cngx-button-hover-shade` in cngx-button.css). */
119
134
  :scope.cngx-button-toggle--checked:hover:not(.cngx-button-toggle--disabled) {
120
- background: color-mix(in oklch, var(--cngx-color-primary, oklch(0.66 0.19 50)) 88%, black);
121
- border-color: color-mix(in oklch, var(--cngx-color-primary, oklch(0.66 0.19 50)) 88%, black);
135
+ background: color-mix(
136
+ in oklch,
137
+ var(
138
+ --cngx-color-primary-strong,
139
+ oklch(from var(--cngx-color-primary, oklch(0.66 0.19 50)) 0.58 c h)
140
+ )
141
+ 88%,
142
+ oklch(from var(--cngx-color-on-primary-strong, oklch(1 0 0)) round(1 - l, 1) 0 0)
143
+ );
144
+ border-color: color-mix(
145
+ in oklch,
146
+ var(
147
+ --cngx-color-primary-strong,
148
+ oklch(from var(--cngx-color-primary, oklch(0.66 0.19 50)) 0.58 c h)
149
+ )
150
+ 88%,
151
+ oklch(from var(--cngx-color-on-primary-strong, oklch(1 0 0)) round(1 - l, 1) 0 0)
152
+ );
122
153
  }
123
154
 
124
155
  /* Disabled by colour, never opacity (the field recipe): 38% text on a
@@ -138,8 +169,8 @@
138
169
  }
139
170
  }
140
171
 
141
- /* forced-colors (WHCM): the checked segment is a primary background fill (with a
142
- * primary border-color and on-primary text); the fill flattens to Canvas and the
172
+ /* forced-colors (WHCM): the checked segment is a strong-primary background fill
173
+ * (with a matching border-color and on-primary-strong text); the fill flattens to Canvas and the
143
174
  * border/text force to the same system colours as an unchecked segment, so the
144
175
  * pressed state is lost. Re-signal with the system Highlight pair. Two rules are
145
176
  * load-bearing here: (1) the host is a `<button>`, and the UA forces a
@@ -156,9 +187,10 @@
156
187
  color: HighlightText !important;
157
188
  border-color: Highlight !important;
158
189
  }
159
- /* Disabled is painted by colour. A native :disabled button gets GrayText from
160
- * the UA, an aria-disabled one does not, so restate it; a checked disabled
161
- * segment fills with GrayText (the repeated classes beat the Highlight rule). */
190
+ /* Disabled is painted by colour. The toggle renders aria-disabled, never a
191
+ * native :disabled, so the UA paints no GrayText and this rule is the only
192
+ * source; a checked disabled segment fills with GrayText (the repeated
193
+ * classes beat the Highlight rule). */
162
194
  .cngx-button-toggle.cngx-button-toggle--disabled {
163
195
  forced-color-adjust: none;
164
196
  background: ButtonFace;