-
Notifications
You must be signed in to change notification settings - Fork 67
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: add font-loading class #2418
Conversation
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.
Apologies for missing this one entirely! This works as described, and is a really nice addition for the more dramatic font widths 🙂 Approving & merging!
Hey @adekbadek, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
# [2.5.0-alpha.1](v2.4.3...v2.5.0-alpha.1) (2025-02-07) ### Bug Fixes * make sure featured image behind images are centred ([#2430](#2430)) ([871838d](871838d)) ### Features * add corrections archive template ([#2431](#2431)) ([09897b0](09897b0)) * add font-loading class ([#2418](#2418)) ([24888a3](24888a3))
🎉 This PR is included in version 2.5.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 2.5.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Adds a
newspack--font-loading
class to thebody
element until custom fonts are loaded. This will a enable font-loading-related performance improvement.Let's say a site is using a thick font for headings. In order to prevent layout shift on font load, the fallback font can be styled to match the thickness (e.g. by setting
letter-spacing
to something wide). On font load, the body class will be removed, and the custom font displayed as expected.How to test the changes in this Pull Request:
//fonts.googleapis.com/css2?family=Anton&family=Inter:wght@400;500;700&display=swap
, then set "Header Font" toAnton
.newspack--font-loading h3 { letter-spacing: -1px; }
body
element has thenewspack--font-loading
class, which is then removed. Theh3
elements should match theAnton
font on load. Enable network throttling for better observation.Other information: