-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fluid typography: ensure fontsizes are strings or integers #44847
Conversation
This PR also harmonizes the JS checks And review comments from #44807 (review) These changes have already been backported to Core in WordPress/wordpress-develop#3428
Size Change: +50 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
Add extra test for floats Add i18n domain
Updated tests and JSDoc type
Just testing how fluid font sizes are generated across theme.json, and the site/post editors. Styles in theme.json are converted and are applied in the editors. Site editor can overwrite global, element and block styles. These appear in both editors. Block support styles appear in the post editor. Frontend appears as expected.
Will move onto to testing individual blocks... > find ./packages/block-library/src/ -type f -name 'block.json' -exec grep -l '"fontSize": true' {} +
./packages/block-library/src//read-more/block.json
./packages/block-library/src//comments/block.json
./packages/block-library/src//post-author/block.json
./packages/block-library/src//post-comments-link/block.json
./packages/block-library/src//navigation-link/block.json
./packages/block-library/src//comments-pagination/block.json
./packages/block-library/src//calendar/block.json
./packages/block-library/src//buttons/block.json
./packages/block-library/src//post-date/block.json
./packages/block-library/src//post-excerpt/block.json
./packages/block-library/src//paragraph/block.json
./packages/block-library/src//quote/block.json
./packages/block-library/src//group/block.json
./packages/block-library/src//site-tagline/block.json
./packages/block-library/src//comment-edit-link/block.json
./packages/block-library/src//heading/block.json
./packages/block-library/src//comment-template/block.json
./packages/block-library/src//comment-content/block.json
./packages/block-library/src//term-description/block.json
./packages/block-library/src//post-author-name/block.json
./packages/block-library/src//comments-pagination-next/block.json
./packages/block-library/src//query-pagination-numbers/block.json
./packages/block-library/src//code/block.json
./packages/block-library/src//navigation/block.json
./packages/block-library/src//verse/block.json
./packages/block-library/src//post-comments-count/block.json
./packages/block-library/src//pullquote/block.json
./packages/block-library/src//post-author-biography/block.json
./packages/block-library/src//query-title/block.json
./packages/block-library/src//column/block.json
./packages/block-library/src//archives/block.json
./packages/block-library/src//post-navigation-link/block.json
./packages/block-library/src//table-of-contents/block.json
./packages/block-library/src//search/block.json
./packages/block-library/src//query-no-results/block.json
./packages/block-library/src//comment-date/block.json
./packages/block-library/src//post-comments-form/block.json
./packages/block-library/src//query-pagination-next/block.json
./packages/block-library/src//button/block.json
./packages/block-library/src//table/block.json
./packages/block-library/src//post-template/block.json
./packages/block-library/src//list/block.json
./packages/block-library/src//preformatted/block.json
./packages/block-library/src//query-pagination/block.json
./packages/block-library/src//post-terms/block.json
./packages/block-library/src//query-pagination-previous/block.json
./packages/block-library/src//comments-title/block.json
./packages/block-library/src//home-link/block.json
./packages/block-library/src//comments-pagination-previous/block.json
./packages/block-library/src//comment-author-name/block.json
./packages/block-library/src//columns/block.json
./packages/block-library/src//latest-posts/block.json
./packages/block-library/src//media-text/block.json
./packages/block-library/src//post-content/block.json
./packages/block-library/src//post-title/block.json
./packages/block-library/src//site-title/block.json
./packages/block-library/src//comment-reply-link/block.json
./packages/block-library/src//comments-pagination-numbers/block.json
./packages/block-library/src//categories/block.json
./packages/block-library/src//cover/block.json |
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.
Code looks good! Testing miscellaneous blocks with global and block-level styles, preset and custom sizes hasn't returned any breakage.
if ( empty( $preset['size'] ) ) { | ||
return $preset['size']; | ||
} | ||
|
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.
We'll also have to backport this bit, right?
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.
Yeah, I was hoping we can piggy back onto WordPress/wordpress-develop#3431 🤞
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.
I think we should be able to fairly smoothly 👍
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.
I've pulled the changes here into WordPress/wordpress-develop#3431
Fix typo in CHANGELOG.md
* Updating PHP doc to describe incoming type of $raw_value (string|int) This PR also harmonizes the JS checks And review comments from #44807 (review) These changes have already been backported to Core in WordPress/wordpress-develop#3428 * Update changelog Add extra test for floats Add i18n domain * Font sizes can be string|int|float Updated tests and JSDoc type * Expand tests for gutenberg_get_typography_value_and_unit Fix typo in CHANGELOG.md
* Fluid typography: convert server-side block support values (#44762) * For serverside rendered typography block support styles, covert font size values to fluid values in the inline styles if fluid typography is activated. Added unit tests * Add fluid font size to Nav Link * Add fluid typography to Search block * Fix fluid typography for Submenu block with open on click * Fix fluid typography for Page List block * Remove unnecessary parameter * Call esc_attr only once on the whole typography string Co-authored-by: tellthemachines <isabel@tellthemachines.com> * Fluid Typography: Fix bug in global styles where fluid clamp rules were not calculated for custom values (#44761) * Fluid Typography: Fix bug where fluid clamp rules were not calculated for custom global styles values * Add inline comments * Add tests for JS changes * Fluid Typography: ensure global styles preset fluid sizes are calculated correctly (#44791) * Forked #44761 * Ensuring the font size picker select box shows the right labels * update comment. Typescript has beaten me. It's much more convenient to use getFontSizeOptions(), but I guess we'll have to refactor. * Adding comment about Typescript bug (YAY, it wasn't me being dumb with TS for once) * Added tests yo * Changeo loggo * Create a new FontSizeSelectOption return type for getSelectedOption to: 1. Clean up type changes in #44791 2. Make TS linter be quiet * Revert accidental changes to emptytheme * Revert type changes and other calamities * Remove additional size value from getToggleGroupOptions test as I believe it is no longer expected Co-authored-by: Ramon <ramonjd@users.noreply.github.com> Co-authored-by: ramonjd <ramonjd@gmail.com> * Fluid typography: convert font size inline style attributes to fluid values (#44764) * This commit ensures that custom font size values that appear in the style attribute of block content are converted to fluid typography (if activated) * Adding comments * Bail early if we don't find a custom font size * Adding tests yo * Updating PHP doc to describe incoming type of $raw_value (string|number) * Make custom font sizes appear fluid in the block editor when fluid typography is enabled (#44765) * Make custom font sizes appear fluid in the block editor when fluid typography is enabled * Add tests for fluid utils * update description * You shall not pass with a number, well, yes, but we'll coerce it to `px` and the tests shall pass nonetheless!!! Co-authored-by: Ben Dwyer <ben@scruffian.com> Co-authored-by: ramonjd <ramonjd@gmail.com> * Fluid typography: covert font size number values to pixels (#44807) * Converts incoming raw font size values to value + pixel to remain consistent with the fontsizepicker component. * Updating comments / docs * Fluid typography: ensure fontsizes are strings or integers (#44847) * Updating PHP doc to describe incoming type of $raw_value (string|int) This PR also harmonizes the JS checks And review comments from #44807 (review) These changes have already been backported to Core in WordPress/wordpress-develop#3428 * Update changelog Add extra test for floats Add i18n domain * Font sizes can be string|int|float Updated tests and JSDoc type * Expand tests for gutenberg_get_typography_value_and_unit Fix typo in CHANGELOG.md * Initial commit (#44852) - ensure that we convert fluid font sizes to fluid values in the editor for search block block supports - we do this by passing the getTypographyClassesAndStyles hook a flag to tell it whether to convert Updated CHANGELOG.md Added tests Co-authored-by: tellthemachines <isabel@tellthemachines.com> Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Co-authored-by: Robert Anderson <robert@noisysocks.com> Co-authored-by: Ben Dwyer <ben@scruffian.com>
…ate 1. Merges the following: * [WordPress/gutenberg#44761 Gutenberg PR 44761] - Fluid Typography: Fix bug in global styles where fluid `clamp()` rules were not calculated for custom values * [WordPress/gutenberg#44762 Gutenberg PR 44762] - Fluid Typography: Convert server-side block support values * [WordPress/gutenberg#44764 Gutenberg PR 44764] - Fluid Typography: Convert font size inline style attributes to fluid values * [WordPress/gutenberg#44807 Gutenberg PR 44807] - Fluid Typography: Covert font size number values to pixels * [WordPress/gutenberg#44847 Gutenberg PR 44847] - Fluid Typography: ensure font sizes are strings or integers Follow-up to [54280]. Props andrewserong, isabel_brison, ramonopoly. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54497 602fd350-edb4-49c9-b593-d223f7449a82
…ate 1. Merges the following: * [WordPress/gutenberg#44761 Gutenberg PR 44761] - Fluid Typography: Fix bug in global styles where fluid `clamp()` rules were not calculated for custom values * [WordPress/gutenberg#44762 Gutenberg PR 44762] - Fluid Typography: Convert server-side block support values * [WordPress/gutenberg#44764 Gutenberg PR 44764] - Fluid Typography: Convert font size inline style attributes to fluid values * [WordPress/gutenberg#44807 Gutenberg PR 44807] - Fluid Typography: Covert font size number values to pixels * [WordPress/gutenberg#44847 Gutenberg PR 44847] - Fluid Typography: ensure font sizes are strings or integers Follow-up to [54280]. Props andrewserong, isabel_brison, ramonopoly. See #56467. Built from https://develop.svn.wordpress.org/trunk@54497 git-svn-id: http://core.svn.wordpress.org/trunk@54056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…ate 1. Merges the following: * [WordPress/gutenberg#44761 Gutenberg PR 44761] - Fluid Typography: Fix bug in global styles where fluid `clamp()` rules were not calculated for custom values * [WordPress/gutenberg#44762 Gutenberg PR 44762] - Fluid Typography: Convert server-side block support values * [WordPress/gutenberg#44764 Gutenberg PR 44764] - Fluid Typography: Convert font size inline style attributes to fluid values * [WordPress/gutenberg#44807 Gutenberg PR 44807] - Fluid Typography: Covert font size number values to pixels * [WordPress/gutenberg#44847 Gutenberg PR 44847] - Fluid Typography: ensure font sizes are strings or integers Follow-up to [54280]. Props andrewserong, isabel_brison, ramonopoly. See #56467. Built from https://develop.svn.wordpress.org/trunk@54497 git-svn-id: https://core.svn.wordpress.org/trunk@54056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Removing the "Backport to WP Beta/RC" label since this has been backported as part of #44868 (and sync'd to Core per WordPress/wordpress-develop#3437). |
…ate 1. Merges the following: * [WordPress/gutenberg#44761 Gutenberg PR 44761] - Fluid Typography: Fix bug in global styles where fluid `clamp()` rules were not calculated for custom values * [WordPress/gutenberg#44762 Gutenberg PR 44762] - Fluid Typography: Convert server-side block support values * [WordPress/gutenberg#44764 Gutenberg PR 44764] - Fluid Typography: Convert font size inline style attributes to fluid values * [WordPress/gutenberg#44807 Gutenberg PR 44807] - Fluid Typography: Covert font size number values to pixels * [WordPress/gutenberg#44847 Gutenberg PR 44847] - Fluid Typography: ensure font sizes are strings or integers Follow-up to [54280]. Props andrewserong, isabel_brison, ramonopoly. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54497 602fd350-edb4-49c9-b593-d223f7449a82
Parent issue: #44758
What?
This PR addresses the review comments from #44807 (review) and backports changes have already been backported to Core in WordPress/wordpress-develop#3428 😄
This PR also harmonizes the JS methods and tests to ensure both versions are compatible and consistent.
Why?
By the time the Core patch was merged, we hadn't merged into Gutenberg a null check on
gutenberg_get_typography_font_size_value
This broke the tests after subsequent WP backport PRs were merged into Gutenberg. See: #44758
Also, to ensure editor and frontend parity, the same rules should be present in the JS and PHP.
Testing Instructions
Ensure the tests pass.
Manually testing by ensuring fluid font size presets and custom sizes work everywhere (site editor, global styles, post editor, block supports, frontend)
Here's some test theme.json!