Global Styles: Create a shared component for typography previews#59503
Global Styles: Create a shared component for typography previews#59503
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +67 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
e4b7953 to
15fe862
Compare
use the typography preview in style panels Pass through the font size
15fe862 to
8afa19e
Compare
ramonjd
left a comment
There was a problem hiding this comment.
This is a nice refactor, thanks!
Confirming that the theme style variations work as expected, as do the typography variation previews
2024-03-04.11.26.35.mp4
| Aa | ||
| </motion.div> | ||
| <PreviewTypography | ||
| fontSize={ 65 * ratio } |
There was a problem hiding this comment.
Not necessary for this PR, but an idea for future follow up could be to use <PreviewTypography /> for the label below. It's using the same heading typography styles, so it could further clean up this file.
gutenberg/packages/edit-site/src/components/global-styles/preview.js
Lines 296 to 310 in 8afa19e
It might just need a tweak to the props, passing styles instead of fontSize and some default labels, e.g.,
// style is applied to body and heading spans
// headingLabel overwrites default of `_x( 'A', 'Uppercase letter A' )`
// bodyLabel=false hides the default bodyLabel
<PreviewTypography
style={ {
fontSize: 40 * ratio,
lineHeight: '1em',
textAlign: 'center',
display: 'block',
} }
headingLabel={ label }
bodyLabel={ false }
variation={ variation }
/>
What?
Creates a new component for previewing typography styles which can be shared by various places in Global Styles that need to preview typography. This differs from the current component in that it uses both the heading font family and the body font family for the preview.
Why?
Creates a more consistent user experience. Sharing code is more maintainable.
How?
Extracts a new
PreviewTypographycomponent from theTypographyVariationsfile and implements it in theStylesPreviewcomponent.Note
There is already a similar component called TypographyPreview - this only outputs one font family preview not two, so we do need two, but I think the names could be better.
Testing Instructions
Screenshots or screencast