Repository navigation
refactor: shared theme CSS generation + remove XDSFontWrapper - #665
Merged
Merged
Conversation
cixzhang
marked this pull request as ready for review
March 18, 2026 02:20
XDSFontWrapper was just <div className='xds-typography'>{children}</div>.
Migration: remove the wrapper, render children directly. Use className
'xds-typography' on a parent div if prose styling is needed.
Co-authored-by: Navi <[email protected]>
Both runtime and build paths now use the same generateThemeRules() function from @xds/core to produce CSS rules. The only difference is how the output is wrapped: - Runtime: @scope only (no @layer), injected via useInsertionEffect - Build: @layer xds.theme { @scope { ... } }, written to theme.css generateThemeRules accepts { computedValues: boolean } — when true, prose rules use computed px values from tokens (self-contained CSS); when false, they use var() references (runtime with token :scope). Co-authored-by: Navi <[email protected]>
The build path now calls defineTheme() + generateThemeRules() from @xds/core/theme — the same functions the runtime uses. This ensures typeScale expansion, component override generation, prose rules, and prop-level color overrides are identical in both paths. Falls back to legacy generation if core isn't built yet. Co-authored-by: Navi <[email protected]>
…ecificity
Text now emits xdsClassName('text', {type, color}) and Heading emits
xdsClassName('heading', {level, color}). This enables themes to target
color variants via CSS (.xds-text.primary, .xds-heading.secondary)
for prop-level override specificity in @layer xds.theme.
Co-authored-by: Navi <[email protected]>
Removed the computedValues option from generateThemeRules — both paths now always use the computed values from tokens (which defineTheme populates via expandTypeScale). The only difference between runtime and build output is the wrapper: runtime uses bare @scope, build wraps in @layer xds.theme with color-scheme. Co-authored-by: Navi <[email protected]>
Font sizes from expandTypeScale now output rem values (e.g. 1.5rem instead of 24px) based on the standard 16px root. This respects user browser font size preferences for accessibility — rem scales with the root font size while px is fixed. The reset.css does not set a root font-size, following the convention of leaving it at the browser default (typically 16px) so user preferences work automatically. Co-authored-by: Navi <[email protected]>
Tests cover: - Token block structure (rem sizes, unitless line-heights, var() weights) - Component override rules (.xds-heading.level-*, .xds-text.*) - Prose HTML element rules (h1-h6, p, small, code, hr with computed values) - Prop-level color overrides (.xds-text.primary, .xds-heading.secondary) - Consistency: every rule from generateThemeRules appears in generateThemeCSS - Weight override propagation through tokens and prose Co-authored-by: Navi <[email protected]>
The Python script that removed FontWrapper component entries left orphaned closing brackets in both the English and Chinese doc objects. Co-authored-by: Navi <[email protected]>
cixzhang
force-pushed
the
navi/fix/theme-prose-typography
branch
from
March 18, 2026 02:39
b88829e to
cd0b233
Compare
- Remove typography.css — prose styles are now generated by themes (both runtime and build paths emit h1-h6, p, small, code, hr rules) - Remove all typography.css imports from example apps, storybook, sandbox - Remove dist/index.css import from storybook preview (was generated from typography.css import in the now-deleted XDSFontWrapper) - Fix remaining orphaned Chinese doc entry in Text.doc.mjs - Remove typography.css export from package.json Co-authored-by: Navi <[email protected]>
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsText · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. XDSText - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This was referenced Mar 18, 2026
cixzhang
added a commit
that referenced
this pull request
Apr 26, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors theme CSS generation so runtime and build use an identical shared path through
generateThemeRules(). Also removesXDSFontWrapper, adds prose HTML element rules, prop-level color overrides, and outputs type scale sizes inrem.Architecture
Changes
<div className='xds-typography'>. Migration: remove wrapper, render children.generateThemeRules()— shared intermediary producing identical CSS for both paths.build-theme.mjscallsdefineTheme()+generateThemeRules()from core.xdsClassNameincludes color prop for theme specificity.1.5rem) instead of px. Respects user browser font preferences.Theme Input (default)
Runtime Output (
generateThemeCSS→<style>tag)Build Output (
xds theme build→theme.css)Differences
@scopeonly@layer xds.theme { @scope }:root { color-scheme: light dark; }