Repository navigation
fix(Toast): the card's text takes its side's on-color, so the dark error toast reads at 4.5:1 - #13058
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 56a2afd |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Toast · Storybook | 107.0 kB (+145 B) · 11.5 kB CSS (+48 B) | 1,832 (+42) | ✓ · ✓ · ✓ |
Package size: @astryxdesign/core 7.85 MB packed (+715 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Requesting changes. The contrast fix works: with Core's default colors the dark error toast's text now reads at 4.70:1 (it was 3.61:1), the other three Core toast cards take their on-color, and every first-party theme renders identically. Two small fixes remain:
- The Lint workflow's comment-provenance baseline check fails on this branch because the comment at
Toast.tsx:130cites(FR14); drop the citation instead of adding it to the baseline. - The comment at
Toast.tsx:491-492and the description say a system-mode server render whose two sides differ keeps the ambient text until it is measured, but with Core's defaults (no Theme) the card's two sides are never computed, so the server markup forces the light-page side's on-color; say the guard covers themed pages only, or extend it to Core's defaults.
Optional: the first sentence of the comment at Toast.tsx:130 restates the styles below it, so keeping only the reason (a caller's text follows the restated token) would read better.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims
- With Core's defaults the dark error toast's text goes from 3.61:1 to 4.70:1: verified (Chromium probe of the rendered card on main and on this branch).
- The other three Core cards take their on-color (7.61:1, 18.78:1, 21:1): verified (same probe).
- Every first-party theme renders as before: verified (28 of 28 themed card frames are pixel-identical; the description's "25 of 25" undercounts the 28 pairs).
- Core's media baseline sets only the color scheme, while themes restate text to the on-color: verified (
reset.css,onMediaTokens.ts). - A card whose own text reads at least as well keeps it: verified (the side rule is unchanged; Neutral and Gothic error cards stay off).
- A system-mode server render whose two sides differ keeps the ambient text until measured: false for Core's defaults (second finding above).
- No token value, theme, public prop or theming target changes: verified (API surface comparison lists no rows; the diff adds none).
- The new unit test fails on main and passes here: verified.
- The Chromium spec now covers Core's defaults and the info toast: verified by reading; not run in this review.
- The node contrast check resolves Core's defaults, 32 cases: verified (32 pass).
- The Toast unit suite passes, 169 tests in 8 files: verified.
- Core tsc, eslint and prettier are clean: tsc and prettier verified; eslint reports one warning at
Toast.tsx:130(first finding above). - The pre-review report lists no findings: verified.
- Deepening Core's dark error surface would change six themes that inherit it: verified (only Gothic sets its own error surface).
- The overlapping pull request is a release interaction check, not a Toast change: verified.
- Changeset: dark-mode error toasts on Core's defaults go from 3.61:1 to 4.70:1, and themes that already draw their on-color look the same: verified.
Files
packages/core/src/Toast/Toast.tsx: both findings above, plus the optional comment suggestion.packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear (fails on main, passes here).packages/core/src/Toast/__tests__/ToastTextContrast.a11y.chromium.spec.ts: clear.scripts/check-toast-text-contrast.test.mjs: clear..changeset/toast-text-on-color.md: clear.
…ts too; drop the comment citation
|
/approve-spec 0411c1b |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet because the pull request is a draft, and marking it ready for review starts it.
With Core's default colors the dark error toast's text now reads at 4.70:1 (it was 3.61:1), the other three Core toast cards take their on-color, and the first-party themes render identically. Both earlier points are fixed: the comment no longer cites a record, and a system-mode server render whose two sides differ now keeps the base's text with Core's defaults too.
Claims and files checked
Review mode: incremental; reason: none
- Changed rules (0): none.
- Claim: with Core's default colors the dark error toast's text goes from 3.61:1 to 4.70:1. Verified: Chromium probe of the error story on the base and this head.
- Claim: the other three Core toast cards take their on-color. Verified: same probe (light error 7.61:1, light info 18.78:1, dark info 21:1).
- Claim: every first-party theme renders as before. Verified: Neutral, Chocolate, Gothic and Stone cards are pixel-identical on base and head, and the description's 25-pair table is unchanged.
- Claim: Core's media surface sets only its color scheme, while compiled themes restate text to the on-color. Verified:
MediaTheme.tsxstyles,onMediaTokens.ts:59and:73. - Claim: the contrast guards missed Core's defaults. Verified: the base versions of both guard files.
- Claim: the card restates the text token and color to the picked side's on-color, so a caller's text follows. Verified:
Toast.tsx:130-142,:538-543,Text/text.stylex.ts:28. - Claim: a card whose own text reads at least as well keeps it. Verified:
mediaSide.ts:77-81,Toast.tsx:516. - Claim: a system-mode server render whose two sides differ keeps the ambient text, Core's info card included, while Core's error card takes the on-color at once. Verified:
Toast.tsx:494-516and the two new server-render tests. - Claim: the Toast spec's text-side clauses govern and no record changes. Verified; the cited token-contrast clause covers status roles, so it is context only.
- Claim: no token value, theme, public prop or theming target changes. Verified: API surface comparison lists 0 rows.
- Claim: deepening Core's dark error surface would change six themes that inherit it. Verified: only
gothicTheme.ts:269sets that surface. - Claim: the new unit test fails on main and passes here. Verified: run on the base with this head's test.
- Claim: the Chromium spec now covers Core's defaults and the info toast. Verified by reading; it runs in CI's browser lane, which has not run on this draft.
- Claim: the node guard resolves Core's defaults in 32 cases. Verified: 32 pass.
- Claim: 170 Toast tests in 8 files pass, and tsc, eslint, prettier, the comment-provenance baseline and the pre-review report are clean. Verified at this head.
- Claim: the overlapping pull request is a release interaction check, not a Toast change. Verified.
- Changeset: dark-mode error toasts are easier to read, 3.61:1 to 4.70:1, with themes unchanged. Verified.
- File
.changeset/toast-text-on-color.md: clear. - File
packages/core/src/Toast/Toast.tsx: clear (one optional comment suggestion inline). - File
packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear. - File
packages/core/src/Toast/__tests__/ToastTextContrast.a11y.chromium.spec.ts: clear. - File
scripts/check-toast-text-contrast.test.mjs: clear.
|
/approve-spec 8be306c |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet because the pull request is a draft, and marking it ready for review starts it.
With Core's default colors every toast card's text now takes its side's on-color, so the dark error toast reads at 4.70:1 (it was 3.61:1), and the first-party themes render identically. The comment rewrite since the last review is clear, and nothing is left to change.
Claims and files checked
Review mode: incremental; reason: none
- Changed rules (0): none.
- Claim: with Core's default colors the dark error toast's text goes from 3.61:1 to 4.70:1. Verified: Chromium probe of the error story on the base and this head.
- Claim: the other three Core toast cards take their on-color. Verified: same probe (light error 5.85:1 to 7.61:1, light info 14.44:1 to 18.78:1, dark info 18.78:1 to 21:1).
- Claim: every first-party theme renders exactly as before. Verified: Neutral, Gothic and Chocolate error cards and Stone and Y2K info cards are pixel-identical on the base and this head; first-party themes already restate media-side text to the on-color.
- Claim: Core's media surface sets only its side's color scheme, so the card drew the scheme's text token rather than the on-color. Verified: the media baseline in
reset.css,MediaTheme.tsxandonMediaTokens.ts. - Claim: the existing guards missed Core's defaults. Verified: the base versions of both guard files.
- Claim: the card restates the text token and color to the picked side's on-color, so a caller's text follows. Verified:
Toast.tsx:130-142and:538-543, andTextreads the same token. - Claim: a card whose own text reads at least as well keeps it. Verified:
mediaSide.tsandToast.tsx:516. - Claim: a system-mode server render whose two sides differ keeps the ambient text, Core's info card included, while Core's error card takes the on-color at once. Verified:
Toast.tsx:494-516and the two new server-render tests. - Claim: the Toast spec's text-side clauses govern and no record changes. Verified; the cited token-contrast clause covers status roles, so it is context only.
- Claim: no token value, theme, public prop or theming target changes. Verified: the built API surface of Core and the seven themes lists 0 changes.
- Claim: deepening Core's dark error surface would change six themes that inherit it. Verified: only Gothic sets that surface.
- Claim: the new unit test fails on main and passes here. Verified: run on the base with this head's test.
- Claim: the Chromium spec now covers Core's defaults and the info toast. Verified: 32 of 32 pass at this head.
- Claim: the node guard resolves Core's defaults in 32 cases. Verified: 32 pass.
- Claim: 170 Toast tests in 8 files pass, and typecheck, lint, formatting, the comment-provenance baseline and the pre-review report are clean. Verified at this head.
- Claim: the overlapping pull request is a release interaction check, not a Toast change. Verified.
- Changeset: dark-mode error toasts are easier to read, 3.61:1 to 4.70:1, and themes that draw their on-color look the same. Verified.
- Title: the card's text takes its side's on-color and the dark error toast reaches 4.5:1. Verified (4.70:1).
- File
.changeset/toast-text-on-color.md: clear. - File
packages/core/src/Toast/Toast.tsx: clear. - File
packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear. - File
packages/core/src/Toast/__tests__/ToastTextContrast.a11y.chromium.spec.ts: clear. - File
scripts/check-toast-text-contrast.test.mjs: clear.
There was a problem hiding this comment.
Changes requested for one description edit; the code itself needs no change. With Core's default colors every toast card's text now takes its side's on-color, so the dark error toast reads at 4.70:1 (it was 3.61:1), themed cards are unchanged, and every CI check at this head is green.
- Miss: the description's "Why it harms the task" says an error toast "leaves on its own", but an error toast stays until it is dismissed by default (
ToastViewport.tsx:326,component:ToastFR2), so please reword that sentence, for example "it stays on screen until the reader dismisses it".
Editing the description needs no new commit.
Claims and files checked
Review mode: same-head; reason: none
- Changed rules (0): none.
- Claim: Title: the card's text takes its side's on-color and the dark error toast reaches 4.5:1. Verified: 4.70:1 (CI's Chromium contrast spec and the token values).
- Claim: Release note: with Core's default colors a toast's text uses its card's on-color, the dark error toast goes from 3.61:1 to 4.70:1, and themes that already draw their on-color look the same. Verified:
Toast.tsx:135-142and:538-543, the before and after frames, andonMediaTokens.ts:55-63. - Claim: With Core's default colors the dark-page error toast's text reads 3.61:1, under 4.5:1, and 4.70:1 after the change. Verified: frames and token values.
- Claim: The other three Core toast cards also take their on-color. Verified: light error 5.85:1 to 7.61:1, light info 14.44:1 to 18.78:1, dark info 18.78:1 to 21:1.
- Claim: Every first-party theme renders exactly as before. Verified: every theme already restates media-side text to the on-color (Gothic overrides only accent roles), and the Neutral dark error card is pixel-identical.
- Claim: Why the text is low: a Core media surface sets only its side's color scheme, so the card drew the scheme's text token, not the on-color. Verified for the dark page (
reset.css:403-409,tokens.stylex.ts:40,48); on a light page the card draws the side scheme's value, as the description's own table shows. - Claim: Every first-party theme sets its media-side text to its on-color, so only Core's defaults fall short. Verified:
onMediaTokens.ts:55-63,gothicTheme.ts:528-539. - Claim: Why it harms the task: an error toast leaves on its own. False: an error toast does not auto-hide by default (
ToastViewport.tsx:326, the Toast spec's auto-hide clause). - Claim: The existing guards missed it: the node guard checked only the themes and assumed the on-color, and the Chromium spec skipped Core's defaults. Verified: the base versions of both files.
- Claim: The card restates the text token and its color to the picked side's on-color, so a caller's
<Text>follows. Verified:Toast.tsx:135-142,:538-543,Text/text.stylex.ts:28. - Claim: A card whose own text reads at least as well keeps it. Verified:
pickInvertedSideinmediaSide.tsandToast.tsx:516. - Claim: A system-mode server render whose two sides differ keeps the ambient text until the card is measured; Core's info card keeps it and Core's error card takes the on-color at once. Verified:
Toast.tsx:494-516and the two new server-render tests. - Claim: The Toast spec's text-side clauses govern and no record changes; the token record holds status text pairs to contrast checks. Verified; the token clause covers status roles, so it is context only.
- Claim: No token value, theme, public prop or theming target changes. Verified: the source diff and CI's API change list for this head (0 rows).
- Claim: Deepening Core's dark error surface would change six themes that inherit it. Verified: only Gothic sets that surface.
- Claim: The measured before and after table for Core's four cards, with the themes unchanged. Verified: the numbers reproduce at this head.
- Claim: Result after the change: 4.70:1 and up on every card. Verified for the four Core cards the change affects.
- Claim: The new server-render test fails on main and passes here, and the second pins the unknown-side case. Verified: run on the base with this head's test, and at this head.
- Claim: The Chromium spec now covers Core's defaults and the info toast, and on main the Core dark error case reads 3.61:1. Verified: 32 of 32 pass in CI at this head; base frame receipt.
- Claim: The node guard resolves Core's defaults in 32 cases. Verified: 32 pass.
- Claim: 170 Toast tests in 8 files pass. Verified at this head.
- Claim: Typecheck, lint, formatting and the comment-provenance baseline are clean, and the pre-review report lists no findings. Verified: CI's typecheck and Lint workflow pass at this head; the pre-review report from CodeBunny's earlier run at this head.
- Claim: The Chromium spec runs in CI's browser lane. Verified: it ran there at this head.
- Claim: Scope: one defect restored, no tagalongs, no new public API, no internal context in public text. Verified.
- Claim: The overlapping pull request is a do-not-merge release interaction check, not a Toast change. Verified.
- File
.changeset/toast-text-on-color.md: clear. - File
packages/core/src/Toast/Toast.tsx: clear. - File
packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear. - File
packages/core/src/Toast/__tests__/ToastTextContrast.a11y.chromium.spec.ts: clear. - File
scripts/check-toast-text-contrast.test.mjs: clear.
There was a problem hiding this comment.
Approved. With Core's default colors every toast card's text now takes its side's on-color, so the dark error toast reads at 4.70:1 (it was 3.61:1), themed cards render exactly as before, and CI at this head has finished with no failures. The description sentence the last review flagged now matches the error toast's default persistence, so nothing is left to change.
Claims and files checked
Review mode: same-head; reason: none
- Changed rules (0): none.
- Claim: Title: the card's text takes its side's on-color and the dark error toast reaches 4.5:1. Verified: 4.70:1 in Chromium at this head and in the contrast spec in CI.
- Claim: Release note: with Core's default colors a toast's text uses its card's on-color, the dark error toast goes from 3.61:1 to 4.70:1, and themes that already draw their on-color look the same. Verified:
Toast.tsx:135-142and:538-543, before and after Chromium measurements, and unchanged Neutral and Gothic frames. - Claim: With Core's default colors the dark-page error toast's text reads 3.61:1 before and 4.70:1 after. Verified: Chromium measurements on base and head.
- Claim: The other three Core toast cards also take their on-color. Verified: light error 5.85:1 to 7.61:1, light info 14.44:1 to 18.78:1, dark info 18.78:1 to 21:1.
- Claim: Every first-party theme renders exactly as before. Verified: each theme already restates media-side text to the on-color (
onMediaTokens.ts:55-63; Gothic overrides only accent roles,gothicTheme.ts:528-539), and the Neutral and Gothic dark error cards are pixel-identical. - Claim: Why the text is low: a Core media surface sets only its side's color scheme, so the card drew the scheme's text token rather than the on-color. Verified for the dark page it describes (
reset.css:398-409,MediaTheme.tsx:51-53,tokens.stylex.ts:40,48). - Claim: Every first-party theme sets its media-side text to its on-color, so only Core's defaults fall short. Verified:
onMediaTokens.ts:55-63. - Claim: Why it harms the task: an error toast is the only cue that an action failed and stays on screen until dismissed. Verified:
ToastViewport.tsx:326and the Toast spec's auto-hide clause. - Claim: The existing guards missed it: the node guard checked only the themes and assumed the on-color, and the Chromium spec skipped Core's defaults. Verified: the base versions of both files.
- Claim: The card restates the text token and its color to the picked side's on-color, so a caller's
<Text>follows. Verified:Toast.tsx:135-142,:538-543,Text/text.stylex.ts:27-29. - Claim: A card whose own text reads at least as well keeps it. Verified:
pickInvertedSideinhooks/mediaSide.tsandToast.tsx:516. - Claim: A system-mode server render whose two sides differ keeps the ambient text until the card is measured; Core's info card keeps it and Core's error card takes the on-color at once. Verified:
Toast.tsx:491-516,tokens.stylex.ts:60-61, and the two new server-render tests. - Claim: The Toast spec's text-side clauses govern and no record changes; the token record holds status text pairs to contrast checks. Verified; the token clause covers status roles, so it is context only.
- Claim: One Toast change; no token value, theme, public prop or theming target changes. Verified: the source diff and CI's API change list for this head (no rows).
- Claim: Deepening Core's dark error surface would change six themes that inherit it. Verified: only Gothic sets that surface.
- Claim: The measured before and after table for Core's four cards. Verified: every number reproduces in Chromium at this head.
- Claim: The themes are unchanged across their info and error cards. Verified by mechanism and by the Neutral and Gothic frames; the stated pair count is the author's own tally.
- Claim: Result after the change: 4.70:1 and up on every card. Verified: the four Core cards, and every themed card at 4.5:1 or more in CI.
- Claim: The new dark error server-render test fails on main and passes here, and the second pins the unknown-side case. Verified: run on the base with this head's test (1 failed, 8 passed), and at this head.
- Claim: The Chromium spec now covers Core's defaults and the info toast, and on main the Core dark error case reads 3.61:1. Verified: 32 of 32 pass in CI at this head; 3.61:1 measured on the base.
- Claim: The node guard resolves Core's defaults in 32 cases. Verified: 32 pass in CI's node tests.
- Claim: 170 Toast tests in 8 files pass. Verified at this head.
- Claim: Typecheck, lint, formatting and the comment-provenance baseline are clean, and the pre-review report lists no findings. Verified: CI's typecheck and Lint workflow pass at this head; the pre-review report lists 0 findings.
- Claim: The Chromium spec runs in CI's browser lane. Verified: it ran there at this head.
- Claim: Scope: one defect restored, no tagalongs, no new public API, no internal context in public text. Verified.
- Claim: The overlapping pull request is a do-not-merge release interaction check, not a Toast change. Verified.
- File
.changeset/toast-text-on-color.md: clear. - File
packages/core/src/Toast/Toast.tsx: clear. - File
packages/core/src/Toast/Toast.mediaFallback.test.tsx: clear. - File
packages/core/src/Toast/__tests__/ToastTextContrast.a11y.chromium.spec.ts: clear. - File
scripts/check-toast-text-contrast.test.mjs: clear.
User impact
With Core's default colors (no theme), an error toast on a dark page draws its text at 3.61:1 on its red card, below the 4.5:1 WCAG 2.2 AA needs for normal text (SC 1.4.3). A reader with low vision can miss the error. After this change it reads at 4.70:1. The other three Core toast cards also take their on-color, and every first-party theme renders exactly as before.
Problem and solution fit
--color-text-primary(#DFE2E5in dark), not the side's on-color (--color-on-dark,#FFFFFF). Every first-party theme sets its media sides' text to its on-color, so only Core's defaults fall short.check-toast-text-contrastassumed the card draws its on-color and checked only the first-party themes; the Chromium spec skipped Core's defaults.The card now restates
--color-text-primary(and its text color) to the on-color of the sidepickInvertedSidepicks, inside its media surface, so a caller's<Text>follows it too. A card whose ambient text reads at least as well keeps it (sideoff). Before the measurement, a system-mode server render whose two sides differ (its reader's scheme is unknown) keeps the ambient text until the card is measured, as before. Its two sides come from the theme, or from Core's defaults when there is no theme (Core's info surface is dark in light mode and light in dark mode, so its server render keeps the ambient text; Core's error surface is dark in both, so it takes the on-color at once).Expected behavior and authority
component:ToastFR14: once measured, the card's text takes the on-color side (--color-on-darkor--color-on-light) that reads best, and keeps the page's own text only when that reads at least as well as both; FR13 picks by the same rule.architecture:theme-tokensINV11 holds status text pairs to their contrast checks. No record changes.Smallest restoration
One Toast change: an inner
display: contentswrapper inside the card'sMediaThemerestates--color-text-primaryandcolorto the picked side's on-color token. No token value, theme, public prop or theming target changes. Rejected: deepening Core's dark--color-background-error-inverted, which would change the dark error toast in six themes that inherit it.Evidence
Real Google Chrome 157 (headless, DPR 2), Storybook
core-toast--typesbuilt atmainand at this head; text color on the card's computed fill:main#DFE2E5on#E3193B, 3.61:1#FFFFFF, 4.70:1#DFE2E5on#AA071E, 5.85:1#FFFFFF, 7.61:1#DFE2E5on#0A1317, 14.44:1#FFFFFF, 18.78:1#0A1317on#FFFFFF, 18.78:1#000000, 21:1Toast.mediaFallback.test.tsx"gives a dark error card the dark side's on-color text" fails onmainand passes here; "keeps the ambient text on a server render whose two sides differ" pins the unknown-side case with Core's defaults.ToastTextContrast.a11y.chromium.spec.tsnow covers Core's defaults (none) and the info toast beside the error toast; onmainits Core dark error case reads 3.61:1.check-toast-text-contrast.test.mjsnow resolves Core's defaults too (32 cases).Before and after (real Chrome)
mainEvery theme's frames and the measured table: measures.tsv.
Scope
Components: Toast
Testing
vitest run --project ui packages/core/src/Toast: 170 tests pass (8 files).vitest run --project node scripts/check-toast-text-contrast.test.mjs: 32 pass.tsc, eslint, prettier and the comment-provenance baseline check are clean;pnpm review:prelists no findings.pnpm preflight --browser).Overlap checked: #12708 (a do-not-merge release interaction check, not a Toast change)