Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Basalt has one owner (Bailey) and a design panel of two independent design revie
exception).
- **WCAG 2.2 AA everywhere:** 4.5:1 for text, 3:1 for boundaries, focus and icons, on every surface the pair can appear on, in both
themes. One exception, by name: a `RunTimeline`'s tail recedes below 4.5:1 from its second row (`opacity-recede-2` to `-5`), because
the control above it opens the whole record at full contrast (WCAG G174); it never recedes under more contrast or in forced colours. Contrast tests prove it; add a
the control above it opens the whole record at full contrast (WCAG G174); its window's top edge fades only the tail row it cuts, from the second step; it never recedes under more contrast or in forced colours. Contrast tests prove it; add a
pair to them when you add a token.
- **Borders build structure; shadows are only for things that float.** No gradient
borders, glow or bounce, and no press scale beyond Button and IconButton's .98. Hover
Expand Down
12 changes: 8 additions & 4 deletions docs/foundations.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ of Basalt's accent classes, in its named roles, and nowhere else.
full ink and in full, and says when the tail holds a failure. Five things hold it: a step that is running, waiting or retrying
never recedes; a failure was said when it happened and stood in full while it was among the newest; everything a tail row says
stays in the accessibility tree; under more contrast and in forced colours nothing recedes; and no other text in Basalt uses these
tokens. A test holds each to it.
tokens. The window's top edge fades the one tail row it cuts, from transparent at the edge to opaque at that row's bottom, only when the row is at the
second step or deeper and the edge crosses its words; it never fades a whole row, a row holding focus, or a step that runs, waits or retries,
and under more contrast and in forced colours the edge is a plain cut. A test holds each to it.
- **The page is the darkest layer, in both themes.** Anything closer to you is lighter.
Light mode never puts a full white page in front of you.
- **Borders build structure; shadows exist only for things that float.**
Expand Down Expand Up @@ -2917,7 +2919,9 @@ Work that runs in stages and reports as it goes: a deploy pipeline, a CI job lis
rolls, and nothing after it does). A tail row is `text-xs` at 400, 20px, one line cut with an ellipsis, its mark still 16, no connector and
no detail, its ink its depth's step (see Principles); everything it says stays in the accessibility tree. The window is the list's
scrolling box, its floor the larger of `keep` and `minRows` rows plus two and a half tail rows, only growing; it draws no scrollbar and is a named tab stop while it
overflows. A roll moves the rows inside the window by transform over `duration-slow` on `ease-out`, the ink stepping on the same clock and
overflows. Its top edge fades the tail row it cuts over the part that shows (from the second step down, only when the edge crosses the row's words; any
other row is cut plainly, and every row while a step rolls in), a still mask on that row
alone, so it moves with the row and never reaches another row or the window's focus ring. A roll moves the rows inside the window by transform over `duration-slow` on `ease-out`, the ink stepping on the same clock and
the arrival fading over `duration-base`; past 48 counted rows it lands at once, as `Reflow` does. It follows new steps only while the reader
is at its end (read from its geometry), holds still while a control in it has focus or the pointer, and starts at its end. The toggle above
it ("Show 5 earlier steps", "Show 5 earlier steps, 1 failed"; open, "Hide earlier steps") holds its line from the first frame and opens the
Expand All @@ -2939,8 +2943,8 @@ Work that runs in stages and reports as it goes: a deploy pipeline, a CI job lis
detail and a roll land at once; an arriving step fades over 100ms; the badge's faces only fade; timers tick. The hold: the ring and braille
stand still, the queued mark is still at full, every change of state lands at once, and a stage's own running time hides (see "A page can
hold every loop"). A demonstration asks the hold when it would start and does not start under it; a run the reader starts runs whatever the
hold. More contrast: no tail, every stepped-back line at the first step and a failed one full `status-danger`. Forced colours: marks and
words are `currentColor`, nothing steps back, the queued mark is still and connectors are real borders. Print: as the hold, with the tail
hold. More contrast: no tail, every stepped-back line at the first step and a failed one full `status-danger`, and the window's top edge is a plain cut. Forced colours: marks and
words are `currentColor`, nothing steps back, the queued mark is still and connectors are real borders, and the top edge is a plain cut. Print: as the hold, with the tail
open.

## Loading in the page's own shape
Expand Down
43 changes: 36 additions & 7 deletions packages/react/src/run-timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ declare const process: { env: { NODE_ENV?: string } };
// row older (the one named exception to 4.5:1: the toggle above the tail opens the whole record in full ink). A step that is running, retrying or
// waiting never rolls, and nothing after it does. The window is the list's scrolling box: its floor holds `keep` rows and two and a half tail rows
// from the first frame and only grows; it follows new steps only while the reader is at its end, holds still while a control in it has focus or the
// pointer, and starts at its end. A roll moves the rows inside the window by transform; past REFLOW_BOUND counted rows it lands at once. Nothing
// here speaks: the run's `RunAnnouncer` does.
// pointer, and starts at its end. A roll moves the rows inside the window by transform; past REFLOW_BOUND counted rows it lands at once. Its top
// edge fades the tail row it cuts, from the second step (DECISIONS 337). Nothing here speaks: the run's `RunAnnouncer` does.

export interface RunStepProps {
/** The step's state; left out, the step is a finding (its own `mark`), and counts as finished. */
Expand Down Expand Up @@ -171,6 +171,7 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon
const rolling = React.useRef(0);
const atEnd = (el: HTMLElement) => el.scrollHeight - el.scrollTop - el.clientHeight <= 2;
const onScroll = () => {
edge();
const el = windowRef.current;
if (!el || rolling.current > 0) return;
if (lastSet.current !== null && Math.abs(el.scrollTop - lastSet.current) < 1) return;
Expand All @@ -184,13 +185,40 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

// ---- the top edge (DECISIONS 337): the one finished tail row at depth 2 or deeper that the window's top edge cuts through its words fades
// over the part that shows. Read from layout (offsetTop ignores a roll's transforms): the row, `data-cut` and `--_cut` (its visible height) are
// written on it and taken off the row that had them, or off every row. The stylesheet admits only such a row, outside a roll and outside more
// contrast, forced colours and print; everything else keeps the hard edge.
const marked = React.useRef<HTMLElement | undefined>(undefined);
const pad = React.useRef(0);
const edge = React.useCallback((focus: Element | null = document.activeElement) => {
const el = windowRef.current;
const list = listRef.current;
let next: HTMLElement | undefined;
let length = 0;
if (el && list && tailShown) {
// The row the edge is on: the first whose bottom is below it. It fades only when it is a tail row past the first step (data-depth 2 to 5),
// holds no focus, and the edge crosses its words, not only its padding: more than space-0-5 above the edge and more than space-0-5 below it.
pad.current ||= Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--basalt-space-0-5")) || 0;
const y = el.scrollTop;
next = ([...list.children] as HTMLElement[]).find((li) => li.offsetTop - list.offsetTop + li.offsetHeight > y);
const top = next ? next.offsetTop - list.offsetTop : 0;
length = top + (next?.offsetHeight ?? 0) - y;
if (!next || (next.dataset.depth ?? "1") === "1" || next.contains(focus) || y <= top + pad.current || length <= pad.current) next = undefined;
}
const was = marked.current;
if (was && was !== next) { was.removeAttribute("data-cut"); was.style.removeProperty("--_cut"); }
if (next) { next.setAttribute("data-cut", ""); next.style.setProperty("--_cut", `${length}px`); }
marked.current = next;
}, [tailShown]);

// ---- the floor that only grows: the newest `keep` full rows and two and a half tail rows, measured once a step is taller than a row
const grown = React.useRef(0);
const [overflows, setOverflows] = React.useState(false);
const measure = React.useCallback(() => {
const el = windowRef.current;
const list = listRef.current;
if (!el || !list || !tailShown) return;
if (!el || !list || !tailShown) { edge(); return; }
const full = [...list.children].filter((li) => !li.hasAttribute("data-tail")).slice(-(keep as number));
const rows = full.reduce((sum, li) => sum + (li as HTMLElement).offsetHeight, 0);
// The floor's own rows and a tail row from their tokens (a row: text-sm's line and space-2 twice, and a second line under 640px of the
Expand All @@ -206,7 +234,8 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon
if (want > grown.current) { grown.current = want; el.style.setProperty("--_grown", `${want}px`); }
setOverflows(el.scrollHeight > el.clientHeight + 1);
toEnd();
}, [tailShown, keep, toEnd, floorRows]);
edge();
}, [tailShown, keep, toEnd, floorRows, edge]);

// ---- the roll: where each row was drawn before this change, read before React writes the DOM
const shape = `${steps.length}:${rolled}:${open}`;
Expand Down Expand Up @@ -275,7 +304,7 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon
if (!flying.current.delete(animation)) return;
if (!roll) return;
rolling.current -= 1;
if (rolling.current === 0) { windowRef.current?.removeAttribute("data-rolling"); toEnd(); }
if (rolling.current === 0) { windowRef.current?.removeAttribute("data-rolling"); toEnd(); edge(); }
};
animation.addEventListener("finish", done);
animation.addEventListener("cancel", done);
Expand All @@ -301,8 +330,8 @@ export function RunTimeline({ label, keep: keepProp, minRows, timeScale = "secon
const holdFor = {
onPointerOver: (event: React.PointerEvent) => { const was = held(); hovered.current = controlOf(event.target); if (was && !held()) { toEnd(); release(); } },
onPointerLeave: () => { hovered.current = null; if (!held()) { toEnd(); release(); } },
onFocus: (event: React.FocusEvent) => { focused.current = controlOf(event.target); },
onBlur: (event: React.FocusEvent) => { focused.current = windowRef.current?.contains(event.relatedTarget as Node | null) ? controlOf(event.relatedTarget) : null; if (!held()) { toEnd(); release(); } },
onFocus: (event: React.FocusEvent) => { focused.current = controlOf(event.target); edge(event.target as Element); },
onBlur: (event: React.FocusEvent) => { focused.current = windowRef.current?.contains(event.relatedTarget as Node | null) ? controlOf(event.relatedTarget) : null; if (!held()) { toEnd(); release(); } edge(event.relatedTarget as Element | null); },
};

const items = steps.map((step, i) => (
Expand Down
9 changes: 9 additions & 0 deletions packages/react/src/styles/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -4660,6 +4660,15 @@
/* Hover and focus lift every tail row to the first step, over duration-fast: a convenience; the toggle is the way back that counts. */
.basalt-run-steps-window:is(:hover, :focus-within) .basalt-run-steps > .basalt-run-step[data-tail] > .basalt-run-step-line { opacity: 1; color: var(--basalt-text-tertiary); transition-duration: var(--basalt-duration-fast); }
.basalt-run-steps-window:is(:hover, :focus-within) .basalt-run-steps > .basalt-run-step[data-tail][data-state="failed"] :is(.basalt-run-step-mark, .basalt-run-step-word) { color: color-mix(in srgb, var(--basalt-status-danger) calc(var(--basalt-opacity-recede-danger) * 100%), transparent); }
/* The top edge (DECISIONS 337): the window's top edge fades the one tail row it cuts, over the part that shows (--_cut, measured), from
transparent at the edge to opaque at the row's bottom. The mask is in that row's own box, so it moves with the row and never reaches
another row or the window's focus ring. The selector is the guard: only a finished tail row at depth 2 to 5, with the tail closed and
no roll in flight, whatever the attribute says. A still mask, kept under reduced motion and the hold; under more contrast, in forced
colours and in print the edge is a plain cut. The black only supplies the opaque alpha; no colour paints. */
.basalt-run-steps-box:not([data-open]) .basalt-run-steps-window:not([data-rolling]) > .basalt-run-steps > .basalt-run-step[data-tail]:not([data-depth="1"])[data-cut] {
mask-image: linear-gradient(to top, var(--basalt-neutral-0), transparent var(--_cut));
mask-repeat: no-repeat;
}
}
/* Past REFLOW_BOUND counted rows, under reduced motion and under the hold, a roll lands at once: no colour transition either. */
.basalt-run-steps-window[data-landing] .basalt-run-step-line, :root[data-loops="held"] .basalt-run-step-line { transition: none; }
Expand Down
6 changes: 4 additions & 2 deletions packages/react/test/bundle.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,11 @@ for (const [name, limit, phosphor] of [["StageMark", 14_500, true], ["StageBadge
}

// RunTimeline carries its toggle (TextButton, and so Base UI's button and the press wait) and the shared stage parts; StageList does not carry it (above).
test("RunTimeline with RunStep loads Base UI's button and nothing else of Base UI (41,850 bytes at most)", async () => {
// Main raised the limit to 41,850 for the safe-sinks merge (measured 41,838, above). The top edge's fade (DECISIONS 337: the cut row, measured on each
// scroll, focus and landing) adds about 730 bytes: measured 42,569 on the merged tree, so the limit is 42,600.
test("RunTimeline with RunStep loads Base UI's button and nothing else of Base UI (42,600 bytes at most)", async () => {
const { bytes, inputs } = await graph("RunTimeline, RunStep");
assert.ok(bytes < 41_850, `RunTimeline bundle is ${bytes} bytes (limit 41,850)`);
assert.ok(bytes < 42_600, `RunTimeline bundle is ${bytes} bytes (limit 42,600)`);
assert.deepEqual(inputs.filter((f) => /cmdk|shiki/.test(f)), []);
assert.ok(!inputs.some((f) => /@base-ui\/react\/(esm\/)?(menu|dialog|select|popover|progress|meter|tooltip)\//.test(f)), "an unrelated Base UI part");
});
10 changes: 5 additions & 5 deletions packages/react/test/export-sizes.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
"RunAnnouncer": 448,
"RunStage": 21697,
"RunStep": 21494,
"RunTimeline": 21947,
"RunTimeline": 22676,
"RunTimer": 5645,
"RunsGlyph": 3128,
"STAGE_WORDS": 149,
Expand Down Expand Up @@ -427,11 +427,11 @@
"useWaitMark": 303
},
"package": {
"bytes": 945503,
"gzip": 314974
"bytes": 946282,
"gzip": 315272
},
"styles": {
"bytes": 460057,
"gzip": 59068
"bytes": 460324,
"gzip": 59128
}
}
Loading
Loading