-
Notifications
You must be signed in to change notification settings - Fork 0
feat: preload fonts #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: preload fonts #1024
Conversation
commit: |
d542056 to
3d5ed30
Compare
WalkthroughAdds optional custom font support across the visual editor: passes Sequence Diagram(s)sequenceDiagram
participant User
participant ThemeEditorRightSidebar
participant ThemeFieldsSidebar
participant CustomFontUtils as customFontPreloads
participant applyTheme
participant Browser
User->>ThemeEditorRightSidebar: Open editor / select template
ThemeEditorRightSidebar->>ThemeFieldsSidebar: Pass customFonts prop
User->>ThemeFieldsSidebar: Change font selection / update theme
ThemeFieldsSidebar->>CustomFontUtils: loadCustomFontCssIndex(customFonts)
CustomFontUtils-->>ThemeFieldsSidebar: customFontCssIndex
ThemeFieldsSidebar->>CustomFontUtils: buildCustomFontPreloads(themeConfig, themeValues, customFonts, customFontCssIndex)
CustomFontUtils-->>ThemeFieldsSidebar: preload URL list
ThemeFieldsSidebar->>ThemeFieldsSidebar: Store __customFontPreloads in theme values
ThemeFieldsSidebar->>applyTheme: Apply theme (includes __customFontPreloads)
applyTheme->>CustomFontUtils: getCustomFontPreloads(overrides)
CustomFontUtils-->>applyTheme: preload URLs
applyTheme->>Browser: Inject <link rel="preload"> tags
applyTheme->>Browser: Inject font stylesheet <link> tags
Browser-->>User: Fonts preloaded before stylesheet fetch/render
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
...ages/visual-editor/src/internal/puck/components/theme-editor-sidebars/ThemeFieldsSidebar.tsx
Show resolved
Hide resolved
benlife5
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
custom fonts (both static and variable) are preloaded.
The file paths to preload at are saved the in theme data under
__customFontPreloadslike:Screen.Recording.2026-02-04.at.1.10.07.PM.mov
See live site: https://jovially-similar-mongrel.pgsdemo.com/va/richmond/1101-wilson-blvd (you can hard refresh and custom fonts still don't flash)