actual-css 0.17.0 → 0.18.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 (92) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +7 -5
  3. package/components.json +20 -4
  4. package/dist/actual.full.css +301 -48
  5. package/dist/actual.full.min.css +1 -1
  6. package/docs/design-notes/tokens.md +2 -1
  7. package/docs/navigation.json +4 -2
  8. package/docs/pages/components/accordion.md +8 -0
  9. package/docs/pages/components/alert.md +15 -11
  10. package/docs/pages/components/app-navigation.md +2 -2
  11. package/docs/pages/components/aura.md +2 -2
  12. package/docs/pages/components/badge.md +4 -3
  13. package/docs/pages/components/button.md +26 -24
  14. package/docs/pages/components/card.md +1 -1
  15. package/docs/pages/components/chat.md +2 -2
  16. package/docs/pages/components/fab.md +2 -1
  17. package/docs/pages/components/list.md +118 -30
  18. package/docs/pages/components/meter.md +1 -1
  19. package/docs/pages/components/navbar.md +1 -1
  20. package/docs/pages/components/overview.md +17 -0
  21. package/docs/pages/components/shimmer.md +2 -2
  22. package/docs/pages/components/timeline.md +130 -2
  23. package/docs/pages/enhancements/overview.md +2 -2
  24. package/docs/pages/enhancements/status-bar.md +1 -1
  25. package/docs/pages/examples/overview.md +2 -0
  26. package/docs/pages/forms/ajax.md +1 -1
  27. package/docs/pages/forms/choice-cards.md +1 -1
  28. package/docs/pages/forms/detached-actions.md +1 -1
  29. package/docs/pages/forms/floating-field.md +5 -3
  30. package/docs/pages/forms/form-actions.md +1 -1
  31. package/docs/pages/forms/input-policy.md +1 -1
  32. package/docs/pages/forms/joined-controls.md +1 -1
  33. package/docs/pages/forms/otp.md +2 -2
  34. package/docs/pages/forms/password.md +1 -1
  35. package/docs/pages/forms/states-and-sizes.md +1 -1
  36. package/docs/pages/forms/sticky-actions.md +1 -1
  37. package/docs/pages/forms/unsaved-changes.md +1 -1
  38. package/docs/pages/foundations/theming.md +8 -6
  39. package/docs/pages/foundations/tokens.md +33 -7
  40. package/docs/pages/foundations/typography.md +6 -1
  41. package/docs/pages/guides/coding-agents.md +163 -0
  42. package/docs/pages/guides/introduction.md +1 -1
  43. package/docs/pages/guides/progressive-enhancement.md +1 -1
  44. package/docs/pages/guides/upgrading.md +1 -1
  45. package/docs/pages/layout/app-layout.md +1 -1
  46. package/docs/pages/layout/app-shell.md +1 -1
  47. package/docs/pages/layout/column-layout.md +1 -1
  48. package/docs/pages/layout/media.md +1 -1
  49. package/docs/pages/layout/overview.md +1 -1
  50. package/docs/pages/layout/scroll-snap.md +27 -2
  51. package/docs/pages/layout/scroll-target.md +1 -1
  52. package/docs/pages/layout/sidebar-layout.md +1 -1
  53. package/docs/pages/layout/sidebar-shell.md +1 -1
  54. package/docs/pages/patterns/code-block.md +1 -1
  55. package/docs/pages/patterns/exclusive-accordion.md +1 -1
  56. package/docs/pages/patterns/hierarchical-nav.md +1 -1
  57. package/docs/pages/patterns/icon-input.md +1 -1
  58. package/docs/pages/patterns/intent-nesting.md +1 -1
  59. package/docs/pages/patterns/navigation-list.md +2 -2
  60. package/docs/pages/patterns/overview.md +1 -1
  61. package/docs/pages/patterns/structured-lists.md +1 -1
  62. package/docs/pages/utilities/flex.md +1 -1
  63. package/docs/pages/utilities/links.md +1 -1
  64. package/docs/pages/utilities/list.md +1 -1
  65. package/docs/pages/utilities/shape.md +1 -1
  66. package/docs/pages/utilities/sizing-wrapping.md +1 -1
  67. package/docs/pages/utilities/spacing.md +1 -1
  68. package/docs/pages/utilities/text.md +1 -1
  69. package/llms.txt +1 -1
  70. package/package.json +1 -1
  71. package/reserved-classes.json +2 -0
  72. package/skills/actual-css/PROJECT.md.example +13 -2
  73. package/skills/actual-css/README.md +5 -0
  74. package/skills/actual-css/SKILL.md +13 -2
  75. package/src/cli/actual-css.js +4 -4
  76. package/src/css/components/accordion.css +10 -6
  77. package/src/css/components/alert.css +44 -3
  78. package/src/css/components/button.css +20 -2
  79. package/src/css/components/join.css +17 -10
  80. package/src/css/components/list.css +32 -0
  81. package/src/css/components/navbar.css +9 -6
  82. package/src/css/components/timeline.css +113 -10
  83. package/src/css/core/theme.css +20 -1
  84. package/src/css/core/tokens.css +8 -2
  85. package/src/css/forms/choice.css +7 -0
  86. package/src/css/forms/custom-select.css +10 -5
  87. package/src/css/forms/input-icon.css +5 -3
  88. package/src/css/typography/prose.css +6 -0
  89. package/src/tooling/design-components.js +2 -2
  90. package/src/tooling/design-tokens.js +1 -0
  91. package/src/tooling/theme-contrast.js +41 -2
  92. package/tokens.json +1 -0
@@ -16,18 +16,29 @@
16
16
  * place. A direct <time> child is the event's dateline. The content stays in
17
17
  * block flow, so a sentence mixing text and links is never split into items.
18
18
  *
19
+ * .timeline-dates-end moves every dateline to the inline end of the event's
20
+ * first line, beside the title instead of above it.
21
+ *
19
22
  * Progress through a process is .steps, not a timeline.
20
23
  *
21
24
  * Public hooks:
22
25
  * --timeline-dot-size
23
26
  * --timeline-slot-size
27
+ * --timeline-glyph-size
24
28
  * --timeline-gap
25
29
  * --timeline-inline-gap
26
30
  * --timeline-line-size
31
+ * --timeline-marker-nudge
27
32
  *
28
33
  * Internal:
29
34
  * --timeline-rail-size
30
35
  * --timeline-line-box
36
+ * --timeline-marker-shift
37
+ * --timeline-marker-inset
38
+ * --timeline-marker-center
39
+ * --timeline-slot-bg
40
+ * --timeline-slot-border
41
+ * --timeline-slot-fg
31
42
  */
32
43
 
33
44
  /* Registered so the event's line box computes to a length on the <li> and
@@ -43,9 +54,18 @@
43
54
  initial-value: 0px;
44
55
  }
45
56
 
57
+ /* An author nudge in em must resolve against the event's text before it
58
+ inherits into a slot with a different glyph size. */
59
+ @property --timeline-marker-shift {
60
+ syntax: "<length>";
61
+ inherits: true;
62
+ initial-value: 0px;
63
+ }
64
+
46
65
  .timeline {
47
66
  --timeline-dot-size: 0.625rem;
48
- --timeline-slot-size: 1.75rem;
67
+ --timeline-slot-size: 2rem;
68
+ --timeline-glyph-size: calc(var(--timeline-slot-size) / 2);
49
69
  --timeline-gap: var(--density-space);
50
70
  --timeline-inline-gap: var(--space-30);
51
71
  --timeline-line-size: var(--border-width);
@@ -73,11 +93,38 @@
73
93
 
74
94
  /* The line box is a length, not the unitless ratio: a smaller <time> opening
75
95
  the event keeps the same first line as text would, so the marker centred on
76
- it lines up whichever element comes first. */
96
+ it lines up whichever element comes first.
97
+
98
+ A slot taller than the line box would overflow the event above and below:
99
+ the first marker would poke out of the list (clipped by a card with
100
+ overflow), and the gap between two discs would shrink below the gap. The
101
+ inset pushes the first line down until the marker, nudge included, starts
102
+ at the top, and the minimum size ends the event at the marker's bottom, so
103
+ the event box always holds its marker. Every marker position derives from
104
+ the one centre.
105
+
106
+ Points, discs and avatars share the first line box's centre. The nudge
107
+ moves that shared geometry; correct an off-centre glyph inside its disc
108
+ instead, so the marker and rail stay aligned. */
77
109
  .timeline > li {
78
110
  --timeline-line-box: calc(var(--line-height) * 1em);
111
+ --timeline-marker-shift: var(--timeline-marker-nudge, 0px);
112
+ --timeline-marker-inset: max(
113
+ 0px,
114
+ (var(--timeline-rail-size) - var(--timeline-line-box)) /
115
+ 2 -
116
+ var(--timeline-marker-shift)
117
+ );
118
+ --timeline-marker-center: calc(
119
+ var(--timeline-marker-inset) +
120
+ var(--timeline-line-box) /
121
+ 2 +
122
+ var(--timeline-marker-shift)
123
+ );
79
124
 
80
125
  position: relative;
126
+ min-block-size: calc(var(--timeline-marker-center) + var(--timeline-rail-size) / 2);
127
+ padding-block-start: var(--timeline-marker-inset);
81
128
  padding-inline-start: calc(var(--timeline-rail-size) + var(--timeline-inline-gap));
82
129
  line-height: var(--timeline-line-box);
83
130
  }
@@ -92,12 +139,43 @@
92
139
  display: block;
93
140
  color: var(--text-muted);
94
141
  font-size: var(--font-size-sm);
142
+ /* Equal-width digits keep times aligned down the list. */
143
+ font-variant-numeric: tabular-nums;
144
+ }
145
+
146
+ /* A float, not a grid: a grid would turn each run of bare text between links
147
+ into its own item and split the sentence. The dateline comes first in the
148
+ source, so it floats on the first line and shares its line box; the text
149
+ wraps beside it, and the next lines take the full width. flow-root keeps a
150
+ float taller than a one-line event inside the <li>, where the rail segment
151
+ measures from. */
152
+ .timeline-dates-end > li {
153
+ display: flow-root;
154
+ }
155
+
156
+ .timeline-dates-end > li > time {
157
+ float: inline-end;
158
+ /* The strut below grows the dateline's line past the line box; held to
159
+ one line box, the float never narrows the event's second line. */
160
+ block-size: var(--timeline-line-box);
161
+ margin-inline-start: var(--timeline-inline-gap);
162
+ }
163
+
164
+ /* A float lays out its own line, so the smaller dateline centres in the line
165
+ box while the title beside it sits on the event's baseline: a pixel or two
166
+ apart, by font, and the eye compares baselines on a shared row. An empty
167
+ strut at the event's font size gives the dateline's line that same
168
+ baseline. The size comes from the registered line box, since 1em here is
169
+ the dateline's own. */
170
+ .timeline-dates-end > li > time::before {
171
+ content: "";
172
+ font-size: calc(var(--timeline-line-box) / var(--line-height));
95
173
  }
96
174
 
97
175
  .timeline > li::before {
98
176
  content: "";
99
177
  position: absolute;
100
- inset-block-start: calc((var(--timeline-line-box) - var(--timeline-dot-size)) / 2);
178
+ inset-block-start: calc(var(--timeline-marker-center) - var(--timeline-dot-size) / 2);
101
179
  inset-inline-start: calc((var(--timeline-rail-size) - var(--timeline-dot-size)) / 2);
102
180
  inline-size: var(--timeline-dot-size);
103
181
  block-size: var(--timeline-dot-size);
@@ -119,7 +197,7 @@
119
197
  .timeline > li:not(:last-child)::after {
120
198
  content: "";
121
199
  position: absolute;
122
- inset-block-start: calc((var(--timeline-line-box) + var(--timeline-rail-size)) / 2);
200
+ inset-block-start: calc(var(--timeline-marker-center) + var(--timeline-rail-size) / 2);
123
201
  inset-inline-start: calc((var(--timeline-rail-size) - var(--timeline-line-size)) / 2);
124
202
  block-size: calc(100% + var(--timeline-gap) - var(--timeline-rail-size));
125
203
  border-inline-start: var(--timeline-line-size) solid var(--border);
@@ -129,25 +207,50 @@
129
207
  --avatar-size: var(--timeline-rail-size);
130
208
 
131
209
  position: absolute;
132
- inset-block-start: calc((var(--timeline-line-box) - var(--timeline-rail-size)) / 2);
210
+ inset-block-start: calc(var(--timeline-marker-center) - var(--timeline-rail-size) / 2);
133
211
  inset-inline-start: 0;
134
212
  }
135
213
 
136
214
  /* An icon slot gets a disc of the avatar's size, so both slot kinds read as one
137
- rail. The event's intent colors the glyph. */
215
+ rail. The event's intent colors the glyph, sized from the slot so a larger
216
+ disc never looks empty. */
138
217
  .timeline > li > [aria-hidden="true"]:first-child:not(.avatar) {
139
218
  display: grid;
140
219
  place-items: center;
141
220
  inline-size: var(--timeline-rail-size);
142
221
  block-size: var(--timeline-rail-size);
143
- border: var(--border-width) solid var(--border);
222
+ border: var(--border-width) solid var(--timeline-slot-border, var(--border));
144
223
  border-radius: var(--radius-full);
145
- background: var(--surface-opaque);
146
- color: var(--intent, var(--text-muted));
147
- font-size: var(--font-size-sm);
224
+ background: var(--timeline-slot-bg, var(--surface-opaque));
225
+ color: var(--timeline-slot-fg, var(--intent, var(--text-muted)));
226
+ font-size: var(--timeline-glyph-size);
148
227
  line-height: 1;
149
228
  }
150
229
 
230
+ /* An event with an intent tints its disc like a soft badge: a translucent
231
+ fill, a rim, and the soft ink. Each mix names var(--intent) bare, so an
232
+ event without one leaves them guaranteed-invalid and the disc falls back to
233
+ the neutral surface above. Guarded because an unsupported color-mix() in a
234
+ custom property is not dropped: it would void the fallback with it. */
235
+ @supports (color: color-mix(in oklch, red, white)) {
236
+ .timeline > li > [aria-hidden="true"]:first-child:not(.avatar) {
237
+ --timeline-slot-bg: color-mix(
238
+ in oklab,
239
+ var(--intent) calc(100% - var(--soft-bg-mix)),
240
+ transparent
241
+ );
242
+ --timeline-slot-border: color-mix(
243
+ in oklab,
244
+ var(--intent) calc(100% - var(--soft-border-mix, 70%)),
245
+ transparent
246
+ );
247
+ --timeline-slot-fg: var(
248
+ --intent-soft-fg,
249
+ color-mix(in oklab, var(--text), var(--intent) var(--soft-fg-mix))
250
+ );
251
+ }
252
+ }
253
+
151
254
  .timeline > li > [aria-hidden="true"]:first-child:not(.avatar) > svg {
152
255
  inline-size: 1em;
153
256
  block-size: 1em;
@@ -118,13 +118,32 @@
118
118
  --surface-opaque: var(--surface);
119
119
  --surface-solid-fg: var(--surface);
120
120
  /* The edge that tells a control apart from the surface, where --border only
121
- separates surfaces: fields, choices, switch, OTP cells, choice cards. */
121
+ separates surfaces: fields, choices, switch, OTP cells, choice cards.
122
+ Derived from the ink: the default palette clears 3:1 against the surface
123
+ in both schemes (WCAG 1.4.11: an unchecked radio is identified by its edge
124
+ alone), where --border sat at ~1.3:1. The mix is not a guarantee for every
125
+ palette: a low-contrast ink lands under 3:1, which the contrast report
126
+ (control edge) shows. Mixed into the opaque surface so a translucent theme
127
+ still draws a solid edge. The plain fallback matters: without color-mix
128
+ the var() is invalid at computed time and takes the whole border
129
+ shorthand with it, erasing every field and choice outline. */
122
130
  --border-control: var(--border);
123
131
  /* Inherited resting field fill, shared with external control bridges.
124
132
  Component state rules still own readonly, disabled and invalid fills. */
125
133
  --control-default-bg: var(--surface);
126
134
  }
127
135
 
136
+ @supports (color: color-mix(in oklab, red, white)) {
137
+ :root,
138
+ [data-theme] {
139
+ --border-control: color-mix(
140
+ in oklab,
141
+ var(--text) var(--border-control-mix),
142
+ var(--surface-opaque)
143
+ );
144
+ }
145
+ }
146
+
128
147
  /* Soft foreground hooks — the soft ink is the intent rebated toward the local
129
148
  text so it keeps 4.5:1 against the soft hover fill (the resting fill carries
130
149
  the extra margin; variants.css soft recipe). Deliberately scoped to the
@@ -23,12 +23,15 @@
23
23
  */
24
24
 
25
25
  /* Typography */
26
- --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
26
+ /* The platform's own faces, never a download: a framework cannot assume a
27
+ locally installed family, and naming one renders the same page differently
28
+ on two machines of the same OS. The docs site loads a webfont instead. */
29
+ --font-sans: system-ui, sans-serif;
27
30
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
28
31
  --font-width: 100%;
29
32
  --line-height: 1.5;
30
33
  --line-height-tight: 1.25;
31
- --line-height-relaxed: 1.75;
34
+ --line-height-relaxed: 1.6;
32
35
  --font-weight-normal: 400;
33
36
  --font-weight-medium: 500;
34
37
  --font-weight-semibold: 600;
@@ -206,6 +209,9 @@
206
209
  the hovered soft fill instead (theme.css); this mix is the fallback a
207
210
  theme without hooks falls back to. */
208
211
  --soft-fg-mix: 100%;
212
+ /* Control edge: the share of ink in --border-control (theme.css). Raise it
213
+ when a tinted or translucent surface pulls the edge under 3:1. */
214
+ --border-control-mix: 45%;
209
215
 
210
216
  /* Shared icon assets. Override these URLs when a strict CSP disallows data:. */
211
217
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238a8594' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
@@ -226,6 +226,13 @@
226
226
  --choice-border: var(--text-subtle);
227
227
  }
228
228
 
229
+ /* A bare checkbox or radio (a table row selector, an application's native
230
+ control) is boxed by its own skin, not text-like: it takes the themed ring
231
+ instead of the core currentColor fallback, which paints the text ink. */
232
+ :where(input[type="checkbox"], input[type="radio"]) {
233
+ --focus-outline-color: var(--focus);
234
+ }
235
+
229
236
  .check:focus-visible,
230
237
  .radio:focus-visible {
231
238
  outline: var(--focus-ring-width) solid var(--focus);
@@ -17,14 +17,19 @@
17
17
  pointer: fine
18
18
  ) {
19
19
  @supports (appearance: base-select) {
20
+ /* why: base-select brings a UA padding-block (0.25em) that the native
21
+ select lacks; with a 24px line it pushed a .compact select to 34px
22
+ against --control-size 32px. min-block-size and align-items already
23
+ center the value. Zero specificity: the reset only has to beat the UA
24
+ sheet, and at (0,3,0) it erased the headroom .floating-field reserves,
25
+ so the floated label sat on the value. */
26
+ :where(.select:not([multiple], .native, [size]:not([size="1"]))) {
27
+ padding-block: 0;
28
+ }
29
+
20
30
  .select:not([multiple], .native, [size]:not([size="1"])) {
21
31
  appearance: base-select;
22
32
  align-items: center;
23
- /* why: base-select brings a UA padding-block (0.25em) that the native
24
- select lacks; with a 24px line it pushed a .compact select to 34px
25
- against --control-size 32px. min-block-size and align-items already
26
- center the value. */
27
- padding-block: 0;
28
33
 
29
34
  &::picker(select) {
30
35
  appearance: base-select;
@@ -49,14 +49,16 @@
49
49
  block-size: 1em;
50
50
  }
51
51
 
52
- /* Leading: input gets start padding to clear the icon */
52
+ /* Leading: input gets start padding to clear the icon. The text sits half a
53
+ pad from the icon: a full pad, the same as the icon's inset from the edge,
54
+ read as two separate items rather than an icon labelling its field. */
53
55
  .input-icon > :first-child:where(:not(.input)) ~ .input {
54
- padding-inline-start: calc(var(--control-pad-x) * 2 + var(--input-icon-size));
56
+ padding-inline-start: calc(var(--control-pad-x) * 1.5 + var(--input-icon-size));
55
57
  }
56
58
 
57
59
  /* Trailing: the input has a following sibling → end padding. Not tied to the
58
60
  input being first child, so a leading icon does not disable the trailing
59
61
  icon's reserved space. */
60
62
  .input-icon > .input:where(:not(:last-child)) {
61
- padding-inline-end: calc(var(--control-pad-x) * 2 + var(--input-icon-size));
63
+ padding-inline-end: calc(var(--control-pad-x) * 1.5 + var(--input-icon-size));
62
64
  }
@@ -163,6 +163,9 @@
163
163
 
164
164
  /* Overflow containment is global on `pre` (base.css); only the box is prose's. */
165
165
  .prose :where(pre) {
166
+ /* why: code is scanned line by line, not read as running text; the prose
167
+ reading leading spread a block to ~1.7 lines per line of code. */
168
+ line-height: var(--line-height);
166
169
  padding: 1em;
167
170
  border: var(--border-width) solid var(--border);
168
171
  border-radius: var(--radius);
@@ -192,6 +195,9 @@
192
195
  }
193
196
 
194
197
  .prose :where(table) {
198
+ /* why: tables are scanned cell by cell, like code; the reading leading made
199
+ every wrapped cell tall and loose. */
200
+ line-height: var(--line-height);
195
201
  inline-size: 100%;
196
202
  border-collapse: collapse;
197
203
  }
@@ -124,8 +124,8 @@ function measureSpecimens({ css, islands, specimens, width }) {
124
124
  if (attribute) island.dataset.theme = attribute;
125
125
  if (scheme) island.style.colorScheme = scheme;
126
126
  // What body gives the page: an island does not reset `color`, and the
127
- // currentColor variants (outline, ghost, link) would otherwise inherit
128
- // the ink of body's scheme instead of this island's.
127
+ // currentColor inks (outline, ghost, link) would otherwise inherit the
128
+ // ink of body's scheme instead of this island's.
129
129
  island.style.color = "var(--text)";
130
130
  island.innerHTML = specimens
131
131
  .map((html) => `<div style="inline-size: ${width}">${html}</div>`)
@@ -128,6 +128,7 @@ export const NOT_EXPORTED = {
128
128
  "soft-border-mix",
129
129
  "soft-hover-alpha",
130
130
  "soft-fg-mix",
131
+ "border-control-mix",
131
132
  "focus-outline-color",
132
133
  ],
133
134
  "soft recipe, exported with the components": [
@@ -5,6 +5,7 @@
5
5
  * (`bun run report:theme-contrast`).
6
6
  *
7
7
  * Measured per island (one per color scheme the theme declares):
8
+ * - the resting edge of a field, checkbox and radio against --surface (3:1)
8
9
  * - soft ink against the resting and the hovered soft fill (4.5:1), on each
9
10
  * surface a soft element sits on
10
11
  * - the solid pairs, -fg on the intent fill (4.5:1); a fill painted by a
@@ -64,9 +65,21 @@ function islandMarkup(id, scheme) {
64
65
  <span data-pair="focus-solid" style="color: var(--focus); background: var(--surface-solid)"></span>
65
66
  <span data-pair="inverse" style="color: var(--surface-solid-fg); background: var(--surface-solid)"></span>
66
67
  <input class="input" aria-invalid="true" data-pair="invalid-field" aria-label="t">
68
+ <div data-controls style="background: var(--surface)">
69
+ ${CONTROLS.map(([kind, markup]) => markup.replace("<input", `<input data-control="${kind}" aria-label="t"`)).join("")}
70
+ </div>
67
71
  </div>`;
68
72
  }
69
73
 
74
+ /* Controls whose resting edge is all that identifies them (WCAG 1.4.11): the
75
+ edge against the surface around them needs 3:1. The field is read on its
76
+ block-end side, the one an underline-only theme (material) keeps. */
77
+ export const CONTROLS = [
78
+ ["field", '<input class="input">'],
79
+ ["checkbox", '<input class="check" type="checkbox">'],
80
+ ["radio", '<input class="radio" type="radio">'],
81
+ ];
82
+
70
83
  const ratio = (fg, bg) => (fg[3] < 255 || bg[3] < 255 ? null : contrast(fg, bg));
71
84
 
72
85
  /*
@@ -186,12 +199,20 @@ export async function measureContrast({ css, themes, label = "default" }) {
186
199
  selected,
187
200
  };
188
201
  }
189
- return { pairs, soft, solid };
202
+ const box = island.querySelector("[data-controls]");
203
+ const controls = { backdrop: rgba(cs(box).backgroundColor), edges: {} };
204
+ for (const el of box.querySelectorAll("[data-control]")) {
205
+ const s = cs(el);
206
+ controls.edges[el.dataset.control] = rgba(
207
+ el.dataset.control === "field" ? s.borderBlockEndColor : s.borderTopColor,
208
+ );
209
+ }
210
+ return { pairs, soft, solid, controls };
190
211
  });
191
212
  })()`);
192
213
 
193
214
  return islands.map(({ theme, scheme }, i) => {
194
- const { pairs, soft, solid } = colors[i];
215
+ const { pairs, soft, solid, controls } = colors[i];
195
216
  const pair = (key) => ratio(pairs[key].fg, pairs[key].bg);
196
217
  // Fill over the surface, then ink over the fill: the colors the page shows.
197
218
  const shown = (fg, fill, backdrop) => {
@@ -232,6 +253,15 @@ export async function measureContrast({ css, themes, label = "default" }) {
232
253
  hover: shown(fills[intent].fg, fills[intent].hover, backdrop),
233
254
  }));
234
255
  }),
256
+ // A translucent edge is composited over the surface; a translucent
257
+ // surface has no defined backdrop and reads n/a.
258
+ controls: CONTROLS.map(([kind]) => ({
259
+ kind,
260
+ value:
261
+ controls.backdrop[3] < 255
262
+ ? null
263
+ : ratio(composite(controls.edges[kind], controls.backdrop), controls.backdrop),
264
+ })),
235
265
  focusSurface: pair("focus-surface"),
236
266
  focusSolid: pair("focus-solid"),
237
267
  invalidFocus: pair("invalid-field"),
@@ -328,6 +358,15 @@ export function formatContrast(rows) {
328
358
  );
329
359
  }
330
360
 
361
+ lines.push("", "Control edge at rest (--border-control vs --surface), needs 3:1.", "");
362
+ lines.push(`${"theme".padEnd(width)} scheme control ratio`);
363
+ for (const row of rows) {
364
+ for (const { kind, value } of row.controls ?? []) {
365
+ const c = cell(value, 3);
366
+ lines.push(`${head(row)} ${kind.padEnd(9)} ${c.text.padStart(8)}${flag([c], 3)}`);
367
+ }
368
+ }
369
+
331
370
  // Documented exception (focus.css): an invalid field focuses in
332
371
  // --form-invalid-border. The line is inset, so it reads against the
333
372
  // field's own background, not the surface around it.
package/tokens.json CHANGED
@@ -6,6 +6,7 @@
6
6
  "--bar-height",
7
7
  "--border",
8
8
  "--border-control",
9
+ "--border-control-mix",
9
10
  "--border-width",
10
11
  "--choice-control-size",
11
12
  "--control-default-bg",