chore(typography): add VRT coverage - #6628
Conversation
|
📚 Branch Preview Links🔍 Gen1 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
8eb093a to
d86344d
Compare
rise-erpelding
left a comment
There was a problem hiding this comment.
Typography is always such a beast to document/test!
VRTs have a nice way of surfacing tiny bugs and missing pieces of documentation, in this case revealing that there's no custom properties table for us to pull information from. I think that's probably worth adding sooner rather than later.
I don't think we want to be in a pattern of always VRTing every possible permutation/combination of states/variants, but I think there are two that might be useful for typography:
- serif + heavy applied together since they seem to both touch font-weight
- serif + emphasized, mainly because we document it ("The following variants may use the emphasized modifier by adding
.swc-Typography--emphasizedalongside the base class. It may also be applied to the serif sub-variants.")
a260950 to
68eeb8b
Compare
miwha-adobe
left a comment
There was a problem hiding this comment.
Overall lgtm - Just thoughts on comments and it's verbosity. Could be worth asking Claude to be more concise, but not a blocker.
Adds the missing "CSS custom properties" table, then wires DOCUMENTED_TYPOGRAPHY_PROPERTIES into the VRT to verify against it, matching link's pattern.
Both classes touch font-weight; adds a case that checks --heavy still wins.
typography.mdx documents emphasized as applying to the serif sub-variants; checks italic survives the serif font-family/weight override.
68eeb8b to
5b6a9f0
Compare
Description
Adds
2nd-gen/packages/swc/components/typography/test/vrt/typography.vrt.tsandtypography-custom-properties.vrt.ts, providing dedicated Chromatic VRT coverage for thetypographyunit. Unlike other units covered so far,typographyis a "component replacement" stylesheet (typography.css): a pure CSS class vocabulary applied to plain HTML elements, with no custom-element counterpart and no custom-elements-manifest declaration (seeCONTRIBUTOR-DOCS/02_style-guide/01_css/07_stylesheets.md).Permutations: every Heading/Title/Body/Detail/Code size, the serif/emphasized/heavy/margins modifiers, the prose-container and link-list structural contexts, and Arabic/Hebrew font-family + CJK (ja/ko/zh) font-metric overrides. Rendered in both light/ltr and dark/rtl.ForcedColors: the same permutation set under forced-colors emulation.typography.csshas no@media (forced-colors: active)overrides of its own - confirmed this is correct, not a gap, since typography's differentiation is entirely size/weight-based rather than color-based, so the browser's automatic forced-colors flattening doesn't lose any meaningful distinction here.CustomProperties: one reference/override row per documented custom property (8 per variant x 5 variants = 40), grouped by variant. Since there's no manifest to verify against, this followslink-custom-properties.vrt.ts's manual-verification pattern: a hardcoded, alphabetically-sortedDOCUMENTED_TYPOGRAPHY_PROPERTIESlist that the covered-properties set must match exactly.typography.mdxhas no "CSS custom properties" reference table for this VRT to verify against (unlikelink.mdx, whichlink-custom-properties.vrt.tschecks against) - out of scope for this PR; flagged separately as follow-up.Motivation and context
The
typographyunit had no dedicated VRT coverage. This follows the VRT foundation established forbutton(PR #6463), extending it totypographyper the linked ticket, usinglink's existing "component replacement" VRT pattern as the closest precedent for a CSS-only, no-custom-element unit.Related issue(s)
Screenshots (if appropriate)
N/A - test-only change, no visual/behavioral change to typography.css itself. Manually verified via Playwright screenshots of the built Storybook, including real
forced-colorsmedia emulation. Caught and fixed one real gap during review: the CJK rows were originally only rendered in the light/ltr pass, not dark/rtl - fixed by folding them into the sharedpermutationContent()so both theme passes cover them.Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Permutations,ForcedColors, andCustomPropertiesstoriesDevice review
Accessibility testing checklist
Keyboard
These are non-interactive VRT snapshot fixtures (tagged
dev); no new keyboard behavior is introduced. The only interactive elements are the prose-container/link-list anchors, which use plain native<a>tab/Enter behavior. Confirm no regressions in the existingtypography.stories.tsdocs examples.Screen reader
h1-h4/p/ul/lielements to announce their native roles/levels correctly, and both links to announce as links with their visible text as the accessible name