actual-css 0.17.1 → 0.19.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/CHANGELOG.md +87 -0
- package/README.md +10 -6
- package/components.json +26 -6
- package/dist/actual.full.css +484 -76
- package/dist/actual.full.js +2 -2
- package/dist/actual.full.min.css +1 -1
- package/docs/design-notes/enhancement-contract.md +20 -11
- package/docs/design-notes/motion-cost.md +62 -0
- package/docs/design-notes/tokens.md +6 -1
- package/docs/navigation.json +4 -0
- package/docs/pages/components/alert.md +8 -6
- package/docs/pages/components/aura.md +3 -0
- package/docs/pages/components/button.md +26 -24
- package/docs/pages/components/list.md +117 -29
- package/docs/pages/components/mark-sweep.md +42 -0
- package/docs/pages/components/rating.md +53 -22
- package/docs/pages/components/reveal.md +54 -0
- package/docs/pages/components/shimmer.md +3 -2
- package/docs/pages/components/timeline.md +130 -2
- package/docs/pages/enhancements/in-view.md +109 -0
- package/docs/pages/enhancements/overview.md +3 -2
- package/docs/pages/enhancements/scrollspy.md +5 -5
- package/docs/pages/examples/overview.md +7 -2
- package/docs/pages/forms/date-picker.md +3 -2
- package/docs/pages/forms/switch.md +25 -16
- package/docs/pages/foundations/theming.md +6 -4
- package/docs/pages/foundations/tokens.md +39 -16
- package/docs/pages/foundations/typography.md +13 -2
- package/docs/pages/guides/coding-agents.md +163 -0
- package/docs/pages/guides/introduction.md +1 -1
- package/docs/pages/guides/modular-import.md +1 -1
- package/docs/pages/guides/progressive-enhancement.md +2 -1
- package/docs/pages/guides/upgrading.md +2 -2
- package/docs/pages/layout/scroll-snap.md +26 -1
- package/docs/pages/patterns/code-block.md +1 -1
- package/docs/pages/patterns/empty-state.md +3 -3
- package/docs/pages/patterns/exclusive-accordion.md +3 -2
- package/docs/pages/patterns/hierarchical-nav.md +5 -4
- package/docs/pages/patterns/icon-input.md +1 -1
- package/docs/pages/patterns/icon-slot.md +4 -4
- package/docs/pages/patterns/intent-nesting.md +2 -3
- package/docs/pages/patterns/navigation-list.md +7 -4
- package/docs/pages/patterns/stat.md +3 -3
- package/docs/pages/patterns/structured-lists.md +1 -2
- package/llms.txt +3 -2
- package/package.json +3 -1
- package/reserved-classes.json +6 -0
- package/skills/actual-css/PROJECT.md.example +13 -2
- package/skills/actual-css/README.md +5 -0
- package/skills/actual-css/SKILL.md +13 -2
- package/src/css/components/alert.css +40 -3
- package/src/css/components/button.css +20 -2
- package/src/css/components/join.css +3 -10
- package/src/css/components/list.css +32 -0
- package/src/css/components/navbar.css +13 -5
- package/src/css/components/rating.css +23 -2
- package/src/css/components/scrollspy.css +4 -2
- package/src/css/components/timeline.css +113 -10
- package/src/css/core/base.css +16 -0
- package/src/css/core/focus.css +13 -12
- package/src/css/core/reset.css +10 -0
- package/src/css/core/theme.css +15 -0
- package/src/css/core/tokens.css +8 -11
- package/src/css/effects/aura.css +5 -0
- package/src/css/effects/index.css +2 -0
- package/src/css/effects/mark-sweep.css +64 -0
- package/src/css/effects/reveal.css +66 -0
- package/src/css/effects/shimmer.css +28 -10
- package/src/css/forms/switch.css +9 -9
- package/src/js/full.js +1 -0
- package/src/js/in-view.js +152 -0
- package/src/js/scrollspy.js +81 -2
- package/src/js/selectors.js +3 -0
- package/src/tooling/design-components.js +2 -2
- package/src/tooling/design-tokens.js +2 -0
- package/tokens.json +2 -0
package/src/js/scrollspy.js
CHANGED
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
* share the viewport — and guesses wrong for sections shorter than the band.
|
|
12
12
|
*
|
|
13
13
|
* activation line = root top + offset (default 20% of the root's height)
|
|
14
|
+
* near scroll end = line advances to the root bottom over the last viewport
|
|
14
15
|
* active section = last section whose top <= activation line
|
|
15
16
|
* scrolled to end = last section, whatever the line says
|
|
16
17
|
* above the first = no active section
|
|
18
|
+
* followed link = its section, until the next scroll input
|
|
19
|
+
* (wheel, touch, key, pointer); the line then starts
|
|
20
|
+
* between that heading and the next and fades back
|
|
17
21
|
*
|
|
18
22
|
* Optional root: data-scrollspy-root="#scroll-container" measures against a
|
|
19
23
|
* scroll container instead of the viewport.
|
|
@@ -106,6 +110,10 @@ function setupNav(nav) {
|
|
|
106
110
|
let sections = [];
|
|
107
111
|
let frame = 0;
|
|
108
112
|
let current;
|
|
113
|
+
// A followed link bends the activation line to sit between its heading and
|
|
114
|
+
// the next: { section, held, scrollTop, remaining, floor, delta }. Held until
|
|
115
|
+
// the next scroll input, then faded; floor is where the upward fade ends.
|
|
116
|
+
let anchor = null;
|
|
109
117
|
|
|
110
118
|
function activate(section) {
|
|
111
119
|
if (section === current) return;
|
|
@@ -126,15 +134,55 @@ function setupNav(nav) {
|
|
|
126
134
|
|
|
127
135
|
const root = rootFor(nav);
|
|
128
136
|
const { top, height, scrollTop, scrollHeight } = measureRoot(nav, root);
|
|
137
|
+
const offset = activationOffset(nav, height);
|
|
138
|
+
// A fixed line followed by an end-of-scroll jump can skip whole sections
|
|
139
|
+
// on a tall viewport. Advance continuously through the final viewport of
|
|
140
|
+
// scroll travel so each intervening heading can become current first.
|
|
141
|
+
const remaining = scrollHeight - height - scrollTop;
|
|
142
|
+
const progress = height > 0 ? Math.max(0, Math.min(1, 1 - remaining / height)) : 0;
|
|
143
|
+
let line = top + offset + Math.max(0, height - offset) * progress;
|
|
144
|
+
|
|
145
|
+
// A followed link names its section outright. Near the end of the page
|
|
146
|
+
// the browser cannot scroll that heading up to the line, so geometry
|
|
147
|
+
// alone would keep a later section. While held (through a smooth scroll
|
|
148
|
+
// on the way there), the bend is recomputed at each position.
|
|
149
|
+
if (anchor?.held) {
|
|
150
|
+
const index = sections.findIndex(({ section }) => section === anchor.section);
|
|
151
|
+
const next = sections[index + 1]?.section;
|
|
152
|
+
const low = anchor.section.getBoundingClientRect().top;
|
|
153
|
+
const high = next ? next.getBoundingClientRect().top - 1 : Infinity;
|
|
154
|
+
Object.assign(anchor, {
|
|
155
|
+
scrollTop,
|
|
156
|
+
remaining,
|
|
157
|
+
floor: Math.max(0, scrollTop - height),
|
|
158
|
+
delta: Math.min(Math.max(line, low), high) - line,
|
|
159
|
+
});
|
|
160
|
+
line += anchor.delta;
|
|
161
|
+
} else if (anchor) {
|
|
162
|
+
// Released, the bend fades over the scroll travel left in each
|
|
163
|
+
// direction: down to the end of the content, up to one viewport above
|
|
164
|
+
// the release. Scrolling on then walks the neighbouring sections in
|
|
165
|
+
// order instead of jumping to whatever the unbent line picks there.
|
|
166
|
+
// Re-based on every measure, so it only ever shrinks: coming back to the
|
|
167
|
+
// release position does not bend the line again.
|
|
168
|
+
const travel = scrollTop - anchor.scrollTop;
|
|
169
|
+
const span = travel > 0 ? anchor.remaining : anchor.scrollTop - anchor.floor;
|
|
170
|
+
const delta = span > 0 ? anchor.delta * Math.max(0, 1 - Math.abs(travel) / span) : 0;
|
|
171
|
+
// Negated so NaN drops too: a pin released before its first measure.
|
|
172
|
+
if (!(Math.abs(delta) >= 0.5)) anchor = null;
|
|
173
|
+
else {
|
|
174
|
+
line += delta;
|
|
175
|
+
anchor = { ...anchor, scrollTop, remaining, delta };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
129
178
|
|
|
130
179
|
// Scrolled to the end: the last section wins even when its top never
|
|
131
180
|
// crosses the line. This is the case IntersectionObserver cannot express.
|
|
132
|
-
if (scrollHeight > height &&
|
|
181
|
+
if (!anchor && scrollHeight > height && remaining <= 1) {
|
|
133
182
|
activate(sections.at(-1).section);
|
|
134
183
|
return;
|
|
135
184
|
}
|
|
136
185
|
|
|
137
|
-
const line = top + activationOffset(nav, height);
|
|
138
186
|
let active = null;
|
|
139
187
|
for (const { section } of sections) {
|
|
140
188
|
if (section.getBoundingClientRect().top <= line) active = section;
|
|
@@ -151,9 +199,17 @@ function setupNav(nav) {
|
|
|
151
199
|
function rebuild() {
|
|
152
200
|
sections = sectionsFor(nav);
|
|
153
201
|
current = undefined;
|
|
202
|
+
anchor = null;
|
|
154
203
|
measure();
|
|
155
204
|
}
|
|
156
205
|
|
|
206
|
+
function pin(link) {
|
|
207
|
+
const entry = sections.find((candidate) => candidate.link === link);
|
|
208
|
+
if (!entry) return;
|
|
209
|
+
anchor = { section: entry.section, held: true };
|
|
210
|
+
schedule();
|
|
211
|
+
}
|
|
212
|
+
|
|
157
213
|
// The scroll root is resolved once when the enhancement connects, and the
|
|
158
214
|
// scroll listener stays on it. Changing data-scrollspy-root or replacing its
|
|
159
215
|
// target is outside the connection contract; recreate the enhancement with
|
|
@@ -168,6 +224,29 @@ function setupNav(nav) {
|
|
|
168
224
|
signal: controller.signal,
|
|
169
225
|
});
|
|
170
226
|
|
|
227
|
+
const doc = nav.ownerDocument;
|
|
228
|
+
nav.addEventListener("click", (event) => pin(event.target.closest?.("a[href^='#']")), {
|
|
229
|
+
signal: controller.signal,
|
|
230
|
+
});
|
|
231
|
+
// Another in-page link, or history navigation, to one of the sections.
|
|
232
|
+
doc.defaultView?.addEventListener(
|
|
233
|
+
"hashchange",
|
|
234
|
+
() => pin(sections.find(({ link }) => link.hash === doc.location.hash)?.link),
|
|
235
|
+
{ signal: controller.signal },
|
|
236
|
+
);
|
|
237
|
+
// Scroll input, not the scroll event: the navigation itself scrolls. Capture
|
|
238
|
+
// runs before the click that may pin again (pointerdown, Enter on a link).
|
|
239
|
+
for (const type of ["wheel", "touchstart", "keydown", "pointerdown"]) {
|
|
240
|
+
doc.addEventListener(
|
|
241
|
+
type,
|
|
242
|
+
() => {
|
|
243
|
+
// No measure here: the scroll this input causes runs it.
|
|
244
|
+
if (anchor) anchor.held = false;
|
|
245
|
+
},
|
|
246
|
+
{ capture: true, passive: true, signal: controller.signal },
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
171
250
|
// Observer is scoped to the nav subtree — link injection is caught;
|
|
172
251
|
// section-only DOM mutations elsewhere need an explicit refreshScrollspy().
|
|
173
252
|
const mo = new MutationObserver(() => schedule(rebuild));
|
package/src/js/selectors.js
CHANGED
|
@@ -35,6 +35,9 @@ export const CLASSES = {
|
|
|
35
35
|
// surface.js — state class on the open flyout/menu/dialog surface.
|
|
36
36
|
// status.js writes the same class on the status bar while a message shows.
|
|
37
37
|
open: "is-open",
|
|
38
|
+
// in-view.js — transient state on an element that waits outside the viewport
|
|
39
|
+
// for its first appearance. Each effect's CSS decides how to hide it.
|
|
40
|
+
pending: "is-pending",
|
|
38
41
|
// dialog.js — transient class for the "can't dismiss" shake animation.
|
|
39
42
|
static: "is-static",
|
|
40
43
|
// dialog.js — written on <html> while any modal dialog is open.
|
|
@@ -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
|
|
128
|
-
//
|
|
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>`)
|