Editor: Don't use fluid layout value in typography.

Changes fluid typography calculation to use fallback value if layout wide size is a fluid value.

Props ramonopoly, mukesh27, jastos, aurooba.
See #58754.


git-svn-id: https://develop.svn.wordpress.org/trunk@56503 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Isabel Brison 2023-09-01 04:01:23 +00:00
parent 3c98d25402
commit 0b40c80d0d
5 changed files with 27 additions and 1 deletions

View File

@ -517,7 +517,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
: array();
// Defaults.
$default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px';
$default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( wp_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : '1600px';
$default_minimum_viewport_width = '320px';
$default_minimum_font_size_factor_max = 0.75;
$default_minimum_font_size_factor_min = 0.25;

View File

@ -0,0 +1,8 @@
/*
Theme Name: Block Theme Child Theme With Fluid Layout
Theme URI: https://wordpress.org/
Description: For testing purposes only.
Template: block-theme
Version: 1.0.0
Text Domain: block-theme-child-with-fluid-layout
*/

View File

@ -0,0 +1,12 @@
{
"version": 2,
"settings": {
"appearanceTools": true,
"layout": {
"wideSize": "clamp(1000px, 85vw, 2000px)"
},
"typography": {
"fluid": true
}
}
}

View File

@ -699,6 +699,11 @@ class Tests_Block_Supports_Typography extends WP_UnitTestCase {
'theme_slug' => 'block-theme-child-with-fluid-typography-config',
'expected_output' => 'font-size:15px;',
),
'returns clamp value using default config if layout is fluid' => array(
'font_size_value' => '15px',
'theme_slug' => 'block-theme-child-with-fluid-layout',
'expected_output' => 'font-size:clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.078), 15px);',
),
);
}

View File

@ -179,6 +179,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
'Block Theme',
'Block Theme Child Theme',
'Block Theme Child with no theme.json',
'Block Theme Child Theme With Fluid Layout',
'Block Theme Child Theme With Fluid Typography',
'Block Theme Child Theme With Fluid Typography Config',
'Block Theme Non Latin',