Repository navigation
fix(Toast): a toast's card draws on the right side from the first paint - #12564
josephfarina wants to merge 9 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Owner decision (engineering owner, covering this pull request): a component whose surface depends on the page's color mode gets its dark-page surface rules written again under the existing dark-page conditions, keyed by a private attribute the component owns, so it draws the right side from the first paint even before script runs or without script. Toast is the first user: while the page's scheme is unknown it renders the light-page side and names the dark-page side in that attribute, and the compiler writes the extra rules only for themes whose surfaces flip. |
|
/approve-spec 59f30f5 |
|
AI review status for this pull request.
|
|
/approve-spec cbf4b4e |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Toast · Storybook | 105.8 kB (+274 B) · 11.1 kB CSS (0) | 1,754 (+15) | — · — · — |
| lab/CommentThread | 372.4 kB (+138 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 379.5 kB (+126 B) · 2.5 kB CSS (0) | — | — · — · — |
6 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/DialogHeroHeader | 90.5 kB (+120 B) · 372 B CSS (0) | — | — · — · — |
| Lightbox | 149.7 kB (+113 B) · 12.0 kB CSS (0) | — | — · — · — |
| Overlay | 23.6 kB (+113 B) · 3.9 kB CSS (0) | — | — · — · — |
| charts/Chart | 242.0 kB (0) · 516 B CSS (0) | — | — · — · — |
| Markdown | 205.3 kB (0) · 22.1 kB CSS (0) | — | — · — · — |
| lab/ListInput | 95.3 kB (0) · 922 B CSS (0) | — | — · — · — |
Package size:
- @astryxdesign/core 7.69 MB packed (+8.2 kB); no new dependencies
- @astryxdesign/theme-butter 56.3 kB packed (+89 B); no new dependencies
- @astryxdesign/theme-chocolate 18.2 kB packed (+99 B); no new dependencies
4 more packages
- @astryxdesign/theme-matcha 29.6 kB packed (+100 B); no new dependencies
- @astryxdesign/theme-neutral 41.4 kB packed (+109 B); no new dependencies
- @astryxdesign/theme-stone 41.2 kB packed (+102 B); no new dependencies
- @astryxdesign/theme-y2k 45.4 kB packed (+103 B); no new dependencies
Wide change (shared styles: packages/core/src/theme/MediaDarkPage.tsx, packages/core/src/theme/MediaTheme.tsx, packages/core/src/theme/generateThemeRules.ts, and 2 more): add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Current run: CI concluded cancelled; parts of this report may be missing.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes requested. The first-paint fix works for the official themes: in a no-script render with a dark scheme, the butter and neutral info toasts now read 16:1 to 19:1, and light mode is unchanged. Two blocking issues remain.
- The dark-page copy ignores a theme's root
@light/@darkblocks, becausenearestSurfaceIs(generateThemeRules.ts:1596) reads onlydata-astryx-media, so inside a flipped card on a dark system page a Button with root mode blocks paints its dark block (close icon white on white, 1.00:1) until script measures the card; treatdata-astryx-media-dark-pageas the nearest surface of its side under the dark-page conditions and add a test for it. fromTokens(Toast.tsx:434-449) repeats the rule that the newinvertedSideInimplements and that Toast now also calls, so the two can drift; compute it withinvertedSideInor drop it.
Non-blocking: INV21's "Toast is the first user" is sequencing wording, ToastViewport.test.tsx:203 leaves toast unused, and the INV18 verification row and a colorModeBlocks test name still say a theme without blocks gets no extra CSS.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: before script ran, a dark-scheme reader saw the info toast's light text on its light card. Verified: a no-script render of main measures 1.05:1 (butter) and 1.00:1 (neutral).
- Claim: the toast renders its light-page side, names its dark-page side, and the theme draws that side on a dark page. Verified in
Toast.tsx:472-487,generateThemeRules.ts:1999-2015and the render. - Claim: themes whose toast surfaces keep one side write no extra CSS. Verified: gothic's built
theme.cssis unchanged, and a test covers it. - Claim: the card draws on the right side from the first paint (title, changeset). True for the official themes; false for a theme with root mode blocks on a control in the card (first blocking item).
- Claim: on the server, a system page's tokens resolve for light. Verified from the base fallback code.
- Claim: the compiler reuses the conditions that decide the page's mode for color-mode blocks. Verified:
generateThemeRules.ts:101-114mirrors:1528-1549. - Claim: the close icon read 1.00:1 to 1.70:1 on main and 4.08:1 to 16.87:1 now. Consistent: butter goes from 1.13:1 to 5.01:1; neutral reaches 18.88:1, above the stated top.
- Claim: light mode and the error toasts are unchanged. Verified: the light frames are pixel-identical and the error colors are equal.
- Claim: with script on, pages read as before. Verified from code: the wrapper drops its attribute once the card is measured.
- Claim: six themes add 972 bytes each and gothic adds 0. Verified by building both trees.
- Claim: a deterministic look check found nothing new. Not checked: that tool was not run here.
- Claim: the named regression tests exist and pass;
check:knowledge, 1983 theme and Toast tests and the Core typecheck pass. Verified. - Claim: no new public API. Verified: the API generator and CI's report both list 0 rows.
- Claim: the attribute is private with a plain-TS owner. Verified against the private-attribute rule.
- File
.changeset/core-toast-first-paint-side.md: clear. - File
docs/architecture/theme-compilation.md: non-blocking (sequencing wording; INV18 row). - File
packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear. - File
packages/core/src/Toast/Toast.tsx: blocking (duplicate side rule); non-blocking comments. - File
packages/core/src/Toast/ToastViewport.test.tsx: non-blocking (unused variable). - File
packages/core/src/privateAttributes/mediaDarkPage.ts: clear. - File
packages/core/src/theme/MediaDarkPage.tsx: clear. - File
packages/core/src/theme/colorModeBlocks.test.ts: non-blocking (test name). - File
packages/core/src/theme/generateThemeRules.test.ts: clear. - File
packages/core/src/theme/generateThemeRules.ts: blocking (root mode blocks); non-blocking comment. - File
packages/core/src/theme/invertedSurfaceSide.ts: clear. - File
packages/core/src/theme/statusRoleDerivation.ts: clear. - File
packages/core/src/theme/themeAdaptations.test.ts: clear.
| // A system-mode page's scheme is the reader's, which the server does not | ||
| // know. The card takes its light-page side, and the side it takes on a | ||
| // dark page rides beside it; the theme writes that side's rules for a dark | ||
| // page, so the first paint is right in both. | ||
| const theme = useThemeDefinition(); | ||
| // While a system-mode page renders on the server (or hydrates the server's | ||
| // markup), its scheme is the reader's and unknown; later renders know it. | ||
| const isHydrating = useIsHydrating(); |
There was a problem hiding this comment.
Non-blocking (comment style): both comments say that a system page's scheme is unknown, and the first one's second sentence runs about 37 words. Suggested: "The server does not know a system page's scheme. The card takes its light-page side and names its dark-page side. The theme draws that side on a dark page."
| // A surface that takes another side on a dark page (a toast's card, whose | ||
| // fill flips with the page) carries that side as a second attribute, so | ||
| // its first paint is right before any script measures it. Its rules come | ||
| // after both sides' own and only for a theme whose surfaces flip. |
There was a problem hiding this comment.
Non-blocking (comment style): one sentence of about 36 words. Suggested: "A flipping surface names its dark-page side in a second attribute. These rules draw that side on a dark page before script measures the surface."
| page root names dark, and the reader's preference while it names none. It | ||
| picks each side by the rule the painted surface is measured with, from the | ||
| theme's tokens for each mode, and writes these rules only for a theme whose | ||
| surfaces take different sides in the two page modes. Toast is the first |
There was a problem hiding this comment.
Non-blocking: "Toast is the first user" states sequencing, which records leave out. Suggest "Toast uses it: its card's fill is …".
|
/approve-spec 691db51 |
There was a problem hiding this comment.
Changes requested. Both blocking issues from the last review are fixed: a theme's root @light/@dark blocks now follow the flipped side (the close icon reads 18.88:1 in a no-script dark render), and Toast's pre-measurement side comes from invertedSideIn alone. One blocking issue remains.
- Miss: inside a flipped toast the other side's on-media overrides still match at the first paint (
generateThemeRules.ts:2039-2058), so a theme withonDark: {components: {button: {base: {backgroundColor: '#000000'}}}}draws the close icon black on its black button (1:1, where main drew it white on black at 21:1) until script measures the card; leave the other side's surface rules out inside the dark-page wrapper under the dark-page conditions as:1577-1585now does for root blocks, cover tokens that only one side sets, and add a test with anonDark-only component property.
The non-blocking notes from the last review still apply: the unused toast in ToastViewport.test.tsx:203, the comment wording noted inline, "Toast is the first user" in INV21, and the INV18 verification row and colorModeBlocks test name that still say a theme without blocks gets no extra CSS.
Claims and files checked
Review mode: incremental; reason: none
- Changed rules (0): none.
- Claim: before script ran, a dark-scheme reader saw the info toast's light text on its light card (about 1.1:1). Verified: a no-script render of main measures the close icon at 1.00:1 to 1.70:1 in the six flipping themes.
- Claim: on the server, a system page's tokens resolve for light. Verified from the base fallback code.
- Claim: while the scheme is unknown, the toast renders its light-page side and names its dark-page side. Verified in
Toast.tsx:446-470and:499, and by the server-markup test. - Claim: the compiler writes that side's surface rules under the conditions that make the page dark. Verified in
generateThemeRules.ts:101-114and:2042-2058. - Claim: a root
@light/@darkblock follows the flipped side at no added specificity. Verified ingenerateThemeRules.ts:1561-1596, its new test, and the render (18.88:1). - Claim: the toast's sides all come from one rule. Verified:
Toast.tsx:436and:451-458both callinvertedSideIn. - Claim: themes whose surfaces keep one side write nothing extra; six themes add 972 bytes and gothic adds 0. Verified by building both trees.
- Claim: the info and error toasts read from the first paint in light and dark in every official theme. Verified for all seven official themes.
- Claim: the close icon read 1.00:1 to 1.70:1 on main and 4.08:1 to 16.87:1 now. Consistent: main matches; the head measures 5.01:1 to 18.88:1.
- Claim: light mode and the error toasts are unchanged. Verified: the light frames are pixel-identical and the error colors are equal.
- Claim: with script on, pages read as before. Verified from code: the attribute drops once the card is measured.
- Claim: a theme with root mode blocks reads 16.48:1 with and without script. Consistent: the no-script render measures 18.88:1 with the light block.
- Claim: a deterministic look check found nothing new. Not checked: that tool was not run here.
- Claim: the named regression tests exist and pass, along with the knowledge check, the theme and Toast tests (1984) and the Core typecheck. Verified.
- Claim: no new public API, and the attribute is private with its own owner module. Verified: the API generator lists 0 rows, and lint reports no private-attribute error.
- Changeset: the card draws on the right side from the first paint, and themes that keep one side write no extra CSS. Verified for the card; a control inside it can still take the other side's overrides (the blocking item).
.changeset/core-toast-first-paint-side.md: clear.docs/architecture/theme-compilation.md: non-blocking (sequencing wording; INV18 verification row).packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear.packages/core/src/Toast/Toast.tsx: non-blocking (comment wording).packages/core/src/Toast/ToastViewport.test.tsx: non-blocking (unused variable).packages/core/src/privateAttributes/mediaDarkPage.ts: clear.packages/core/src/theme/MediaDarkPage.tsx: clear.packages/core/src/theme/colorModeBlocks.test.ts: non-blocking (test name).packages/core/src/theme/generateThemeRules.test.ts: clear; the blocking fix needs one more case here.packages/core/src/theme/generateThemeRules.ts: blocking (one-sided on-media overrides in a flipped card); non-blocking comment wording.packages/core/src/theme/invertedSurfaceSide.ts: clear.packages/core/src/theme/statusRoleDerivation.ts: clear.packages/core/src/theme/themeAdaptations.test.ts: clear.
|
/approve-spec 862295e |
There was a problem hiding this comment.
Changes requested. The last review's blocking issue is fixed: an onDark-only Button fill no longer reaches the flipped toast at the first paint, and every official theme's info toast reads from the first paint in dark mode. Two blocking issues remain, and one measurement is missing.
packages/core/src/theme/MediaDarkPage.tsxnow importsusefrom React but has no'use client'directive, soscripts/check-use-client.mjsfails the required lint check; add the directive after the copyright line.- The dark-page copy's
revert-layerfallback (generateThemeRules.ts:1998-2002) also drops the theme root's rules for that property under other style keys and in color-mode blocks, so a theme with rootbutton: {'variant:ghost': {backgroundColor: '#1f2937', color: '#ffffff'}}andonDark: {components: {button: {base: {color: '#ffffff'}}}}draws the info toast's close icon#000000on its#1f2937chip (1.43:1) at the first paint and#ffffff(14.68:1) after script; leave the other side's surface rules out of the dark-page surface under the dark-page conditions, as the root color-mode blocks already do, update INV21's sentence to match, and add a test with a root'variant:ghost'property and anonDarkbaseone. - Please also report the first-load gzip delta of the grown
MediaTheme.tsx(INV10) on a page that imports Lightbox or OverlayScrim, base against head, since none of the four reference pages reaches it.
The earlier non-blocking notes on comment wording and "Toast is the first user" still apply, and one new comment note is inline. CI's test and build jobs were cancelled for capacity at this head, so they still need to run.
Claims and files checked
Review mode: full; reason: spec-record
- Claim: before script ran, a dark-scheme reader saw the info toast's light text on its light card (about 1.1:1). Verified: a no-script render of the base measures the info text at 1.00:1 to 1.70:1 in the six flipping themes.
- Claim: on the server a system page's tokens resolve for light. Verified from the base fallback code.
- Claim: while the scheme is unknown, the card renders its light-page side and names its dark-page side in a private attribute. Verified in
Toast.tsx:463-469,MediaTheme.tsx:102-120and the server-markup test. - Claim: the compiler writes that side's surface rules under the conditions that make the page dark. Verified in
generateThemeRules.ts:101-114and:2141-2160. - Claim: diagnostics are reported once. Verified: the copies use a silent sink (
generateThemeRules.ts:2054-2056). - Claim: a root light or dark block follows the same side at no added specificity. Verified in
generateThemeRules.ts:1561-1596, its test and the render (18.88:1). - Claim: the copy undoes what only the light-page side's overrides set, a token by inheriting and a component property by the root's value for the same style key, else the base style. Verified as written (
generateThemeRules.ts:1965-2003,:2083-2118); its effect on root rules under other keys is the second blocking item. - Claim: the toast's sides all come from one rule. Verified:
Toast.tsx:436and:452-459callinvertedSideIn. - Claim: themes whose surfaces keep one side write nothing extra; six themes add 972 bytes and gothic adds 0. Verified by building both trees.
- Claim: the info and error toasts read from the first paint in light and dark in every official theme. Verified for all seven official themes.
- Claim: the dark info close icon read 1.00:1 to 1.70:1 on main and 4.08:1 to 16.87:1 now. Consistent: main matches; the head measures 5.01:1 to 18.88:1.
- Claim: light mode and the error toasts are unchanged. Verified: their computed colors are equal on base and head.
- Claim: with script on, pages read as before. Verified from code: the attribute drops once the card is measured.
- Claim: a theme with root Button mode blocks and a dark-surface-only button fill shows no fill and a readable icon without script. Consistent: each case, rendered separately, reads 18.88:1 and 21:1.
- Claim: a deterministic look check found nothing new. Not checked: that tool was not run here.
- Claim: the named regression tests, the knowledge check, the theme and Toast tests and the Core typecheck pass. Verified (2006 tests across the theme and Toast suites).
- Claim: no new public API, and the attribute is private with its own owner module. Verified: the API generator lists 0 rows, and lint reports no private-attribute error.
- Changeset: the card draws on the right side from the first paint, and themes that keep one side write no extra CSS. Verified for the card in the official themes; a control inside it can still draw the other way for some themes (the second blocking item).
.changeset/core-toast-first-paint-side.md: clear.docs/architecture/theme-compilation.md: non-blocking (sequencing wording); INV21's undo sentence changes with the second blocking fix.packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear.packages/core/src/Toast/Toast.tsx: non-blocking (comment wording, carried).packages/core/src/Toast/ToastViewport.test.tsx: clear.packages/core/src/privateAttributes/mediaDarkPage.ts: clear.packages/core/src/theme/MediaDarkPage.tsx: blocking (missing directive).packages/core/src/theme/MediaTheme.tsx: evidence gap (first-load delta).packages/core/src/theme/colorModeBlocks.test.ts: clear.packages/core/src/theme/generateThemeRules.test.ts: clear; the blocking fix needs one more case here.packages/core/src/theme/generateThemeRules.ts: blocking (revert-layer undo); non-blocking comment wording.packages/core/src/theme/invertedSurfaceSide.ts: clear.packages/core/src/theme/statusRoleDerivation.ts: clear.packages/core/src/theme/themeAdaptations.test.ts: clear.
|
/approve-spec c20e079 |
|
/approve-spec 941bea4 |
There was a problem hiding this comment.
Approved. The two first-paint gaps from the last review are fixed: a dark surface nested in a flipped toast keeps its own color-mode block (21:1 before script, as on main), and a theme's adaptation @light/@dark blocks now follow the flipped card (close icon 18.88:1 before script). Both new colorModeBlocks.test.ts cases fail on the previous head and pass here, and CI passes.
Non-blocking: darkPageNearestIs's JSDoc sits between nearestSurfaceIs's JSDoc and its function (generateThemeRules.ts:1645-1678), so nearestSurfaceIs loses its documentation; the earlier comment-style notes and the record's "first user" wording still stand.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
- Release note: a toast's card draws on the right side from the first paint of a system-mode page; before script a dark-scheme reader saw about 1.1:1; themes whose surfaces keep one side write no extra CSS: verified (no-script dark render 1.00–1.70:1 on the base, 5.75–18.88:1 now; gothic's theme.css unchanged).
- The record gains the first-paint invariant with its verification row, the no-mode-rules sentence points to it, and the private attribute has a named owner module: verified (theme-compilation.md:281-282, :301-322, :436).
- Before script, a dark-scheme reader saw the info toast's light card with light text and icon, and a script-free page kept it: verified (base no-script dark render, every flipping theme).
- Info and error toasts now read from the first paint in light and dark in every official theme: verified (dark info 5.75–18.88:1, error 4.59–4.97:1, light frames identical to the base).
- Cause: before measuring, Toast took its side from tokens the server resolves for light: verified (base markup names the dark side on every flipping info card).
- Each page mode's side comes from the measurement's own rule: verified (invertedSideIn wraps pickInvertedSide; Toast.tsx:436-462).
- While the scheme is unknown, a card whose side differs renders its light-page side and names its dark-page side: verified (Toast.tsx:446-469; server-markup test).
- The dark-page rules apply under a dark root, a system root whose page root names dark, and the reader's preference while it names none: verified (generateThemeRules.ts:114-128; built theme.css).
- A theme whose surfaces keep one side writes nothing extra: verified (gothic theme.css byte-identical; compiler test).
- After hydration the measurement decides as before: verified (the dark-page side is set only while hydrating).
- The compiler repeats the on-media token, component and status-role rules and reports diagnostics once: verified (generateThemeRules.ts:2022-2026, :2160-2165).
- A root light/dark block follows the flipped side at no added specificity, and the other block's nearest-surface rule leaves the surface out: verified, nested surfaces included (nested dark surface 21:1 at the first paint; selectors in where()).
- Nested surfaces take their own side and the nested provider always renders: verified (MediaTheme.tsx:117).
- The setup evaluator reads a media surface's own color-scheme as its side: verified (setup-integrity tests pass, including the not() case).
- Toast's sides all come from one rule: verified (every side goes through invertedSideIn).
- Where a dark page flips the surface, the light-page side's rules leave it out, and official themes keep their media rules: verified (theme.css diffs are additions only).
- The dark info close icon goes from 1.00–1.70:1 to 4.08–16.87:1, light and error unchanged: consistent (computed colours give 1.00–1.70:1 and 5.01–18.88:1; light and error unchanged).
- With script on the pages read as before: verified (the after-script rows match the base's).
- A theme with root mode blocks and an onDark button fill shows an unfilled close button that reads well without script: consistent (the mode-blocks and onDark-fill probes read 18.88:1 and 21:1 before and after script).
- A root ghost chip keeps its white icon without script: verified (14.68:1 both ways).
- Lightbox and Overlay pages grow by 139 B and 114 B: consistent (the repository's reference-page measure gives +153 B and +107 B gzip; the four reference pages +0).
- Six flipping themes each add 1,004 bytes to theme.css and gothic adds 0: verified.
- The look gate found nothing new on toast pages: not checkable (no such tool in the repository); this review's renders cover those pages.
- A ghost Button's root hover fill shows with and without script alike: verified from the selector weight (the dark-page conditions sit in where()).
- The named regression tests, the Core theme and Toast folders, the CLI and setup tests and the typecheck pass: verified (1,994 tests in those folders at this head; the two new nested-surface and adaptation tests fail on the previous head).
- The setup-canonical browser run passes: not repeated here; the setup-integrity unit tests cover the evaluator change.
- No new public API, visual representation, default or interaction model; no internal context in public text: verified (API generator and CI: 0 rows; text scan clean).
- The knowledge check passes: verified.
.changeset/core-toast-first-paint-side.md: clear.docs/architecture/theme-compilation.md: non-blocking ("first user" wording).internal/vibe-tests/setup-test/setup-integrity.mjs,setup-integrity.test.mjs: clear.packages/cli/clients/cli/commands/build-theme.adaptations.test.mjs,build-theme.color-mode-blocks.test.mjs: clear.packages/core/src/Toast/Toast.tsx: non-blocking comment style.packages/core/src/Toast/Toast.mediaFallback.test.tsx,ToastViewport.test.tsx: clear.packages/core/src/privateAttributes/mediaDarkPage.ts,theme/MediaDarkPage.tsx,theme/MediaTheme.tsx,theme/invertedSurfaceSide.ts,theme/statusRoleDerivation.ts: clear.packages/core/src/theme/generateThemeRules.ts: non-blocking (a JSDoc out of place; comment style).packages/core/src/theme/generateThemeRules.test.ts,colorModeBlocks.test.ts,dynamicType.test.ts,onMediaTokens.test.ts,themeAdaptations.test.ts: clear.- Pull request description: no false claim.
| /** | ||
| * Selectors for elements whose nearest surface draws `side`, where `outer` | ||
| * is a surface that draws `side` (a flipped surface on a dark page): inside | ||
| * it and no nearer surface of the other side, or inside a nested surface of | ||
| * `side` that follows one of the other side, down to the same depth as | ||
| * nearestSurfaceIs. | ||
| */ | ||
| function darkPageNearestIs(outer: string, side: MediaSide): string[] { |
There was a problem hiding this comment.
Non-blocking: this JSDoc and its function sit between nearestSurfaceIs's JSDoc (lines 1645-1656) and nearestSurfaceIs, so nearestSurfaceIs loses its documentation and the earlier block now reads as part of this helper. Move darkPageNearestIs with its comment above line 1645, or below nearestSurfaceIs.
On a system-mode page the server does not know the reader's scheme, so a Toast took the side its light-page tokens pick, and a dark-mode reader saw the info toast unreadable until script ran. The Toast now computes its side for both page modes from the theme. While the scheme is unknown it renders the light-page side and names the dark-page side in a private attribute. The theme compiler writes that side's surface rules again under the conditions that make the page dark, only for themes whose inverted surfaces flip (architecture:theme-compilation INV21).
…st as its first user
…ge side; Toast reads its side once Inside a surface that takes another side on a dark page, the root color-mode block of that side applies there and the other side's nearest-surface rule leaves it out, under the same dark-page conditions, so a Button with root mode blocks draws the right block before script names the side. The Toast's pre-measurement side comes from invertedSideIn alone.
The dark-page side is now named on the MediaTheme element itself, beside its light-page side. Its copy of the surface rules also undoes what only the light-page side's on-media overrides set: a token inherits again (revert-layer), and a component property takes the theme root's value for the same style key, else the base style. A light-page onDark button fill no longer reaches the close button on a dark page's first paint. INV21 says so; the INV18 row and colorModeBlocks test name allow INV21's rules.
…ad of reverting them On a dark page, a surface that names its light-page side and takes the other side gets none of the light-page side's rules (when the copy does not write each of them again), so the theme root's rules for every style key and mode apply as they would without them. This replaces the revert-layer undo, which also dropped the root's rules under other keys. MediaDarkPage is a client module. Tests about other rules use a theme whose surfaces keep their side.
…children's place MediaTheme always renders the nested MediaDarkPage provider, so a server-rendered toast's content keeps its place in the tree after hydration and focus stays on its close button. The dark-page copy's page conditions sit in :where(), as a root color-mode block's do, so a root state rule (a ghost Button's hover fill) wins there as it does once script names the side. The setup evaluator reads an Astryx media surface's own color-scheme as that surface's side, not as disabling dark mode; the CLI build tests allow a flipped surface's dark-page rules.
…es; width check matches the compiler setup-integrity exempts a color-scheme arm only when the surface's side attribute is on the compound itself, not inside a functional pseudo-class (body:not([data-astryx-media=light]) forces light on everything else and stays a finding). themeAdaptations.test.ts checks for the @media (width ...) form the compiler writes.
…k; adaptations follow the flipped side The dark-page mode-block rules match content on the nearest-surface chain with the flipped surface as its outermost link, so a dark surface nested in a flipped toast keeps the dark block at the first paint. An adaptation's color-mode blocks get the theme's dark-page sides as the root blocks do.
941bea4 to
6cf3d5c
Compare
|
/approve-spec 6cf3d5c |
There was a problem hiding this comment.
Approved pending CI: CI is still running on this head.
A toast's first paint is now right on a system-mode page: with no script, a dark-scheme reader sees each flipping theme's info card at 5.75–18.88:1 instead of 1.00–1.70:1, the light scheme and the error toasts are unchanged, and after the rebase main's new toast-close target follows the flipped card too. No public API changes.
Non-blocking: the earlier comment-style notes, the displaced nearestSurfaceIs JSDoc (generateThemeRules.ts:1346-1379), the record's "Toast is the first user" wording and a curly lint warning in generateThemeRules.test.ts:2365 still stand.
Claims and files checked
Review mode: full; reason: rebase
- Release note: a toast's card draws on the right side from the first paint of a system-mode page, where a dark-mode reader saw about 1.1:1 before script; the toast renders its light-page side and names its dark-page side; themes whose toast surfaces keep one side write no extra CSS: verified (no-script dark render 1.00–1.70:1 on the base, 5.75–18.88:1 now; gothic's
theme.cssbyte-identical). - The theme-compilation record gains the first-paint invariant keyed by a private attribute, names Toast and the attribute's owner module, and its no-mode-rules sentence points to it: verified (
theme-compilation.md:20-21,:282-283,:302-323,:434,:437). - Before script, a dark-scheme reader saw the info toast's light card with light text and icon, and a page with no script kept it: verified (base no-script render, six flipping themes).
- Info and error toasts read from the first paint in light and dark in every official theme: verified (dark info 5.75–18.88:1, error text 4.59–4.97:1; light frames pixel-identical to the base).
- Cause: before measuring, Toast took its side from tokens the server resolves for light: verified (base token pick; base server markup names the dark side on every flipping info card).
- Toast computes each page mode's side by the measurement's rule: verified (
invertedSideInwrapspickInvertedSide;Toast.tsx:452-466). - While the scheme is unknown, a card whose side differs renders its light-page side and names its dark-page side: verified (
Toast.tsx:451-474,:503; server-markup test). - The dark-page rules apply under a dark root, a system root whose page root names dark, and the reader's preference when it names none: verified (
generateThemeRules.ts:124-137; builttheme.css). - A theme whose inverted surfaces keep one side writes nothing extra: verified (gothic unchanged; compiler test).
- After hydration the measurement decides as before: verified (the dark-page side is set only while hydrating).
- The existing record already makes color-mode blocks right at the first paint, and the attribute is private with a plain-TS owner written through an internal provider: verified (the owner is imported only from the theme folder, as the private-attribute invariant allows).
- A new module holds the side rule and the sides a dark page needs: verified (
invertedSurfaceSide.ts). - The compiler repeats the on-media token, component and status-role rules, reports diagnostics once, and root light/dark blocks follow the flipped side at no added specificity: verified (
generateThemeRules.ts:1723-1727,:1861-1866,:113-116). - MediaTheme names the dark-page side beside its own; nested surfaces take their own; the nested provider always renders: verified (
MediaTheme.tsx:104-117; nested dark surface 21:1 before script). - The setup evaluator reads a media surface's own color-scheme as its side, not as disabling dark mode: verified (
setup-integrity.mjs:523-541; unit tests, including the:not()case). - Toast's sides all come from one rule: verified.
- Where a dark page flips the surface, the light-page side's rules leave it out unless the copy writes them again, and official themes keep their media rules: verified (
generateThemeRules.ts:1788-1822; neutral and buttertheme.cssdiffs are additions only). - Dark info close icon 1.00–1.70:1 on main and 4.08–16.87:1 now, light and error unchanged: consistent (this review measures 1.00–1.70:1 and 5.01–18.88:1).
- With script on, the pages read as before: verified (after-script rows equal the base's).
- Root light/dark Button blocks with an onDark fill leave the close button unfilled and readable without script: consistent (the separate root-block and onDark-fill probes read 18.88:1 and 21:1 before and after script).
- A root ghost chip keeps its white icon without script: verified (14.68:1 both ways).
- Lightbox and Overlay pages grow 139 B and 114 B: consistent (the repository's reference-page measure gives +100 B and +104 B gzip; the four reference pages +0).
- Six themes add 1,004 bytes of
theme.css, gothic 0: verified. - The look gate found nothing new on toast pages: not checkable (no such tool in the repository); this review's renders cover those pages.
- A ghost Button's root hover fill shows with and without script alike: verified from selector weight (conditions in
:where()). - The named regression tests exist and pass: verified.
- One defect, no tag-alongs, no new public API, default or interaction model, no internal context: verified (API generator 0 rows; text scan clean).
- Writing rubric (present tense, one topic per sentence, no project status, owners named, INV23 linked): not fully; INV21 still says "Toast is the first user" (
theme-compilation.md:319), noted above as non-blocking. - The knowledge check passes: verified.
- The Core theme and Toast tests (1,985 stated), CLI theme-build tests, setup-integrity tests and typecheck pass: verified at this head (2,017 tests after the rebase); the setup-canonical browser run was not repeated (the unit tests cover the evaluator).
- Every official theme rendered with script off and on: verified by this review's own render.
.changeset/core-toast-first-paint-side.md: clear.docs/architecture/theme-compilation.md: non-blocking ("first user" wording).internal/vibe-tests/setup-test/setup-integrity.mjs,setup-integrity.test.mjs: clear.packages/cli/clients/cli/commands/build-theme.adaptations.test.mjs,build-theme.color-mode-blocks.test.mjs: clear.packages/core/src/Toast/Toast.tsx: non-blocking (comment style).packages/core/src/Toast/Toast.mediaFallback.test.tsx,ToastViewport.test.tsx: clear.packages/core/src/privateAttributes/mediaDarkPage.ts,theme/MediaDarkPage.tsx,theme/MediaTheme.tsx,theme/invertedSurfaceSide.ts,theme/statusRoleDerivation.ts: clear.packages/core/src/theme/generateThemeRules.ts: non-blocking (displaced JSDoc; comment style).packages/core/src/theme/generateThemeRules.test.ts: non-blocking (curlywarning).packages/core/src/theme/colorModeBlocks.test.ts,dynamicType.test.ts,onMediaTokens.test.ts,themeAdaptations.test.ts: clear.- Pull request description: no false claim about the code.
Open PRs meta#12378 and meta#12564 claim INV21, so this record takes INV22.
- #12784 fix(Breadcrumbs): the menu crumb's menu slides in from the crumb in published builds Author: Joey Farina <[email protected]> - #12327 chore(storybook): resolve StyleX merges the way the published CSS does Author: josephfarina <[email protected]> - #12564 fix(Toast): a toast's card draws on the right side from the first paint Author: Joey <[email protected]>
|
Landed in #12811. |
Record change:
architecture:theme-compilationgains INV21, under which a component whose media surface depends on the page's mode gets its dark-page surface rules written under the existing dark-page conditions, keyed by a private attribute it owns (architecture:public-component-apiINV23). Toast is its first user, with ownerprivateAttributes/mediaDarkPage.ts. INV18's "no mode rules" sentence points to it.User impact
On a system-mode page, the first paint of a toast could draw its card on the wrong side. A reader whose device is in dark mode saw the info toast's light card with light text and a light close icon (about 1.1:1) until script ran and measured the card. A page that runs no script (a static export, a reader who blocks scripts) kept it. With this change the info and error toasts read from the first paint in light and dark, in every official theme.
Problem and solution fit
The theme knows both page modes. The Toast now computes its side for each page mode from the theme's tokens, by the same rule the measurement uses. While the scheme is unknown (a server render, or the client render that hydrates it), a card whose side differs between the two modes renders its light-page side and names its dark-page side in a private attribute. The theme compiler writes that side's surface rules again for that attribute, under the conditions that already decide the page's mode for color-mode blocks: a dark root, a system root while the page root names dark, and the reader's preference while it names none. A theme whose inverted surfaces keep one side in both modes writes nothing extra. After hydration the Toast knows the scheme, and the measurement still decides as before.
Expected behavior and authority
architecture:theme-compilationINV18 already makes color-mode blocks right at the first paint of a server-rendered page. The new INV21 extends that to any component whose surface depends on the page's mode, with Toast as the first user. The attribute is private (architecture:public-component-apiINV23; plain-TS ownerprivateAttributes/mediaDarkPage.ts, written through the internaltheme/MediaDarkPage).Smallest restoration
theme/invertedSurfaceSide.ts: the side an inverted surface takes in a page mode, and the dark-page sides a theme needs.theme/generateThemeRules.ts: for those sides, the on-media token, component and status-role rules again, scoped to the dark-page attribute under the dark-page conditions (diagnostics reported once). A root@light/@darkblock follows the same side there: the flipped side's block applies inside the surface on a dark page, and the other block's nearest-surface rule leaves it out (at no added specificity).Toast/Toast.tsx,theme/MediaDarkPage.tsxandtheme/MediaTheme.tsx: while the scheme is unknown, Toast gives its MediaTheme the dark-page side, and MediaTheme names it beside its own side (nested surfaces take their own; the nested provider always renders, so the children keep their place after hydration).internal/vibe-tests/setup-test/setup-integrity.mjs: the setup evaluator reads an Astryx media surface's owncolor-scheme(the rule's every selector ends at the surface's side attribute, and the value is that side) as the surface's side, not as disabling the page's dark mode. The Toast's sides all come frominvertedSideIn, one rule.docs/architecture/theme-compilation.md: INV21 and its verification row.Evidence
@dark/@lightblocks and anonDarkbutton fill of#000000: with no script, in dark, the info toast's close button has no fill and its icon reads 16.48:1 on the light card, as with script.#1f2937chip and white text, and anonDarkbutton color: with no script, in dark, the close icon is white on its chip, as with script.theme.css; gothic adds 0 (its surfaces keep one side).:hoverfill shows on the toast's close button with no script and with script alike (the dark-page copy adds no specificity).Toast.mediaFallback.test.tsx(server markup under a flipping theme in system mode, the same theme forced dark, and a non-flipping theme) andgenerateThemeRules.test.ts("a media surface that flips with the page", including root color-mode blocks and leaving a light-page side's overrides out).Scope
Components: Toast, theme compiler
Writing rubric results
pnpm check:knowledgepasses.Testing
CI=1 pnpm vitest run packages/core/src/theme packages/core/src/Toast(1985 passed); the CLI theme-build tests;setup-integrity.test.mjs;setup-canonical.test.tswith the browser (33 passed; it reportsdark-mode-disabledwithout the evaluator change)tsc --noEmit -p packages/core/tsconfig.jsonastryx experimental render, then checked them with script off and on.