actual-css 0.16.1 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +8 -4
  3. package/components.json +19 -4
  4. package/dist/actual.full.css +464 -80
  5. package/dist/actual.full.js +2 -1
  6. package/dist/actual.full.min.css +1 -1
  7. package/docs/design-notes/app-ui.md +37 -3
  8. package/docs/design-notes/enhancement-contract.md +3 -1
  9. package/docs/navigation.json +17 -3
  10. package/docs/pages/components/accordion.md +8 -0
  11. package/docs/pages/components/alert.md +47 -17
  12. package/docs/pages/components/app-navigation.md +2 -2
  13. package/docs/pages/components/aura.md +2 -2
  14. package/docs/pages/components/badge.md +4 -3
  15. package/docs/pages/components/button.md +3 -0
  16. package/docs/pages/components/card.md +1 -1
  17. package/docs/pages/components/chat.md +2 -2
  18. package/docs/pages/components/dialog.md +36 -0
  19. package/docs/pages/components/drawer.md +52 -8
  20. package/docs/pages/components/fab.md +2 -1
  21. package/docs/pages/components/list.md +1 -1
  22. package/docs/pages/components/meter.md +1 -1
  23. package/docs/pages/components/navbar.md +27 -3
  24. package/docs/pages/components/overview.md +17 -0
  25. package/docs/pages/components/rating.md +111 -12
  26. package/docs/pages/components/segmented.md +36 -1
  27. package/docs/pages/components/shimmer.md +2 -2
  28. package/docs/pages/components/spinner.md +2 -0
  29. package/docs/pages/components/table.md +77 -0
  30. package/docs/pages/components/timeline.md +3 -1
  31. package/docs/pages/enhancements/flyout.md +83 -14
  32. package/docs/pages/enhancements/overview.md +2 -2
  33. package/docs/pages/enhancements/status-bar.md +1 -1
  34. package/docs/pages/enhancements/tabs.md +5 -0
  35. package/docs/pages/examples/overview.md +5 -1
  36. package/docs/pages/forms/ajax.md +101 -0
  37. package/docs/pages/forms/choice-cards.md +1 -1
  38. package/docs/pages/forms/color-swatches.md +31 -2
  39. package/docs/pages/forms/detached-actions.md +1 -1
  40. package/docs/pages/forms/floating-field.md +5 -3
  41. package/docs/pages/forms/form-actions.md +1 -1
  42. package/docs/pages/forms/input-policy.md +1 -1
  43. package/docs/pages/forms/joined-controls.md +9 -4
  44. package/docs/pages/forms/otp.md +2 -2
  45. package/docs/pages/forms/overview.md +1 -1
  46. package/docs/pages/forms/password.md +1 -1
  47. package/docs/pages/forms/states-and-sizes.md +1 -1
  48. package/docs/pages/forms/sticky-actions.md +1 -1
  49. package/docs/pages/forms/unsaved-changes.md +198 -0
  50. package/docs/pages/foundations/philosophy.md +2 -1
  51. package/docs/pages/foundations/theming.md +4 -3
  52. package/docs/pages/foundations/tokens.md +30 -5
  53. package/docs/pages/foundations/typography.md +1 -1
  54. package/docs/pages/guides/introduction.md +1 -1
  55. package/docs/pages/guides/progressive-enhancement.md +31 -50
  56. package/docs/pages/guides/upgrading.md +15 -2
  57. package/docs/pages/layout/app-layout.md +1 -1
  58. package/docs/pages/layout/app-shell.md +1 -1
  59. package/docs/pages/layout/choosing.md +5 -0
  60. package/docs/pages/layout/column-layout.md +23 -9
  61. package/docs/pages/layout/media.md +1 -1
  62. package/docs/pages/layout/overview.md +1 -1
  63. package/docs/pages/layout/scroll-snap.md +1 -1
  64. package/docs/pages/layout/scroll-target.md +1 -1
  65. package/docs/pages/layout/sidebar-layout.md +1 -1
  66. package/docs/pages/layout/sidebar-shell.md +68 -0
  67. package/docs/pages/patterns/code-block.md +1 -1
  68. package/docs/pages/patterns/empty-state.md +74 -0
  69. package/docs/pages/patterns/exclusive-accordion.md +1 -1
  70. package/docs/pages/patterns/hierarchical-nav.md +41 -20
  71. package/docs/pages/patterns/icon-input.md +1 -1
  72. package/docs/pages/patterns/intent-nesting.md +1 -1
  73. package/docs/pages/patterns/navigation-list.md +5 -62
  74. package/docs/pages/patterns/overview.md +1 -1
  75. package/docs/pages/patterns/stat.md +61 -0
  76. package/docs/pages/patterns/structured-lists.md +1 -1
  77. package/docs/pages/utilities/accessibility.md +32 -10
  78. package/docs/pages/utilities/flex.md +1 -1
  79. package/docs/pages/utilities/links.md +1 -1
  80. package/docs/pages/utilities/list.md +1 -1
  81. package/docs/pages/utilities/shape.md +1 -1
  82. package/docs/pages/utilities/sizing-wrapping.md +1 -1
  83. package/docs/pages/utilities/spacing.md +1 -1
  84. package/docs/pages/utilities/text.md +1 -1
  85. package/package.json +4 -1
  86. package/reserved-classes.json +2 -0
  87. package/src/cli/actual-css.js +4 -4
  88. package/src/css/components/accordion.css +10 -6
  89. package/src/css/components/alert.css +4 -0
  90. package/src/css/components/busy.css +25 -0
  91. package/src/css/components/button.css +3 -0
  92. package/src/css/components/drawer.css +37 -3
  93. package/src/css/components/flyout.css +37 -0
  94. package/src/css/components/join.css +14 -0
  95. package/src/css/components/modal.css +3 -0
  96. package/src/css/components/navbar.css +102 -38
  97. package/src/css/components/rating.css +50 -5
  98. package/src/css/components/segmented.css +25 -2
  99. package/src/css/core/theme.css +20 -1
  100. package/src/css/core/tokens.css +4 -1
  101. package/src/css/forms/color-swatch.css +38 -19
  102. package/src/css/forms/custom-select.css +10 -0
  103. package/src/css/forms/input-icon.css +5 -3
  104. package/src/css/layout/index.css +2 -0
  105. package/src/css/layout/sidebar-shell.css +67 -0
  106. package/src/css/typography/prose.css +6 -0
  107. package/src/js/ajax.js +148 -0
  108. package/src/js/dialog.js +59 -2
  109. package/src/js/dirty.js +140 -0
  110. package/src/js/dismiss.js +25 -0
  111. package/src/js/events.js +17 -0
  112. package/src/js/focus.js +12 -0
  113. package/src/js/form-submission.js +34 -0
  114. package/src/js/full.js +2 -0
  115. package/src/js/tab.js +16 -2
  116. package/src/js/validation.js +12 -4
  117. package/src/tooling/design-tokens.js +1 -0
  118. package/src/tooling/theme-contrast.js +44 -4
  119. package/tokens.json +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "actual-css",
3
- "version": "0.16.1",
3
+ "version": "0.17.1",
4
4
  "description": "Plain CSS component framework with semantic classes, universal variants, small tokens, theme hooks, and progressive enhancements.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.4.4",
@@ -72,6 +72,8 @@
72
72
  "./js/tab": "./src/js/tab.js",
73
73
  "./js/tooltip": "./src/js/tooltip.js",
74
74
  "./js/validation": "./src/js/validation.js",
75
+ "./js/dirty": "./src/js/dirty.js",
76
+ "./js/ajax": "./src/js/ajax.js",
75
77
  "./js/status": "./src/js/status.js",
76
78
  "./js/surface": "./src/js/surface.js",
77
79
  "./reserved-classes.json": "./reserved-classes.json",
@@ -150,6 +152,7 @@
150
152
  "shot:states": "bun scripts/shot-states.js",
151
153
  "probe": "bun scripts/probe.js",
152
154
  "serve": "bun scripts/serve.js",
155
+ "play:ajax": "bun --watch scripts/playground/ajax.js",
153
156
  "check:sync": "bun scripts/check-sync.js",
154
157
  "release": "bun scripts/release.js",
155
158
  "release:notes": "bun scripts/release-notes.js",
@@ -207,6 +207,7 @@
207
207
  "shadow-popout-context",
208
208
  "shimmer",
209
209
  "sidebar-layout",
210
+ "sidebar-shell",
210
211
  "skeleton",
211
212
  "sm",
212
213
  "soft",
@@ -259,6 +260,7 @@
259
260
  "touch-target",
260
261
  "truncate",
261
262
  "user-select-none",
263
+ "vertical",
262
264
  "visibility-hidden",
263
265
  "warning",
264
266
  "was-validated"
@@ -27,10 +27,10 @@ function usage() {
27
27
  "Penpot plugin that builds them. Needs Bun (bunx --bun actual-css design ...).",
28
28
  "",
29
29
  "contrast: measure the pairs a theme tunes by hand in headless Chrome, in every",
30
- "scheme it declares: soft ink on its resting and hovered fill, the focus line on",
31
- "--surface and --surface-solid, the invalid-field focus line, and the inverse",
32
- "text. Exits 1 when a pair misses its threshold. Needs Bun (bunx --bun actual-css",
33
- "contrast ...).",
30
+ "scheme it declares: soft ink on its resting and hovered fill, the resting edge",
31
+ "of a field, checkbox and radio, the focus line on --surface and --surface-solid,",
32
+ "the invalid-field focus line, and the inverse text. Exits 1 when a pair misses",
33
+ "its threshold. Needs Bun (bunx --bun actual-css contrast ...).",
34
34
  ].join("\n");
35
35
  }
36
36
 
@@ -104,12 +104,6 @@
104
104
  margin-block-start: 0;
105
105
  }
106
106
 
107
- .accordion details > summary + ul,
108
- .accordion details > summary + ol {
109
- margin: 0;
110
- padding-inline-start: 2rem;
111
- }
112
-
113
107
  /* Flush — the shell is dropped and only the shared item separators remain.
114
108
  Zero inline padding puts the group edge to edge inside the surface that
115
109
  already frames it, so no override is repeated per embedding. */
@@ -130,6 +124,16 @@
130
124
  --surface-pad: 0px;
131
125
  }
132
126
 
127
+ /* A list panel keeps its marker gutter in every treatment. The .flush
128
+ selector is required, not redundant: .flush zeroes the panel's inline
129
+ padding at higher specificity, which would push the bullets out of the
130
+ panel. */
131
+ .accordion details > summary + :is(ul, ol),
132
+ .accordion.flush details > summary + :is(ul, ol) {
133
+ margin: 0;
134
+ padding-inline-start: 2rem;
135
+ }
136
+
133
137
  /* Separated — each item owns a full card. The item's own border beats the
134
138
  shared details + details separator on specificity alone, so nothing needs
135
139
  undoing for the second item onwards. */
@@ -231,6 +231,10 @@
231
231
  border: 0;
232
232
  border-inline-start: var(--alert-border-inline-start-width, 4px) solid
233
233
  var(--alert-border-inline-start-color, var(--intent, var(--neutral)));
234
+ /* why: a thick flag under the large radius curves into a crescent. The
235
+ leading corners take the small radius so the flag stays a straight bar. */
236
+ border-start-start-radius: var(--radius-sm);
237
+ border-end-start-radius: var(--radius-sm);
234
238
  }
235
239
 
236
240
  /* Admonition — structured static box with a tinted title bar and a body
@@ -7,8 +7,13 @@
7
7
  * shows that spinner as a centered overlay over a faded surface. Buttons keep
8
8
  * their spinners inline (e.g. .btn[aria-busy] > .spinner stays inline-flex).
9
9
  *
10
+ * The overlay fades in after --busy-delay, so a fast request leaves the
11
+ * content untouched instead of flashing it. Reduced motion drops the delay
12
+ * with every other animation (reset.css): the overlay then shows at once.
13
+ *
10
14
  * Public hooks:
11
15
  * --busy-overlay-bg
16
+ * --busy-delay
12
17
  *
13
18
  * Internal:
14
19
  * --spinner-size (overlay copy of the shared spinner hook)
@@ -43,6 +48,26 @@
43
48
  margin: auto;
44
49
  display: block;
45
50
  }
51
+
52
+ @media (prefers-reduced-motion: no-preference) {
53
+ [aria-busy="true"]:not(.btn):has(> .spinner:last-child)::before {
54
+ animation: actual-busy-reveal var(--duration-slow) var(--busy-delay, 300ms) ease both;
55
+ }
56
+
57
+ /* Restates the spin: one animation list replaces spinner.css's. */
58
+ [aria-busy="true"]:not(.btn) > .spinner:last-child {
59
+ animation:
60
+ actual-busy-reveal var(--duration-slow) var(--busy-delay, 300ms) ease both,
61
+ actual-spin var(--duration-spin) linear infinite;
62
+ }
63
+ }
64
+ }
65
+
66
+ /* `both` holds the from-frame through the delay. */
67
+ @keyframes actual-busy-reveal {
68
+ from {
69
+ opacity: 0;
70
+ }
46
71
  }
47
72
 
48
73
  @supports (selector([aria-busy="true"]:has(> .spinner:last-child))) and
@@ -106,6 +106,9 @@
106
106
  }
107
107
 
108
108
  .btn.icon-only {
109
+ /* why: beside a full-width control (.join, a flex row) it would share the
110
+ shrink and stop being square. */
111
+ flex: none;
109
112
  inline-size: var(--btn-min-size);
110
113
  block-size: var(--btn-min-size);
111
114
  padding: 0;
@@ -13,14 +13,17 @@
13
13
  * navigation content inside uses .nav-link and .accordion, which carry their
14
14
  * own link/summary styling.
15
15
  *
16
+ * Sides: start (default), end, and bottom (a bottom sheet) via data-side.
17
+ *
16
18
  * Public hooks:
17
- * --drawer-size
19
+ * --drawer-size (width on start/end, maximum height on bottom)
18
20
  * --drawer-pad
19
21
  *
20
22
  * The corner close control is .close (components/close.css).
21
23
  *
22
24
  * Internal:
23
25
  * --drawer-closed-translate (side/RTL positioning state)
26
+ * --drawer-closed-transform (closed position; bottom changes its axis)
24
27
  * --drawer-focus-bleed
25
28
  * --drawer-close-reserve (header room for a corner close; zero without a close)
26
29
  * --drawer-motion-duration (shared by panel and ::backdrop so exit duration
@@ -33,6 +36,9 @@
33
36
  /* The inset a direct .bleed child cancels (components/bleed.css). */
34
37
  --surface-pad: var(--drawer-pad);
35
38
  --drawer-closed-translate: -100%;
39
+ /* The closed position as one transform, so a side can change axis without
40
+ a rule that would tie with [open] on specificity. */
41
+ --drawer-closed-transform: translateX(var(--drawer-closed-translate));
36
42
  /* Header room for a corner close. Unconditional baseline: without :has()
37
43
  (Degraded tier) a header keeps too much room rather than a title running
38
44
  under the close. Zeroed when the drawer has no close. */
@@ -71,7 +77,7 @@
71
77
  color: var(--text);
72
78
  box-shadow: var(--shadow);
73
79
  opacity: 0;
74
- transform: translateX(var(--drawer-closed-translate));
80
+ transform: var(--drawer-closed-transform);
75
81
  /* Unsupported discrete behavior drops alone, preserving opacity/transform. */
76
82
  transition-property: opacity, transform, overlay, display;
77
83
  transition-duration: var(--drawer-motion-duration);
@@ -125,10 +131,32 @@
125
131
  opacity: 1;
126
132
  }
127
133
 
134
+ /* Bottom sheet: the same drawer on the block-end edge, sized by its content
135
+ up to --drawer-size, which reads as a height here. :where() keeps the size
136
+ at the base rule's weight, so an application class still overrides it. */
137
+ :where(dialog).drawer:where([data-side="bottom"]) {
138
+ --drawer-size: 32rem;
139
+ --drawer-closed-transform: translateY(100%);
140
+ }
141
+
142
+ :where(dialog).drawer[data-side="bottom"] {
143
+ inset-block: auto 0;
144
+ inset-inline: 0;
145
+ inline-size: 100%;
146
+ block-size: auto;
147
+ max-block-size: min(calc(var(--viewport-block) * 0.85), var(--drawer-size));
148
+ /* The home indicator sits over the panel's last line otherwise. */
149
+ padding-block-end: calc(var(--drawer-pad) + env(safe-area-inset-bottom, 0px));
150
+ border-inline-end: 0;
151
+ border-block-start: var(--border-width) solid var(--border);
152
+ border-start-start-radius: var(--radius-lg);
153
+ border-start-end-radius: var(--radius-lg);
154
+ }
155
+
128
156
  @starting-style {
129
157
  :where(dialog).drawer[open] {
130
158
  opacity: 0;
131
- transform: translateX(var(--drawer-closed-translate));
159
+ transform: var(--drawer-closed-transform);
132
160
  }
133
161
 
134
162
  :where(dialog).drawer[open]::backdrop {
@@ -156,6 +184,12 @@
156
184
  under the header or footer. */
157
185
  margin: calc(var(--drawer-focus-bleed) * -1);
158
186
  padding: var(--drawer-focus-bleed);
187
+ /* The scrollport reaches the panel's inline-end edge and takes the panel
188
+ padding back inside: the scrollbar sits on the edge and the content keeps
189
+ --drawer-pad on both sides. Inside the content box, the scrollbar sat a
190
+ focus bleed from the text with the panel padding wasted beyond it. */
191
+ margin-inline-end: calc(var(--drawer-pad) * -1);
192
+ padding-inline-end: var(--drawer-pad);
159
193
  overflow: auto;
160
194
  overscroll-behavior: contain;
161
195
  }
@@ -11,6 +11,9 @@
11
11
  * Runtime marker (managed by surface.js): .is-open marks an open flyout.
12
12
  * --surface-anchor-width is set by surface.js while an open flyout is positioned.
13
13
  *
14
+ * Modifier: .scrollable keeps a header and footer in view while the one body
15
+ * region between them scrolls.
16
+ *
14
17
  * Public hooks:
15
18
  * --flyout-inline-size
16
19
  * --flyout-max-inline-size
@@ -18,6 +21,7 @@
18
21
  *
19
22
  * Internal:
20
23
  * --menu-item-size (derived from --control-size for menu rows)
24
+ * --flyout-focus-bleed (focus reserve of the .scrollable body)
21
25
  * --available-height (measured by the positioner)
22
26
  * --surface-anchor-width (measured by surface.js)
23
27
  */
@@ -168,6 +172,39 @@
168
172
  margin: 0;
169
173
  }
170
174
 
175
+ /* .scrollable: the .modal.scrollable contract on a panel with a header, one
176
+ body and a footer — the header and footer keep their size and the body
177
+ absorbs the overflow, so an Apply row stays in view however long the list
178
+ or however little room the positioner leaves. Opt-in, because a menu or a
179
+ multi-section nav panel has no single body to scroll. :where() keeps the
180
+ display at .flyout's weight, so [hidden] and the closed popover still win
181
+ whatever the source order. */
182
+ .flyout:where(.scrollable) {
183
+ display: flex;
184
+ flex-direction: column;
185
+ overflow: hidden;
186
+ }
187
+
188
+ .flyout.scrollable > :is(header, footer) {
189
+ flex: none;
190
+ }
191
+
192
+ .flyout.scrollable > :not(:is(header, footer)) {
193
+ /* Declared here, not as a :root alias: an inherited alias arrives already
194
+ computed, so a --focus-ring-width override on the panel would not reach
195
+ it. */
196
+ --flyout-focus-bleed: calc(var(--focus-outline-offset) + var(--focus-ring-width));
197
+
198
+ flex: 1 1 auto;
199
+ min-block-size: 0;
200
+ /* Keep focus paint inside the clip without moving the content: the reserve
201
+ reaches into the panel gap and padding, both --space-10 by default. */
202
+ margin: calc(var(--flyout-focus-bleed) * -1);
203
+ padding: var(--flyout-focus-bleed);
204
+ overflow: auto;
205
+ overscroll-behavior: contain;
206
+ }
207
+
171
208
  /* Vertical dividers — .menu-separator (menu.css) is the canonical way to
172
209
  separate menu items. Flyout panels that are not menus use auto grid gap
173
210
  declared on .flyout itself. */
@@ -98,6 +98,20 @@
98
98
  margin-inline-start: calc(var(--border-width) * -1);
99
99
  }
100
100
 
101
+ /* Seam between adjacent filled buttons (default, .solid, .soft): their border
102
+ is transparent, so "Left Middle Right" read as one button. A quarter of the
103
+ ink turns that edge into a hairline; the mix keeps a soft rim set by
104
+ --soft-border-mix. Variants that already draw an edge, or have no fill, keep
105
+ their border untouched. Chained :not(): a list inside :not() is above
106
+ the Firefox 78 floor. */
107
+ .join > .btn + .btn:not(.outline):not(.surface):not(.ghost):not(.link) {
108
+ border-inline-start-color: color-mix(
109
+ in oklab,
110
+ var(--btn-border-color, var(--btn-border)),
111
+ var(--btn-fg) 25%
112
+ );
113
+ }
114
+
101
115
  .join > :is(:hover, :focus, :focus-within) {
102
116
  z-index: 1;
103
117
  }
@@ -55,6 +55,9 @@
55
55
  /* Keep the surface anchored to the viewport in the top layer. This also
56
56
  provides the containing block for the absolutely positioned close button. */
57
57
  position: fixed;
58
+ /* Restates the UA centering: a modal authored inside .stack or .cluster
59
+ would otherwise take their child margin reset and pin to the top. */
60
+ margin: auto;
58
61
 
59
62
  /* The root is :where(dialog).modal (0-1-0), so a single author class can
60
63
  outrank these defaults — no fallback-only indirection needed here. */
@@ -8,7 +8,9 @@
8
8
  * list shared with .drawer, fed by the shared --gap token.
9
9
  *
10
10
  * Public hooks:
11
- * --state-selected-text (fallback-only: current-link ink, see tokens.css)
11
+ * --nav-current-bg (fallback-only: current-link fill)
12
+ * --nav-current-fg (fallback-only: current-link ink)
13
+ * --nav-list-indent (fallback-only: nested .nav-list inset)
12
14
  *
13
15
  * Internal:
14
16
  * --gap (local value for the shared gap token)
@@ -59,6 +61,8 @@
59
61
  .nav-link {
60
62
  display: inline-flex;
61
63
  align-items: center;
64
+ /* Icon + label rows; a text-only link has one flex item and shows no gap. */
65
+ gap: var(--space-20);
62
66
  min-block-size: var(--control-size-sm);
63
67
  padding-block: 0;
64
68
  padding-inline: var(--space-20);
@@ -72,43 +76,48 @@
72
76
  cursor: pointer;
73
77
  }
74
78
 
75
- /* nav-link serves two contracts: plain page navigation (aria-current="page")
76
- and scrollspy, which toggles aria-current="location" on the active link.
77
- Those two values are the contract; any other, "false" included, is inert.
78
- Selection never changes text metrics: the shared medium weight is kept and
79
- the current link is carried by the selected accent. */
79
+ /* nav-link serves three contracts: plain page navigation (aria-current="page"),
80
+ scrollspy, which toggles aria-current="location" on the active link, and
81
+ section navigation (aria-current="true"): a link whose section holds the
82
+ current page without being it, as on .tab. Those three values are the
83
+ contract; any other, "false" included, is inert.
84
+ Selection never changes text metrics: the shared medium weight is kept.
85
+
86
+ The current link is neutral: full --text ink over a stronger tint of it,
87
+ against --text-muted at rest. That is a luminance step on both ink and
88
+ fill, so the state does not rest on hue. A brand-accent ink was measured
89
+ and dropped: on light presets the accent is already at 4.5:1 on the page,
90
+ so any fill strong enough to carry the state pushed it under. */
80
91
  .nav-link:hover {
81
92
  background: var(--surface-subtle);
82
93
  color: var(--text);
83
94
  }
84
95
 
85
96
  /* Current last, equal specificity to :hover (0,2,0): a hovered current link
86
- keeps the selected accent instead of dropping to --text. The surface fill is
87
- shared with the hover rule above. */
88
- .nav-link:is([aria-current="page"], [aria-current="location"]) {
89
- background: var(--surface-subtle);
90
- color: var(--state-selected-text, var(--state-selected));
97
+ keeps its current fill. */
98
+ .nav-link:is([aria-current="page"], [aria-current="location"], [aria-current="true"]) {
99
+ background: var(--nav-current-bg, var(--surface-subtle));
100
+ color: var(--nav-current-fg, var(--text));
91
101
  }
92
102
 
93
- /* On a bar with its own --ui-bg/--ui-fg the fill is a tint of the link's own
94
- ink, the .btn.ghost hover recipe, so it reads on light and dark bars alike
95
- instead of snapping back to --surface-subtle. Not --ui-hover-bg: that is the
96
- bar's own hover and can equal its fill. The ink follows --ui-fg too — the
97
- selected accent has no contrast pair with an arbitrary bar. The baseline
98
- above keeps the light chip where color-mix is missing, with ink that is
99
- legible on it. */
103
+ /* Fills are a tint of the link's own ink, like the .btn.ghost hover, so they
104
+ read on light and dark bars alike, including a bar with its own
105
+ --ui-bg/--ui-fg. Not --ui-hover-bg: that is the bar's own hover and can
106
+ equal its fill. Current is a step above hover (8% vs 5%), so the current
107
+ link stays apart while another is hovered. Both stay paler than the ghost
108
+ button: a nav row is wide, and at 18% a full-width current row read as a
109
+ pressed button. The fill only seconds the ink step, so it needs no 3:1 of
110
+ its own. The baseline above keeps a light chip where color-mix is
111
+ missing. */
100
112
  @supports (color: color-mix(in oklch, red, white)) {
101
- .nav-link:is(:hover, [aria-current="page"], [aria-current="location"]) {
102
- background: color-mix(in oklch, currentColor 10%, transparent);
103
- }
104
-
105
113
  .nav-link:hover {
114
+ background: color-mix(in oklch, currentColor 5%, transparent);
106
115
  color: var(--ui-fg, var(--text));
107
116
  }
108
117
 
109
- /* After :hover so a hovered current link keeps the selected accent. */
110
- .nav-link:is([aria-current="page"], [aria-current="location"]) {
111
- color: var(--ui-fg, var(--state-selected-text, var(--state-selected)));
118
+ .nav-link:is([aria-current="page"], [aria-current="location"], [aria-current="true"]) {
119
+ background: var(--nav-current-bg, color-mix(in oklch, currentColor 8%, transparent));
120
+ color: var(--nav-current-fg, var(--ui-fg, var(--text)));
112
121
  }
113
122
  }
114
123
 
@@ -132,23 +141,78 @@
132
141
  margin: 0;
133
142
  }
134
143
 
144
+ /* The positioning context lives on every row link, so becoming current never
145
+ moves an app-positioned decoration (or the forced-colors trait below) to a
146
+ new containing block. */
135
147
  .nav-list .nav-link {
136
148
  position: relative;
137
149
  inline-size: 100%;
138
150
  }
139
151
 
140
- /* Vertical current indicator: inset inline-start trait in currentColor, so it
141
- follows the forced palette without a forced-colors block and never touches
142
- the row separators. Navbar horizontal links keep color + surface only. The
143
- positioning context lives on every row link, so becoming current never moves
144
- an app-positioned decoration to a new containing block.
145
- The trait sits centered in the link's inline padding with rounded ends: flush
146
- on the edge, a square line read as pasted onto the rounded fill. */
147
- .nav-list .nav-link:is([aria-current="page"], [aria-current="location"])::before {
152
+ /* Collapsible group: <details> in a row, <summary class="nav-link"> as its
153
+ label, a nested .nav-list as its links. The summary takes the link's row,
154
+ hover and focus; display: inline-flex already drops the list-item marker,
155
+ the WebKit pseudo is Safari's own. */
156
+ .nav-list summary.nav-link {
157
+ list-style: none;
158
+ }
159
+
160
+ .nav-list summary.nav-link::-webkit-details-marker {
161
+ display: none;
162
+ }
163
+
164
+ /* The open state is the native [open], so the chevron needs no script. */
165
+ .nav-list summary.nav-link::after {
148
166
  content: "";
149
- position: absolute;
150
- inset-block: var(--space-20);
151
- inset-inline-start: calc((var(--space-20) - 2px) / 2);
152
- border-inline-start: 2px solid currentColor;
153
- border-radius: var(--radius-full);
167
+ flex: 0 0 auto;
168
+ margin-inline-start: auto;
169
+ inline-size: 1rem;
170
+ block-size: 1rem;
171
+ background-color: currentColor;
172
+ -webkit-mask: var(--icon-chevron) center / contain no-repeat;
173
+ mask: var(--icon-chevron) center / contain no-repeat;
174
+ transition: transform var(--duration);
175
+ }
176
+
177
+ .nav-list details[open] > summary.nav-link::after {
178
+ transform: rotate(180deg);
179
+ }
180
+
181
+ /* A nested list is indented so its labels start under the parent's label,
182
+ past a 1em leading icon and the link gap. Fallback-only: a base
183
+ declaration on .nav-list would reset an override at every level. */
184
+ .nav-list .nav-list {
185
+ margin-block-start: var(--gap);
186
+ padding-inline-start: var(--nav-list-indent, calc(1em + var(--space-20)));
187
+ }
188
+
189
+ /* Forced colors drops the fill and maps both inks to LinkText, so the current
190
+ link would be indistinguishable: it gets a shape instead. A vertical row
191
+ takes an inline-start trait, centered in the link's inline padding with
192
+ rounded ends; a horizontal link an underline. */
193
+ @media (forced-colors: active) {
194
+ .nav-link:is([aria-current="page"], [aria-current="location"], [aria-current="true"]) {
195
+ text-decoration: underline;
196
+ text-underline-offset: 0.25em;
197
+ }
198
+
199
+ .nav-list .nav-link:is([aria-current="page"], [aria-current="location"], [aria-current="true"]) {
200
+ text-decoration: none;
201
+ }
202
+
203
+ /* The chevron is a mask over a fill that forced colors would remap to
204
+ Canvas, as in accordion.css. */
205
+ .nav-list summary.nav-link::after {
206
+ background-color: CanvasText;
207
+ }
208
+
209
+ .nav-list
210
+ .nav-link:is([aria-current="page"], [aria-current="location"], [aria-current="true"])::before {
211
+ content: "";
212
+ position: absolute;
213
+ inset-block: var(--space-20);
214
+ inset-inline-start: calc((var(--space-20) - 2px) / 2);
215
+ border-inline-start: 2px solid currentColor;
216
+ border-radius: var(--radius-full);
217
+ }
154
218
  }
@@ -17,10 +17,12 @@
17
17
  * --rating-color
18
18
  * --rating-empty
19
19
  * --rating-star
20
+ * --rating-star-empty (the empty star's shape; the filled one by default)
20
21
  * --rating-value (display: the shown value, fractions allowed)
21
22
  * --rating-max (display: the number of stars)
22
23
  *
23
24
  * Internal:
25
+ * --rating-shape
24
26
  * --rating-fill
25
27
  * --rating-direction
26
28
  */
@@ -30,10 +32,12 @@
30
32
 
31
33
  .rating {
32
34
  --rating-size: 1.25rem;
33
- --rating-gap: 0.1rem;
35
+ --rating-gap: var(--space-10);
34
36
  --rating-color: var(--intent, var(--warning));
35
37
  --rating-empty: var(--border);
36
38
  --rating-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='2 2 16 16'%3E%3Cpath d='M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 0 0 .95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 0 0-.364 1.118l1.07 3.292c.3.922-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 0 0-1.175 0l-2.8 2.034c-.783.57-1.838-.196-1.539-1.118l1.07-3.292a1 1 0 0 0-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 0 0 .951-.69l1.07-3.292Z'/%3E%3C/svg%3E");
39
+ /* An outline here turns the empty stars into a shape cue (see the docs). */
40
+ --rating-star-empty: var(--rating-star);
37
41
 
38
42
  display: inline-flex;
39
43
  gap: 0;
@@ -44,19 +48,29 @@
44
48
  appearance: none;
45
49
  flex: 0 0 auto;
46
50
  inline-size: calc(var(--rating-size) + var(--rating-gap));
47
- block-size: var(--rating-size);
51
+ /* Taller than the star: the hit area grows, the drawing does not. */
52
+ block-size: calc(var(--rating-size) + var(--space-20));
48
53
  margin: 0;
49
54
  border: 0;
50
55
  background: var(--rating-empty);
51
56
  /* Contiguous radio boxes own hit-testing; the centered mask preserves the
52
- star's proportions while leaving a purely visual gap between values. */
53
- -webkit-mask: var(--rating-star) center / var(--rating-size) var(--rating-size) no-repeat;
54
- mask: var(--rating-star) center / var(--rating-size) var(--rating-size) no-repeat;
57
+ star's proportions while leaving a purely visual gap between values.
58
+ A rule that fills a star sets --rating-shape, never mask-image: a state
59
+ selector outranks the forced-colors mask: none below, and its mask-image
60
+ would clip the native radio there. */
61
+ -webkit-mask:
62
+ var(--rating-shape, var(--rating-star-empty)) center / var(--rating-size) var(--rating-size)
63
+ no-repeat;
64
+ mask:
65
+ var(--rating-shape, var(--rating-star-empty)) center / var(--rating-size) var(--rating-size)
66
+ no-repeat;
55
67
  cursor: pointer;
56
68
  transition: background-color var(--duration);
57
69
  }
58
70
 
59
71
  .rating > input[type="radio"]:checked {
72
+ --rating-shape: var(--rating-star);
73
+
60
74
  background: var(--rating-color);
61
75
  }
62
76
 
@@ -68,6 +82,8 @@
68
82
  .rating > input[type="radio"]:focus-visible {
69
83
  outline: var(--focus-ring-width) solid var(--focus);
70
84
  outline-offset: var(--focus-outline-offset);
85
+ --rating-shape: var(--rating-star);
86
+
71
87
  background: var(--rating-color);
72
88
  }
73
89
 
@@ -75,18 +91,24 @@
75
91
  star. The enhancement only adds cumulative checked and hover previews. */
76
92
  @supports selector(:has(*)) {
77
93
  .rating > input[type="radio"]:has(~ input[type="radio"]:checked) {
94
+ --rating-shape: var(--rating-star);
95
+
78
96
  background: var(--rating-color);
79
97
  }
80
98
 
81
99
  @media (hover: hover) {
82
100
  .rating > input[type="radio"]:not(:disabled):hover,
83
101
  .rating > input[type="radio"]:has(~ input[type="radio"]:not(:disabled):hover) {
102
+ --rating-shape: var(--rating-star);
103
+
84
104
  background: var(--rating-color);
85
105
  }
86
106
 
87
107
  /* A hovered value previews exactly that value: later stars are emptied,
88
108
  including a previously checked star beyond the pointer. */
89
109
  .rating > input[type="radio"]:not(:disabled):hover ~ input[type="radio"] {
110
+ --rating-shape: var(--rating-star-empty);
111
+
90
112
  background: var(--rating-empty);
91
113
  }
92
114
  }
@@ -117,6 +139,29 @@
117
139
  repeat-x;
118
140
  }
119
141
 
142
+ /* The filled share in the filled shape, the rest in the empty one:
143
+ (filled star ∩ value band) ∪ empty star. With the default empty shape it
144
+ draws exactly the single layer above. Guarded on purpose: the declaration
145
+ holds var(), so an engine without composite keywords would not drop it at
146
+ parse time but invalidate it at computed time, leaving no mask at all — a
147
+ solid bar. Without it (Chromium before 120), a custom empty shape shows as
148
+ filled-shape empty stars. */
149
+ @supports (mask-composite: intersect) {
150
+ .rating[role="img"] {
151
+ mask:
152
+ var(--rating-star) left center / calc(var(--rating-size) + var(--rating-gap))
153
+ var(--rating-size) repeat-x intersect,
154
+ linear-gradient(
155
+ var(--rating-direction),
156
+ #000 var(--rating-fill),
157
+ transparent var(--rating-fill)
158
+ )
159
+ add,
160
+ var(--rating-star-empty) left center / calc(var(--rating-size) + var(--rating-gap))
161
+ var(--rating-size) repeat-x;
162
+ }
163
+ }
164
+
120
165
  /* The fill starts at the inline start; only the direction changes, so the
121
166
  forced-colors gradient below follows it too. Safari before 16.4 has no
122
167
  :dir(); the attribute path is its fallback, as in avatar.css. Each selector