@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.
- package/a11y/README.md +15 -2
- package/button/README.md +258 -0
- package/command/README.md +42 -2
- package/data/README.md +15 -12
- package/fesm2022/cngx-common-a11y.mjs +1076 -319
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +99 -77
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-button.mjs +1084 -0
- package/fesm2022/cngx-common-button.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +138 -78
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +799 -327
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +101 -25
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +861 -423
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +198 -160
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +693 -329
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +7303 -2774
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +2174 -442
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-menu-button.mjs +557 -0
- package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +2109 -557
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +548 -419
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +442 -331
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +44 -71
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +10 -10
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +30 -19
- package/layout/README.md +17 -1
- package/menu-button/README.md +234 -0
- package/package.json +31 -8
- package/popover/README.md +81 -4
- package/popover/tooltip-indicator.scss +52 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +96 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +5 -5
- package/theming/components/cngx-accordion.css +36 -7
- package/theming/components/cngx-async.css +185 -37
- package/theming/components/cngx-backdrop.css +3 -1
- package/theming/components/cngx-badge.css +20 -5
- package/theming/components/cngx-bottom-sheet.css +2 -0
- package/theming/components/cngx-breadcrumb.css +3 -1
- package/theming/components/cngx-button-group.css +325 -0
- package/theming/components/cngx-button-toggle.css +55 -23
- package/theming/components/cngx-button.css +975 -0
- package/theming/components/cngx-data-grid.css +2 -0
- package/theming/components/cngx-dialog.css +3 -1
- package/theming/components/cngx-divider.css +24 -9
- package/theming/components/cngx-drawer.css +153 -0
- package/theming/components/cngx-icon-glyph.css +76 -0
- package/theming/components/cngx-listbox.css +79 -25
- package/theming/components/cngx-menu.css +112 -52
- package/theming/components/cngx-nav.css +1220 -0
- package/theming/components/cngx-popover-sheet.css +434 -0
- package/theming/components/cngx-popover.css +37 -9
- package/theming/components/cngx-recycler-placeholder.css +2 -0
- package/theming/components/cngx-ripple.css +74 -16
- package/theming/components/cngx-sidebar.css +71 -0
- package/theming/components/cngx-slider.css +3 -1
- package/theming/components/cngx-tooltip.css +2 -0
- package/timeline/README.md +2 -2
- package/types/cngx-common-a11y.d.ts +488 -112
- package/types/cngx-common-audio.d.ts +60 -88
- package/types/cngx-common-button.d.ts +698 -0
- package/types/cngx-common-card.d.ts +104 -78
- package/types/cngx-common-chart.d.ts +677 -389
- package/types/cngx-common-command.d.ts +55 -41
- package/types/cngx-common-data.d.ts +506 -360
- package/types/cngx-common-dialog.d.ts +94 -127
- package/types/cngx-common-display.d.ts +475 -300
- package/types/cngx-common-interactive.d.ts +4383 -1721
- package/types/cngx-common-layout.d.ts +1399 -288
- package/types/cngx-common-menu-button.d.ts +382 -0
- package/types/cngx-common-popover.d.ts +990 -268
- package/types/cngx-common-stepper.d.ts +374 -465
- package/types/cngx-common-tabs.d.ts +309 -403
- package/types/cngx-common-timeline.d.ts +50 -109
|
@@ -0,0 +1,975 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @overview
|
|
3
|
+
* Default visuals for the button family. The host is the native `<button>` or
|
|
4
|
+
* `<a>` and carries `.cngx-button` plus `data-variant`, `data-tone` and
|
|
5
|
+
* `data-size`; the component renders the start slot, the label, the end
|
|
6
|
+
* slot and, while a co-hosted `cngxAsyncClick` runs, a busy layer.
|
|
7
|
+
*
|
|
8
|
+
* Loaded by `@cngx/themes/cngx.css`. A custom host gets it by carrying
|
|
9
|
+
* `.cngx-button` (and `.cngx-icon-button` for a square box).
|
|
10
|
+
*
|
|
11
|
+
* **Axes**
|
|
12
|
+
*
|
|
13
|
+
* - `data-variant` - emphasis: `solid` (filled), `secondary` (tonal fill),
|
|
14
|
+
* `outline` (border), `ghost` (no chrome until hover), `link` (inline
|
|
15
|
+
* text, no control height, no touch floor - WCAG 2.5.8 inline exception)
|
|
16
|
+
* - `data-tone` - intent: `neutral`, `primary`, `danger`; sets the three
|
|
17
|
+
* tone tokens every variant paints from
|
|
18
|
+
* - `data-size` - `xs`, `sm`, `md`, `lg`; `md` is the form-control row
|
|
19
|
+
* (`line box + 2 * --cngx-space-sm + 2 * 1px`)
|
|
20
|
+
*
|
|
21
|
+
* **State modifiers**
|
|
22
|
+
*
|
|
23
|
+
* - `:hover` - the variant's surface mixed towards the tone (solid primary
|
|
24
|
+
* and danger: `--cngx-button-hover-layer` of `--cngx-button-hover-shade`);
|
|
25
|
+
* never on an `aria-disabled` (or busy) button
|
|
26
|
+
* - `:active` / `.cngx-pressed` - pressed: the same mix one step stronger
|
|
27
|
+
* (`--cngx-button-pressed-layer`, `--cngx-button-pressed-wash`,
|
|
28
|
+
* `--cngx-button-neutral-tint-pressed`); `.cngx-pressed` is the class `cngxPressable`
|
|
29
|
+
* sets on pointerdown, so a touch press shows without the `:active` lag.
|
|
30
|
+
* Never on an `aria-disabled` (or busy) button
|
|
31
|
+
* - `[aria-disabled='true']:not([data-busy], [data-pending])` - disabled by
|
|
32
|
+
* colour, never opacity; `cursor: not-allowed`; GrayText under forced colors.
|
|
33
|
+
* `data-pending` is the immediate run flag; `data-busy` follows the loading
|
|
34
|
+
* config's show delay, so without the pending exclusion the first frames of
|
|
35
|
+
* every run (aria-disabled, no data-busy yet) would paint as disabled
|
|
36
|
+
* - `[data-busy]` - label kept in the box and in the accessible name but
|
|
37
|
+
* painted at opacity 0 (width stable), spinner ring centred over it; the
|
|
38
|
+
* ring stops rotating under reduced motion. The fade sits on every direct
|
|
39
|
+
* child, so projected content cannot opt back in with its own rule
|
|
40
|
+
* - `[data-busy][data-status-label]` - host hook: a host that shows a status
|
|
41
|
+
* label instead of the spinner (`CngxActionButton`, `CngxPopoverAction`)
|
|
42
|
+
* sets `data-status-label`, and `.cngx-button__label` stays at
|
|
43
|
+
* `opacity: 1` while the other children keep the busy fade
|
|
44
|
+
* - `.cngx-button__label` with `[cngxActionStatusStack]` - the status cells
|
|
45
|
+
* of an action host; the stack's own sheet puts them in one grid cell, so
|
|
46
|
+
* the button is as wide as its widest label
|
|
47
|
+
* - `[data-start]` / `[data-end]` - a filled slot trims the padding on its
|
|
48
|
+
* side
|
|
49
|
+
*
|
|
50
|
+
* **Inheritance**
|
|
51
|
+
*
|
|
52
|
+
* - padding -> `--cngx-space-*` (SET per size, so `[data-density]` re-scales)
|
|
53
|
+
* - font-size -> `--cngx-font-size-control` at `md`
|
|
54
|
+
* - tone -> `--cngx-color-text` / `--cngx-color-primary` / `--cngx-color-danger`
|
|
55
|
+
* - radius -> `--cngx-radius-md`
|
|
56
|
+
* - touch floor -> `--cngx-target-min`
|
|
57
|
+
* - transition -> `--cngx-duration-fast`
|
|
58
|
+
*
|
|
59
|
+
* **Icon button**
|
|
60
|
+
*
|
|
61
|
+
* `.cngx-icon-button` makes the box square and floors it to the touch
|
|
62
|
+
* target; paint comes from the `.cngx-button` rules above.
|
|
63
|
+
*
|
|
64
|
+
* - The box is `line box + 2 * --cngx-button-padding-block + 2 * border` on
|
|
65
|
+
* both axes, so an `md` icon button is as tall as an `md` button and a
|
|
66
|
+
* form control, and stays square at every size and density.
|
|
67
|
+
* - The box floors to `--cngx-target-min` on both axes (44px on a coarse
|
|
68
|
+
* pointer, 0px and inert on a fine one), so the box is the hit area on
|
|
69
|
+
* touch and in either writing direction; the glyph keeps its design size.
|
|
70
|
+
* - Adjacent icon buttons keep `--cngx-target-gap` between them (WCAG 2.5.8).
|
|
71
|
+
*
|
|
72
|
+
* @themes CngxButton, CngxIconButton, CngxCloseButton, CngxMenuButton, CngxIconMenuButton, CngxPopoverAction, CngxPopoverDismiss, CngxPanelToggle, CngxActionButton
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
@layer cngx.tokens {
|
|
76
|
+
/**
|
|
77
|
+
* Block padding. SET per size from `--cngx-space-*`.
|
|
78
|
+
* @group Layout
|
|
79
|
+
*/
|
|
80
|
+
@property --cngx-button-padding-block {
|
|
81
|
+
syntax: '*';
|
|
82
|
+
inherits: false;
|
|
83
|
+
initial-value: 0.5rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Inline padding. SET per size from `--cngx-space-*`.
|
|
88
|
+
* @group Layout
|
|
89
|
+
*/
|
|
90
|
+
@property --cngx-button-padding-inline {
|
|
91
|
+
syntax: '*';
|
|
92
|
+
inherits: false;
|
|
93
|
+
initial-value: 1rem;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Gap between the slots and the label.
|
|
98
|
+
* @group Layout
|
|
99
|
+
*/
|
|
100
|
+
@property --cngx-button-gap {
|
|
101
|
+
syntax: '*';
|
|
102
|
+
inherits: false;
|
|
103
|
+
initial-value: 0.5rem;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Font size. `md` reads the form-control font so the button shares the
|
|
108
|
+
* control line box.
|
|
109
|
+
* @group Typography
|
|
110
|
+
*/
|
|
111
|
+
@property --cngx-button-font-size {
|
|
112
|
+
syntax: '*';
|
|
113
|
+
inherits: false;
|
|
114
|
+
initial-value: 1rem;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Corner radius.
|
|
119
|
+
* @group Layout
|
|
120
|
+
*/
|
|
121
|
+
@property --cngx-button-radius {
|
|
122
|
+
syntax: '*';
|
|
123
|
+
inherits: false;
|
|
124
|
+
initial-value: 0.5rem;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Border width on all four sides; transparent where the variant paints
|
|
129
|
+
* none, so every variant shares one box.
|
|
130
|
+
* @group Layout
|
|
131
|
+
*/
|
|
132
|
+
@property --cngx-button-border-width {
|
|
133
|
+
syntax: '*';
|
|
134
|
+
inherits: false;
|
|
135
|
+
initial-value: 1px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Transition duration for colour changes. Derives from the
|
|
140
|
+
* `--cngx-duration-fast` rung of the motion scale.
|
|
141
|
+
* @group Motion
|
|
142
|
+
* @relatedTo provideMotion, CngxMotionScope, injectMotion
|
|
143
|
+
*/
|
|
144
|
+
@property --cngx-button-transition {
|
|
145
|
+
syntax: '<time>';
|
|
146
|
+
inherits: false;
|
|
147
|
+
initial-value: 150ms;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Tone colour: the outline border, the hover wash, and the solid fill
|
|
152
|
+
* unless `--cngx-button-tone-fill` is set.
|
|
153
|
+
* @group Tone
|
|
154
|
+
*/
|
|
155
|
+
@property --cngx-button-tone {
|
|
156
|
+
syntax: '*';
|
|
157
|
+
inherits: false;
|
|
158
|
+
initial-value: currentColor;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Text colour on a transparent or tonal surface.
|
|
163
|
+
* @group Tone
|
|
164
|
+
*/
|
|
165
|
+
@property --cngx-button-tone-text {
|
|
166
|
+
syntax: '*';
|
|
167
|
+
inherits: false;
|
|
168
|
+
initial-value: currentColor;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Text colour on the solid tone fill.
|
|
173
|
+
* @group Tone
|
|
174
|
+
*/
|
|
175
|
+
@property --cngx-button-on-tone {
|
|
176
|
+
syntax: '*';
|
|
177
|
+
inherits: false;
|
|
178
|
+
initial-value: Canvas;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Solid fill colour. Set by the primary and danger tones to the strong
|
|
183
|
+
* palette rung their on-colour clears 4.5:1 against; unset, the solid fill
|
|
184
|
+
* falls back to `--cngx-button-tone`. Outline, secondary, ghost and link
|
|
185
|
+
* keep painting from `--cngx-button-tone`. Registered without an initial
|
|
186
|
+
* value so the fallback stays live.
|
|
187
|
+
* @group Tone
|
|
188
|
+
*/
|
|
189
|
+
@property --cngx-button-tone-fill {
|
|
190
|
+
syntax: '*';
|
|
191
|
+
inherits: false;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Diameter of the busy spinner ring, and the box of a bare `svg` or `img`
|
|
196
|
+
* drawn by a `provideButtonSpinner` component.
|
|
197
|
+
* @group Busy
|
|
198
|
+
*/
|
|
199
|
+
@property --cngx-button-spinner-size {
|
|
200
|
+
syntax: '*';
|
|
201
|
+
inherits: true;
|
|
202
|
+
initial-value: 1em;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Stroke width of the busy spinner ring. Inherits so a value set on the
|
|
207
|
+
* button reaches the ring inside the busy layer.
|
|
208
|
+
* @group Busy
|
|
209
|
+
*/
|
|
210
|
+
@property --cngx-button-spinner-thickness {
|
|
211
|
+
syntax: '*';
|
|
212
|
+
inherits: true;
|
|
213
|
+
initial-value: 2px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Colour a solid button's tone mixes towards on hover and press (by
|
|
218
|
+
* `--cngx-button-hover-layer` / `--cngx-button-pressed-layer`), so the fill
|
|
219
|
+
* shifts without a second tone token. By default it is the opposite of
|
|
220
|
+
* `--cngx-button-on-tone` (black under white ink, white under dark ink), so
|
|
221
|
+
* the shaded fill keeps its label contrast; black is only the registered
|
|
222
|
+
* initial.
|
|
223
|
+
* @group Tone
|
|
224
|
+
*/
|
|
225
|
+
@property --cngx-button-hover-shade {
|
|
226
|
+
syntax: '*';
|
|
227
|
+
inherits: false;
|
|
228
|
+
initial-value: oklch(0 0 0);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Underline thickness of a `link` button on hover; at rest it keeps the
|
|
233
|
+
* font's own underline.
|
|
234
|
+
* @group Tone
|
|
235
|
+
*/
|
|
236
|
+
@property --cngx-button-link-hover-thickness {
|
|
237
|
+
syntax: '*';
|
|
238
|
+
inherits: false;
|
|
239
|
+
initial-value: 2px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Edge length of an `svg` or `img` in a start or end slot. Same rung as
|
|
244
|
+
* `--cngx-icon-size-md`, so a projected `cngx-icon` and a bare `svg` match.
|
|
245
|
+
* Inherits so a value set on the button reaches the slot glyph.
|
|
246
|
+
* @group Layout
|
|
247
|
+
*/
|
|
248
|
+
@property --cngx-button-icon-size {
|
|
249
|
+
syntax: '*';
|
|
250
|
+
inherits: true;
|
|
251
|
+
initial-value: 1.25em;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Tint strength of a neutral `secondary` fill and its hover. Light text on
|
|
256
|
+
* a dark surface reads a small tint as almost nothing, so the dark scheme
|
|
257
|
+
* steps both up.
|
|
258
|
+
* @group Tone
|
|
259
|
+
*/
|
|
260
|
+
@property --cngx-button-neutral-tint {
|
|
261
|
+
syntax: '*';
|
|
262
|
+
inherits: true;
|
|
263
|
+
initial-value: 10%;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Hover tint strength of a neutral `secondary` fill.
|
|
268
|
+
* @group Tone
|
|
269
|
+
*/
|
|
270
|
+
@property --cngx-button-neutral-tint-hover {
|
|
271
|
+
syntax: '*';
|
|
272
|
+
inherits: true;
|
|
273
|
+
initial-value: 14%;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Share of `--cngx-button-hover-shade` laid over a solid primary or danger
|
|
278
|
+
* fill on hover, a state layer. A theme maps it to its hover state-layer
|
|
279
|
+
* opacity (the Material bridge: `--mat-sys-hover-state-layer-opacity`).
|
|
280
|
+
* @group State / Hover
|
|
281
|
+
*/
|
|
282
|
+
@property --cngx-button-hover-layer {
|
|
283
|
+
syntax: '*';
|
|
284
|
+
inherits: true;
|
|
285
|
+
initial-value: 12%;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Share of `--cngx-button-hover-shade` laid over a solid primary or danger
|
|
290
|
+
* fill while pressed, one step above `--cngx-button-hover-layer`. A theme
|
|
291
|
+
* maps it to its pressed state-layer opacity (the Material bridge:
|
|
292
|
+
* `--mat-sys-pressed-state-layer-opacity`).
|
|
293
|
+
* @group State / Pressed
|
|
294
|
+
*/
|
|
295
|
+
@property --cngx-button-pressed-layer {
|
|
296
|
+
syntax: '*';
|
|
297
|
+
inherits: true;
|
|
298
|
+
initial-value: 20%;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Tone wash of a pressed `outline` or `ghost` button (hover takes 8%).
|
|
303
|
+
* @group State / Pressed
|
|
304
|
+
*/
|
|
305
|
+
@property --cngx-button-pressed-wash {
|
|
306
|
+
syntax: '*';
|
|
307
|
+
inherits: true;
|
|
308
|
+
initial-value: 12%;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Pressed tint strength of a neutral `secondary` fill, one step above
|
|
313
|
+
* `--cngx-button-neutral-tint-hover`; the dark scheme steps it up.
|
|
314
|
+
* @group State / Pressed
|
|
315
|
+
*/
|
|
316
|
+
@property --cngx-button-neutral-tint-pressed {
|
|
317
|
+
syntax: '*';
|
|
318
|
+
inherits: true;
|
|
319
|
+
initial-value: 18%;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Fill strength of a neutral `solid` button, the tone mixed into the
|
|
324
|
+
* surface. One rung above `--cngx-button-neutral-tint`, so solid stays the
|
|
325
|
+
* stronger neutral fill; the dark scheme steps it up.
|
|
326
|
+
* @group Tone
|
|
327
|
+
*/
|
|
328
|
+
@property --cngx-button-neutral-solid {
|
|
329
|
+
syntax: '*';
|
|
330
|
+
inherits: true;
|
|
331
|
+
initial-value: 18%;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Hover fill strength of a neutral `solid` button.
|
|
336
|
+
* @group State / Hover
|
|
337
|
+
*/
|
|
338
|
+
@property --cngx-button-neutral-solid-hover {
|
|
339
|
+
syntax: '*';
|
|
340
|
+
inherits: true;
|
|
341
|
+
initial-value: 23%;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Pressed fill strength of a neutral `solid` button, one step above
|
|
346
|
+
* `--cngx-button-neutral-solid-hover`.
|
|
347
|
+
* @group State / Pressed
|
|
348
|
+
*/
|
|
349
|
+
@property --cngx-button-neutral-solid-pressed {
|
|
350
|
+
syntax: '*';
|
|
351
|
+
inherits: true;
|
|
352
|
+
initial-value: 28%;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Lightness offset of a primary or danger `secondary` label from the tone
|
|
357
|
+
* text rung, so the label holds 4.5:1 on the stronger wash: darker in the
|
|
358
|
+
* light scheme, lighter in the dark one.
|
|
359
|
+
* @group Tone
|
|
360
|
+
*/
|
|
361
|
+
@property --cngx-button-secondary-text-shift {
|
|
362
|
+
syntax: '*';
|
|
363
|
+
inherits: true;
|
|
364
|
+
initial-value: -0.07;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Pressed fill of a `secondary` button. Unset by default, so the pressed
|
|
369
|
+
* tone mix paints; a theme sets it next to `--cngx-button-secondary-bg-hover`.
|
|
370
|
+
* @group State / Pressed
|
|
371
|
+
*/
|
|
372
|
+
@property --cngx-button-secondary-bg-pressed {
|
|
373
|
+
syntax: '*';
|
|
374
|
+
inherits: false;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Fill of a `secondary` button. Unset by default, so the fill is the tone
|
|
379
|
+
* mixed into transparency (the neutral tint for `neutral`, 20% otherwise).
|
|
380
|
+
* A theme sets it to paint a container colour instead (the Material bridge
|
|
381
|
+
* maps it to the `*-container` roles).
|
|
382
|
+
* @group Tone
|
|
383
|
+
*/
|
|
384
|
+
@property --cngx-button-secondary-bg {
|
|
385
|
+
syntax: '*';
|
|
386
|
+
inherits: false;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Hover fill of a `secondary` button. Unset by default, so hover steps the
|
|
391
|
+
* tone mix up.
|
|
392
|
+
* @group Tone
|
|
393
|
+
*/
|
|
394
|
+
@property --cngx-button-secondary-bg-hover {
|
|
395
|
+
syntax: '*';
|
|
396
|
+
inherits: false;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Text colour of a `secondary` button. Unset by default, so the tone text
|
|
401
|
+
* colour paints.
|
|
402
|
+
* @group Tone
|
|
403
|
+
*/
|
|
404
|
+
@property --cngx-button-secondary-color {
|
|
405
|
+
syntax: '*';
|
|
406
|
+
inherits: false;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
:root {
|
|
410
|
+
--cngx-button-neutral-tint: 10%;
|
|
411
|
+
--cngx-button-neutral-tint-hover: 14%;
|
|
412
|
+
--cngx-button-neutral-tint-pressed: 18%;
|
|
413
|
+
--cngx-button-neutral-solid: 18%;
|
|
414
|
+
--cngx-button-neutral-solid-hover: 23%;
|
|
415
|
+
--cngx-button-neutral-solid-pressed: 28%;
|
|
416
|
+
--cngx-button-secondary-text-shift: -0.07;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
@media (prefers-color-scheme: dark) {
|
|
420
|
+
:root:not([data-color-scheme='light']):not(.light) {
|
|
421
|
+
--cngx-button-neutral-tint: 16%;
|
|
422
|
+
--cngx-button-neutral-tint-hover: 21%;
|
|
423
|
+
--cngx-button-neutral-tint-pressed: 26%;
|
|
424
|
+
--cngx-button-neutral-solid: 26%;
|
|
425
|
+
--cngx-button-neutral-solid-hover: 31%;
|
|
426
|
+
--cngx-button-neutral-solid-pressed: 36%;
|
|
427
|
+
--cngx-button-secondary-text-shift: 0.06;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
[data-color-scheme='dark'],
|
|
432
|
+
.dark {
|
|
433
|
+
--cngx-button-neutral-tint: 16%;
|
|
434
|
+
--cngx-button-neutral-tint-hover: 21%;
|
|
435
|
+
--cngx-button-neutral-tint-pressed: 26%;
|
|
436
|
+
--cngx-button-neutral-solid: 26%;
|
|
437
|
+
--cngx-button-neutral-solid-hover: 31%;
|
|
438
|
+
--cngx-button-neutral-solid-pressed: 36%;
|
|
439
|
+
--cngx-button-secondary-text-shift: 0.06;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
[data-color-scheme='light'],
|
|
443
|
+
.light {
|
|
444
|
+
--cngx-button-neutral-tint: 10%;
|
|
445
|
+
--cngx-button-neutral-tint-hover: 14%;
|
|
446
|
+
--cngx-button-neutral-tint-pressed: 18%;
|
|
447
|
+
--cngx-button-neutral-solid: 18%;
|
|
448
|
+
--cngx-button-neutral-solid-hover: 23%;
|
|
449
|
+
--cngx-button-neutral-solid-pressed: 28%;
|
|
450
|
+
--cngx-button-secondary-text-shift: -0.07;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/* Derive the colour transition from the motion scale; the registered
|
|
454
|
+
* initial-value wins over a read-site fallback, so the token must be SET.
|
|
455
|
+
* The solid hover / press shade is the ink's opposite (white ink gives
|
|
456
|
+
* black, dark ink gives white), so the shaded fill moves away from the
|
|
457
|
+
* label in both schemes. */
|
|
458
|
+
:where(.cngx-button) {
|
|
459
|
+
--cngx-button-transition: var(--cngx-duration-fast);
|
|
460
|
+
--cngx-button-hover-shade: oklch(from var(--cngx-button-on-tone) round(1 - l, 1) 0 0);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
@layer cngx.components {
|
|
465
|
+
/* Row metrics per size, SET from the scale so a [data-density] swap
|
|
466
|
+
* re-scales them. Shared with the button-group addon (it carries the same
|
|
467
|
+
* `data-size`), so an addon sits on the row of the buttons beside it and a
|
|
468
|
+
* theme that re-sets these tokens reaches both. */
|
|
469
|
+
@scope (.cngx-button, .cngx-button-group__addon) {
|
|
470
|
+
:scope {
|
|
471
|
+
/* md: the form-control row (8/16 -> sm/md). The padding-block literal
|
|
472
|
+
keeps the icon-button size calc valid without the core theme: a '*'
|
|
473
|
+
token set to a missing scale token turns invalid, not initial. */
|
|
474
|
+
--cngx-button-padding-block: var(--cngx-space-sm, 8px);
|
|
475
|
+
--cngx-button-padding-inline: var(--cngx-space-md);
|
|
476
|
+
--cngx-button-font-size: var(--cngx-font-size-control, 1rem);
|
|
477
|
+
}
|
|
478
|
+
:scope[data-size='xs'] {
|
|
479
|
+
/* Half the xs rung: tight, but still re-scaled by [data-density]. */
|
|
480
|
+
--cngx-button-padding-block: calc(var(--cngx-space-xs, 4px) / 2);
|
|
481
|
+
--cngx-button-padding-inline: var(--cngx-space-sm);
|
|
482
|
+
--cngx-button-font-size: var(--cngx-font-size-sm, 0.8125rem);
|
|
483
|
+
}
|
|
484
|
+
:scope[data-size='sm'] {
|
|
485
|
+
--cngx-button-padding-block: var(--cngx-space-xs, 4px);
|
|
486
|
+
--cngx-button-padding-inline: var(--cngx-space-sm);
|
|
487
|
+
--cngx-button-font-size: var(--cngx-font-size-sm, 0.8125rem);
|
|
488
|
+
}
|
|
489
|
+
:scope[data-size='lg'] {
|
|
490
|
+
/* One and a half sm rungs: a step above md about as large as sm to md,
|
|
491
|
+
not a full rung jump. */
|
|
492
|
+
--cngx-button-padding-block: calc(var(--cngx-space-sm, 8px) * 1.5);
|
|
493
|
+
--cngx-button-padding-inline: var(--cngx-space-lg);
|
|
494
|
+
--cngx-button-font-size: var(--cngx-font-size-lg, 1.0625rem);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
@scope (.cngx-button) {
|
|
499
|
+
:scope {
|
|
500
|
+
--cngx-button-gap: var(--cngx-space-sm);
|
|
501
|
+
--cngx-button-radius: var(--cngx-radius-md, 0.5rem);
|
|
502
|
+
--cngx-button-tone: var(--cngx-color-text, oklch(0.2 0.01 250));
|
|
503
|
+
--cngx-button-tone-text: var(--cngx-color-text, oklch(0.2 0.01 250));
|
|
504
|
+
--cngx-button-on-tone: var(--cngx-color-surface, oklch(1 0 0));
|
|
505
|
+
/* The button shows its own busy treatment, not the async dim. */
|
|
506
|
+
--cngx-async-pending-opacity: 1;
|
|
507
|
+
|
|
508
|
+
position: relative;
|
|
509
|
+
display: inline-flex;
|
|
510
|
+
align-items: center;
|
|
511
|
+
justify-content: center;
|
|
512
|
+
gap: var(--cngx-button-gap, 0.5rem);
|
|
513
|
+
box-sizing: border-box;
|
|
514
|
+
/* Touch-target floor: inert at 0px on a fine pointer, 44px on coarse. */
|
|
515
|
+
min-block-size: var(--cngx-target-min, 0px);
|
|
516
|
+
padding-block: var(--cngx-button-padding-block);
|
|
517
|
+
padding-inline: var(--cngx-button-padding-inline, 1rem);
|
|
518
|
+
border: var(--cngx-button-border-width, 1px) solid transparent;
|
|
519
|
+
border-radius: var(--cngx-button-radius, 0.5rem);
|
|
520
|
+
background: transparent;
|
|
521
|
+
color: var(--cngx-button-tone-text);
|
|
522
|
+
font: inherit;
|
|
523
|
+
font-size: var(--cngx-button-font-size, 1rem);
|
|
524
|
+
font-weight: var(--cngx-button-font-weight, 500);
|
|
525
|
+
line-height: var(--cngx-line-height-base, 1.5);
|
|
526
|
+
text-decoration: none;
|
|
527
|
+
white-space: nowrap;
|
|
528
|
+
vertical-align: middle;
|
|
529
|
+
cursor: pointer;
|
|
530
|
+
user-select: none;
|
|
531
|
+
transition:
|
|
532
|
+
background-color var(--cngx-button-transition, 150ms) ease,
|
|
533
|
+
border-color var(--cngx-button-transition, 150ms) ease,
|
|
534
|
+
color var(--cngx-button-transition, 150ms) ease;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/* Gap steps; the row metrics live in the shared block above. */
|
|
538
|
+
:scope:is([data-size='xs'], [data-size='sm']) {
|
|
539
|
+
--cngx-button-gap: var(--cngx-space-xs);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/* A filled slot trims the padding on its side. */
|
|
543
|
+
:scope[data-start] {
|
|
544
|
+
padding-inline-start: calc(var(--cngx-button-padding-inline, 1rem) * 0.75);
|
|
545
|
+
}
|
|
546
|
+
:scope[data-end] {
|
|
547
|
+
padding-inline-end: calc(var(--cngx-button-padding-inline, 1rem) * 0.75);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/* Tones set the colours every variant paints from. The solid fill takes
|
|
551
|
+
the strong rung, so its label clears 4.5:1 in both schemes. */
|
|
552
|
+
:scope[data-tone='primary'] {
|
|
553
|
+
--cngx-button-tone: var(--cngx-color-primary, oklch(0.66 0.19 50));
|
|
554
|
+
--cngx-button-tone-text: var(
|
|
555
|
+
--cngx-color-primary-text,
|
|
556
|
+
oklch(from var(--cngx-color-primary, oklch(0.66 0.19 50)) 0.54 c h)
|
|
557
|
+
);
|
|
558
|
+
--cngx-button-tone-fill: var(
|
|
559
|
+
--cngx-color-primary-strong,
|
|
560
|
+
oklch(from var(--cngx-color-primary, oklch(0.66 0.19 50)) 0.58 c h)
|
|
561
|
+
);
|
|
562
|
+
--cngx-button-on-tone: var(--cngx-color-on-primary-strong, oklch(1 0 0));
|
|
563
|
+
}
|
|
564
|
+
:scope[data-tone='danger'] {
|
|
565
|
+
--cngx-button-tone: var(--cngx-color-danger, oklch(0.6 0.18 25));
|
|
566
|
+
--cngx-button-tone-text: var(
|
|
567
|
+
--cngx-color-danger-text,
|
|
568
|
+
oklch(from var(--cngx-color-danger, oklch(0.6 0.18 25)) 0.46 c h)
|
|
569
|
+
);
|
|
570
|
+
--cngx-button-tone-fill: var(
|
|
571
|
+
--cngx-color-danger-strong,
|
|
572
|
+
oklch(from var(--cngx-color-danger, oklch(0.6 0.18 25)) 0.48 c h)
|
|
573
|
+
);
|
|
574
|
+
--cngx-button-on-tone: var(--cngx-color-on-danger-strong, oklch(1 0 0));
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/* Variants. */
|
|
578
|
+
:scope[data-variant='solid'] {
|
|
579
|
+
background: var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor));
|
|
580
|
+
border-color: var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor));
|
|
581
|
+
color: var(--cngx-button-on-tone, Canvas);
|
|
582
|
+
}
|
|
583
|
+
:scope[data-variant='solid']:hover:not([aria-disabled='true']) {
|
|
584
|
+
background: color-mix(
|
|
585
|
+
in oklch,
|
|
586
|
+
var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor))
|
|
587
|
+
calc(100% - var(--cngx-button-hover-layer)),
|
|
588
|
+
var(--cngx-button-hover-shade, oklch(0 0 0))
|
|
589
|
+
);
|
|
590
|
+
border-color: color-mix(
|
|
591
|
+
in oklch,
|
|
592
|
+
var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor))
|
|
593
|
+
calc(100% - var(--cngx-button-hover-layer)),
|
|
594
|
+
var(--cngx-button-hover-shade, oklch(0 0 0))
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
/* Neutral solid is the browser-native default: a light grey fill under the
|
|
598
|
+
text colour, not a fill in the text colour. The loud action is
|
|
599
|
+
tone="primary". */
|
|
600
|
+
:scope[data-variant='solid'][data-tone='neutral'] {
|
|
601
|
+
background: color-mix(
|
|
602
|
+
in oklch,
|
|
603
|
+
var(--cngx-button-tone, currentColor) var(--cngx-button-neutral-solid, 18%),
|
|
604
|
+
var(--cngx-color-surface, Canvas)
|
|
605
|
+
);
|
|
606
|
+
border-color: var(--cngx-color-border, oklch(0.88 0.005 250));
|
|
607
|
+
color: var(--cngx-button-tone-text);
|
|
608
|
+
}
|
|
609
|
+
:scope[data-variant='solid'][data-tone='neutral']:hover:not([aria-disabled='true']) {
|
|
610
|
+
background: color-mix(
|
|
611
|
+
in oklch,
|
|
612
|
+
var(--cngx-button-tone, currentColor) var(--cngx-button-neutral-solid-hover, 23%),
|
|
613
|
+
var(--cngx-color-surface, Canvas)
|
|
614
|
+
);
|
|
615
|
+
border-color: var(--cngx-color-border, oklch(0.88 0.005 250));
|
|
616
|
+
}
|
|
617
|
+
/* The three --cngx-button-secondary-* hooks are unset by default; a theme
|
|
618
|
+
sets them to paint a container colour instead of the tone mix. */
|
|
619
|
+
:scope[data-variant='secondary'] {
|
|
620
|
+
background: var(
|
|
621
|
+
--cngx-button-secondary-bg,
|
|
622
|
+
color-mix(in oklch, var(--cngx-button-tone, currentColor) 20%, transparent)
|
|
623
|
+
);
|
|
624
|
+
color: var(--cngx-button-secondary-color, var(--cngx-button-tone-text));
|
|
625
|
+
}
|
|
626
|
+
/* A primary or danger label sits on a stronger wash than the surface the
|
|
627
|
+
tone text rung is tuned for, so it shifts one step further from it. */
|
|
628
|
+
:scope[data-variant='secondary']:not([data-tone='neutral']) {
|
|
629
|
+
color: var(
|
|
630
|
+
--cngx-button-secondary-color,
|
|
631
|
+
oklch(
|
|
632
|
+
from var(--cngx-button-tone-text) calc(l + var(--cngx-button-secondary-text-shift, -0.07))
|
|
633
|
+
c h
|
|
634
|
+
)
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
:scope[data-variant='secondary']:hover:not([aria-disabled='true']) {
|
|
638
|
+
background: var(
|
|
639
|
+
--cngx-button-secondary-bg-hover,
|
|
640
|
+
color-mix(in oklch, var(--cngx-button-tone, currentColor) 24%, transparent)
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
/* Neutral secondary steps below the neutral solid fill so the two stay apart. */
|
|
644
|
+
:scope[data-variant='secondary'][data-tone='neutral'] {
|
|
645
|
+
background: var(
|
|
646
|
+
--cngx-button-secondary-bg,
|
|
647
|
+
color-mix(
|
|
648
|
+
in oklch,
|
|
649
|
+
var(--cngx-button-tone, currentColor) var(--cngx-button-neutral-tint, 10%),
|
|
650
|
+
transparent
|
|
651
|
+
)
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
:scope[data-variant='secondary'][data-tone='neutral']:hover:not([aria-disabled='true']) {
|
|
655
|
+
background: var(
|
|
656
|
+
--cngx-button-secondary-bg-hover,
|
|
657
|
+
color-mix(
|
|
658
|
+
in oklch,
|
|
659
|
+
var(--cngx-button-tone, currentColor) var(--cngx-button-neutral-tint-hover, 14%),
|
|
660
|
+
transparent
|
|
661
|
+
)
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
/* The boundary is the only cue an outline button has, so it reads the
|
|
665
|
+
* 3:1 border rung (WCAG 1.4.11). A toned edge takes the tone text rung,
|
|
666
|
+
* which holds 4.5:1 against the surface in both schemes. */
|
|
667
|
+
:scope[data-variant='outline'] {
|
|
668
|
+
border-color: var(--cngx-color-border-strong, oklch(0.62 0.005 250));
|
|
669
|
+
}
|
|
670
|
+
:scope[data-variant='outline']:not([data-tone='neutral']) {
|
|
671
|
+
border-color: var(--cngx-button-tone-text);
|
|
672
|
+
}
|
|
673
|
+
:scope:is([data-variant='outline'], [data-variant='ghost']):hover:not([aria-disabled='true']) {
|
|
674
|
+
background: color-mix(in oklch, var(--cngx-button-tone, currentColor) 8%, transparent);
|
|
675
|
+
}
|
|
676
|
+
:scope[data-variant='link'] {
|
|
677
|
+
/* Inline text: no control height and no touch floor (WCAG 2.5.8 inline
|
|
678
|
+
exception). The border stays transparent so the box keeps its shape. */
|
|
679
|
+
min-block-size: 0;
|
|
680
|
+
padding: 0;
|
|
681
|
+
border-width: 0;
|
|
682
|
+
text-decoration: underline;
|
|
683
|
+
text-underline-offset: 0.15em;
|
|
684
|
+
vertical-align: baseline;
|
|
685
|
+
}
|
|
686
|
+
:scope[data-variant='link']:hover:not([aria-disabled='true']) {
|
|
687
|
+
text-decoration-thickness: var(--cngx-button-link-hover-thickness, 2px);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/* Pressed: the hover mix one step stronger, on `:active` and on the
|
|
691
|
+
`.cngx-pressed` class cngxPressable sets on pointerdown (a touch press
|
|
692
|
+
paints without the :active lag). An aria-disabled (or busy) button
|
|
693
|
+
never shows it, nor the hover. A link keeps the hover underline while pressed. */
|
|
694
|
+
:scope[data-variant='solid']:is(:active, .cngx-pressed):not([aria-disabled='true']) {
|
|
695
|
+
background: color-mix(
|
|
696
|
+
in oklch,
|
|
697
|
+
var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor))
|
|
698
|
+
calc(100% - var(--cngx-button-pressed-layer)),
|
|
699
|
+
var(--cngx-button-hover-shade)
|
|
700
|
+
);
|
|
701
|
+
border-color: color-mix(
|
|
702
|
+
in oklch,
|
|
703
|
+
var(--cngx-button-tone-fill, var(--cngx-button-tone, currentColor))
|
|
704
|
+
calc(100% - var(--cngx-button-pressed-layer)),
|
|
705
|
+
var(--cngx-button-hover-shade)
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
:scope[data-variant='solid'][data-tone='neutral']:is(:active, .cngx-pressed):not(
|
|
709
|
+
[aria-disabled='true']
|
|
710
|
+
) {
|
|
711
|
+
background: color-mix(
|
|
712
|
+
in oklch,
|
|
713
|
+
var(--cngx-button-tone, currentColor) var(--cngx-button-neutral-solid-pressed, 28%),
|
|
714
|
+
var(--cngx-color-surface, Canvas)
|
|
715
|
+
);
|
|
716
|
+
border-color: var(--cngx-color-border, oklch(0.88 0.005 250));
|
|
717
|
+
}
|
|
718
|
+
:scope[data-variant='secondary']:is(:active, .cngx-pressed):not([aria-disabled='true']) {
|
|
719
|
+
background: var(
|
|
720
|
+
--cngx-button-secondary-bg-pressed,
|
|
721
|
+
color-mix(in oklch, var(--cngx-button-tone, currentColor) 27%, transparent)
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
:scope[data-variant='secondary'][data-tone='neutral']:is(:active, .cngx-pressed):not(
|
|
725
|
+
[aria-disabled='true']
|
|
726
|
+
) {
|
|
727
|
+
background: var(
|
|
728
|
+
--cngx-button-secondary-bg-pressed,
|
|
729
|
+
color-mix(
|
|
730
|
+
in oklch,
|
|
731
|
+
var(--cngx-button-tone, currentColor) var(--cngx-button-neutral-tint-pressed, 18%),
|
|
732
|
+
transparent
|
|
733
|
+
)
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
:scope:is([data-variant='outline'], [data-variant='ghost']):is(:active, .cngx-pressed):not(
|
|
737
|
+
[aria-disabled='true']
|
|
738
|
+
) {
|
|
739
|
+
background: color-mix(
|
|
740
|
+
in oklch,
|
|
741
|
+
var(--cngx-button-tone, currentColor) var(--cngx-button-pressed-wash),
|
|
742
|
+
transparent
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
:scope[data-variant='link']:is(:active, .cngx-pressed):not([aria-disabled='true']) {
|
|
746
|
+
text-decoration-thickness: var(--cngx-button-link-hover-thickness, 2px);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/* Disabled by colour, never opacity. A busy button is aria-disabled too
|
|
750
|
+
but reads as busy, not disabled - also in the show-delay window, where
|
|
751
|
+
data-pending is set before the gated data-busy. */
|
|
752
|
+
:scope[aria-disabled='true']:not([data-busy], [data-pending]) {
|
|
753
|
+
color: color-mix(in oklab, var(--cngx-color-text, oklch(0.2 0.01 250)) 38%, transparent);
|
|
754
|
+
cursor: not-allowed;
|
|
755
|
+
}
|
|
756
|
+
:scope[aria-disabled='true']:not([data-busy], [data-pending]):is(
|
|
757
|
+
[data-variant='solid'],
|
|
758
|
+
[data-variant='secondary']
|
|
759
|
+
) {
|
|
760
|
+
background: color-mix(in oklab, var(--cngx-color-text, oklch(0.2 0.01 250)) 8%, transparent);
|
|
761
|
+
border-color: transparent;
|
|
762
|
+
}
|
|
763
|
+
:scope[aria-disabled='true']:not([data-busy], [data-pending])[data-variant='outline'] {
|
|
764
|
+
background: transparent;
|
|
765
|
+
border-color: color-mix(
|
|
766
|
+
in oklab,
|
|
767
|
+
var(--cngx-color-text, oklch(0.2 0.01 250)) 20%,
|
|
768
|
+
transparent
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
:scope[aria-disabled='true']:not([data-busy], [data-pending]):is(
|
|
772
|
+
[data-variant='ghost'],
|
|
773
|
+
[data-variant='link']
|
|
774
|
+
) {
|
|
775
|
+
background: transparent;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/* Busy: the label keeps its box (width stable) and its place in the
|
|
779
|
+
accessible name under the ring; opacity, not visibility, which would
|
|
780
|
+
drop it from the name. The ring sits inside cngx-button-adornment
|
|
781
|
+
(display: contents), so the adornment is the one child left lit. */
|
|
782
|
+
:scope[data-busy] {
|
|
783
|
+
cursor: progress;
|
|
784
|
+
}
|
|
785
|
+
:scope[data-busy] > :not(cngx-button-adornment) {
|
|
786
|
+
opacity: 0;
|
|
787
|
+
}
|
|
788
|
+
/* Host hook: a host that renders a status label instead of the spinner
|
|
789
|
+
sets data-status-label, and only the label is lifted back. */
|
|
790
|
+
:scope[data-busy][data-status-label] > .cngx-button__label {
|
|
791
|
+
opacity: 1;
|
|
792
|
+
}
|
|
793
|
+
.cngx-button__busy {
|
|
794
|
+
position: absolute;
|
|
795
|
+
inset: 0;
|
|
796
|
+
display: grid;
|
|
797
|
+
place-items: center;
|
|
798
|
+
}
|
|
799
|
+
.cngx-button__spinner {
|
|
800
|
+
inline-size: var(--cngx-button-spinner-size, 1em);
|
|
801
|
+
block-size: var(--cngx-button-spinner-size, 1em);
|
|
802
|
+
border: var(--cngx-button-spinner-thickness, 2px) solid currentColor;
|
|
803
|
+
border-block-start-color: transparent;
|
|
804
|
+
border-radius: 50%;
|
|
805
|
+
animation: cngx-button-spin var(--cngx-spin-duration, 0.8s) linear infinite;
|
|
806
|
+
}
|
|
807
|
+
/* A CNGX_BUTTON_SPINNER component draws its glyph inside its own host, one
|
|
808
|
+
level below the busy layer; a bare svg or img there has no size of its
|
|
809
|
+
own, so it gets the ring's box. A glyph sized by its component's own
|
|
810
|
+
styles keeps that size (unlayered beats this layer). */
|
|
811
|
+
.cngx-button__busy > * > :is(svg, img) {
|
|
812
|
+
display: block;
|
|
813
|
+
inline-size: round(nearest, var(--cngx-button-spinner-size, 1em), 1px);
|
|
814
|
+
block-size: round(nearest, var(--cngx-button-spinner-size, 1em), 1px);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/* Content slots scale with the button font. */
|
|
818
|
+
.cngx-button__slot {
|
|
819
|
+
display: inline-flex;
|
|
820
|
+
align-items: center;
|
|
821
|
+
flex-shrink: 0;
|
|
822
|
+
line-height: 1;
|
|
823
|
+
}
|
|
824
|
+
/* The slot marker sits on the glyph itself or on a wrapper around it. */
|
|
825
|
+
:is(svg, img).cngx-button__slot,
|
|
826
|
+
.cngx-button__slot > :is(svg, img) {
|
|
827
|
+
inline-size: round(nearest, var(--cngx-button-icon-size, 1.25em), 1px);
|
|
828
|
+
block-size: round(nearest, var(--cngx-button-icon-size, 1.25em), 1px);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/* Stronger chrome on the more-contrast axis: outline borders take the
|
|
832
|
+
tone text, ghost buttons gain a border. */
|
|
833
|
+
[data-contrast='more']
|
|
834
|
+
:scope:is([data-variant='outline'], [data-variant='solid'][data-tone='neutral']) {
|
|
835
|
+
border-color: var(--cngx-button-tone-text);
|
|
836
|
+
}
|
|
837
|
+
[data-contrast='more'] :scope[data-variant='ghost'] {
|
|
838
|
+
border-color: var(--cngx-color-border, oklch(0.88 0.005 250));
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
@keyframes cngx-button-spin {
|
|
844
|
+
to {
|
|
845
|
+
transform: rotate(360deg);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/* Reduced motion: the ring stops, the static ring plus aria-busy (owned by
|
|
850
|
+
* cngxAsyncClick) still say "working". */
|
|
851
|
+
[data-motion='reduced'] .cngx-button__spinner {
|
|
852
|
+
animation: none;
|
|
853
|
+
}
|
|
854
|
+
@media (prefers-reduced-motion: reduce) {
|
|
855
|
+
:root:not([data-motion='full']) .cngx-button__spinner {
|
|
856
|
+
animation: none;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/* forced-colors (WHCM): the host is a form control, so the UA forces its
|
|
861
|
+
* background to ButtonFace over an author fill. `forced-color-adjust: none`
|
|
862
|
+
* opts out so the system pair paints: every variant is a ButtonText border on
|
|
863
|
+
* ButtonFace (link stays LinkText), disabled is GrayText. A solid primary or
|
|
864
|
+
* danger button fills with Highlight so the main action still stands out once
|
|
865
|
+
* colour emphasis is gone. Transitions are off: system colours switch, they
|
|
866
|
+
* never fade through author mixes. The reset's focus outline would keep its author
|
|
867
|
+
* colour under the opt-out, so it is re-pointed at Highlight. Unlayered, outside
|
|
868
|
+
* @scope, `!important` because the base uses `:scope[data-*]` compounds. */
|
|
869
|
+
@media (forced-colors: active) {
|
|
870
|
+
.cngx-button {
|
|
871
|
+
forced-color-adjust: none;
|
|
872
|
+
background: ButtonFace !important;
|
|
873
|
+
color: ButtonText !important;
|
|
874
|
+
border-color: ButtonText !important;
|
|
875
|
+
transition: none !important;
|
|
876
|
+
}
|
|
877
|
+
.cngx-button[data-variant='link'] {
|
|
878
|
+
background: transparent !important;
|
|
879
|
+
color: LinkText !important;
|
|
880
|
+
}
|
|
881
|
+
.cngx-button:hover:not([aria-disabled='true']) {
|
|
882
|
+
border-color: Highlight !important;
|
|
883
|
+
}
|
|
884
|
+
.cngx-button[data-variant='solid']:is([data-tone='primary'], [data-tone='danger']) {
|
|
885
|
+
background: Highlight !important;
|
|
886
|
+
color: HighlightText !important;
|
|
887
|
+
border-color: Highlight !important;
|
|
888
|
+
}
|
|
889
|
+
.cngx-button[data-variant='solid']:is([data-tone='primary'], [data-tone='danger']):hover:not(
|
|
890
|
+
[aria-disabled='true']
|
|
891
|
+
) {
|
|
892
|
+
border-color: ButtonText !important;
|
|
893
|
+
}
|
|
894
|
+
/* Pressed, so a press still reads once the tone mix is gone: ButtonFace
|
|
895
|
+
* buttons fill with Highlight, a link turns ActiveText. A Highlight-filled
|
|
896
|
+
* solid tone keeps its fill (dropping it reads as the button vanishing,
|
|
897
|
+
* and an async button flips aria-disabled mid-press) and marks the press
|
|
898
|
+
* on the edge: a ButtonText border plus an inset ButtonText outline. Never
|
|
899
|
+
* on an aria-disabled (or busy) button. */
|
|
900
|
+
.cngx-button:is(:active, .cngx-pressed):not([aria-disabled='true']) {
|
|
901
|
+
background: Highlight !important;
|
|
902
|
+
color: HighlightText !important;
|
|
903
|
+
border-color: Highlight !important;
|
|
904
|
+
}
|
|
905
|
+
.cngx-button[data-variant='solid']:is([data-tone='primary'], [data-tone='danger']):is(
|
|
906
|
+
:active,
|
|
907
|
+
.cngx-pressed
|
|
908
|
+
):not([aria-disabled='true']) {
|
|
909
|
+
background: Highlight !important;
|
|
910
|
+
color: HighlightText !important;
|
|
911
|
+
border-color: ButtonText !important;
|
|
912
|
+
outline: 2px solid ButtonText !important;
|
|
913
|
+
outline-offset: -3px !important;
|
|
914
|
+
}
|
|
915
|
+
.cngx-button[data-variant='link']:is(:active, .cngx-pressed):not([aria-disabled='true']) {
|
|
916
|
+
background: transparent !important;
|
|
917
|
+
color: ActiveText !important;
|
|
918
|
+
border-color: ButtonText !important;
|
|
919
|
+
}
|
|
920
|
+
.cngx-button[aria-disabled='true']:not([data-busy], [data-pending]) {
|
|
921
|
+
background: ButtonFace !important;
|
|
922
|
+
color: GrayText !important;
|
|
923
|
+
border-color: GrayText !important;
|
|
924
|
+
}
|
|
925
|
+
/* A link is inline text, never a box, disabled or not. */
|
|
926
|
+
.cngx-button[data-variant='link'][aria-disabled='true'] {
|
|
927
|
+
background: transparent !important;
|
|
928
|
+
}
|
|
929
|
+
.cngx-button:focus-visible {
|
|
930
|
+
outline-color: Highlight !important;
|
|
931
|
+
}
|
|
932
|
+
/* The async settle outline is for hosts without their own cue. revert-layer
|
|
933
|
+
* hands a settled button back to its layered outline, the consumer's
|
|
934
|
+
* included, instead of writing one over it. */
|
|
935
|
+
.cngx-button:where(.cngx-async--success, .cngx-async--error):not(:focus-visible) {
|
|
936
|
+
outline: revert-layer;
|
|
937
|
+
outline-offset: revert-layer;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/* Icon button: square box and touch floor (CngxIconButton, CngxCloseButton,
|
|
942
|
+
* CngxIconMenuButton, CngxPanelToggle). */
|
|
943
|
+
|
|
944
|
+
@layer cngx.components {
|
|
945
|
+
@scope (.cngx-icon-button) {
|
|
946
|
+
:scope.cngx-button {
|
|
947
|
+
--cngx-icon-button-size: calc(
|
|
948
|
+
var(--cngx-line-height-base, 1.5) * 1em + 2 * var(--cngx-button-padding-block) + 2 *
|
|
949
|
+
var(--cngx-button-border-width, 1px)
|
|
950
|
+
);
|
|
951
|
+
inline-size: max(var(--cngx-icon-button-size), var(--cngx-target-min, 0px));
|
|
952
|
+
block-size: max(var(--cngx-icon-button-size), var(--cngx-target-min, 0px));
|
|
953
|
+
min-block-size: 0;
|
|
954
|
+
padding: 0;
|
|
955
|
+
flex-shrink: 0;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
.cngx-icon-button__glyph {
|
|
959
|
+
display: inline-flex;
|
|
960
|
+
align-items: center;
|
|
961
|
+
justify-content: center;
|
|
962
|
+
line-height: 1;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
.cngx-icon-button__glyph > :is(svg, img) {
|
|
966
|
+
inline-size: round(nearest, 1.25em, 1px);
|
|
967
|
+
block-size: round(nearest, 1.25em, 1px);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/* Outside @scope: a sibling is not inside the scoping root. */
|
|
972
|
+
.cngx-icon-button + .cngx-icon-button {
|
|
973
|
+
margin-inline-start: var(--cngx-target-gap, 0px);
|
|
974
|
+
}
|
|
975
|
+
}
|