Repository navigation
feat(theme): remove runtime font loading from defineTheme - #2226
Merged
Merged
Conversation
Font loading via the typography.url field and useThemeFontLoading hook was unreliable (CSP, SSR, timing issues) and only used by the Stone theme. Consumers should import fonts themselves via <link> tags or @import in their CSS. Removes: - ThemeFontSource type and fonts field from XDSDefinedTheme - url field from TypographyRole - useThemeFontLoading hook from XDSTheme - Font derivation/merging logic in defineTheme() - url declarations from Stone theme typography.family and typography.fallbacks still work — defineTheme sets the --font-family-* tokens so the font is used once loaded.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
enabled auto-merge (squash)
May 19, 2026 23:55
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
Font loading via the typography.url field and useThemeFontLoading hook was unreliable (CSP, SSR, timing issues) and only used by the Stone theme. Consumers should import fonts themselves via <link> tags or @import in their CSS. Removes: - ThemeFontSource type and fonts field from XDSDefinedTheme - url field from TypographyRole - useThemeFontLoading hook from XDSTheme - Font derivation/merging logic in defineTheme() - url declarations from Stone theme typography.family and typography.fallbacks still work — defineTheme sets the --font-family-* tokens so the font is used once loaded.
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
Font loading via the typography.url field and useThemeFontLoading hook was unreliable (CSP, SSR, timing issues) and only used by the Stone theme. Consumers should import fonts themselves via <link> tags or @import in their CSS. Removes: - ThemeFontSource type and fonts field from XDSDefinedTheme - url field from TypographyRole - useThemeFontLoading hook from XDSTheme - Font derivation/merging logic in defineTheme() - url declarations from Stone theme typography.family and typography.fallbacks still work — defineTheme sets the --font-family-* tokens so the font is used once loaded.
cixzhang
pushed a commit
that referenced
this pull request
Aug 15, 2026
* feat(cli): warn when a theme names fonts it does not load `astryx theme build` now checks the resolved --font-family-* tokens and component-override fontFamily values against CSS generics and known preinstalled system families (including the shipped themes' deliberate fallback stacks, so none of the seven themes false-warns). Anything else gets one warning per family in the receipt and on stderr, plus the <link>/@font-face snippet printed after the install instructions — the slot that previously held a dead resolvedTheme.fonts block (#2226 removed the field it read). `astryx docs typography` gains a Loading Custom Fonts section (Google Fonts and self-hosted recipes, font-display: swap, real fallback stacks); the theme docs' production-build section points at it. Shipped webfont themes now warn by design in repo builds — the same builds already print install instructions for them. Part (3) of the issue (the phantom url field in the docs) is a design call and is left untouched. Closes #5015 * test(cli): cover font-warning edge cases; fix multi-line quoted names Nine tests: null/non-string resolved-theme inputs, fontFamily nested under pseudo-class override blocks (unit and through the defineTheme path), var() fallbacks containing another var(), case-variant generic keywords, css2 URL percent-encoding, and the --json envelope contract (warnings in the receipt, snippet suppressed, stdout stays parseable). The multi-line test caught a real bug: the quoted-name check lacked dotAll, so a family quoted across lines (template-literal theme sources) kept its quote characters, breaking dedupe, system-font matching, and the css2 URL. Fixed with the /s flag.
This branch was successfully deployed
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.
What
Removes the runtime font loading mechanism from
defineTheme. Consumers should load fonts themselves (e.g.<link>tag in<head>or@importin CSS).Why
The
typography.url+useThemeFontLoadingapproach was:What's removed
ThemeFontSourcetype andfontsfield fromXDSDefinedThemeurlfield fromTypographyRoleuseThemeFontLoadinghook fromXDSThemedefineTheme()urldeclarations from Stone themeWhat still works
typography.familyandtypography.fallbacksare unchanged —defineThemestill sets--font-family-body,--font-family-heading,--font-family-codetokens so the font is applied once loaded.Migration
If you were relying on the runtime font injection, add a
<link>to your HTML: