Editor: add configurable viewport sizes for fluid typography.

Adds options to configure min and max viewport sizes for fluid typography in theme.json settings.

Props ramonopoly.
Fixes #59048.

Built from https://develop.svn.wordpress.org/trunk@56535


git-svn-id: http://core.svn.wordpress.org/trunk@56047 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
isabel_brison 2023-09-07 04:30:21 +00:00
parent 4b87f197f4
commit 337a910076
2 changed files with 16 additions and 8 deletions

View File

@ -471,6 +471,7 @@ function wp_get_computed_fluid_typography_value( $args = array() ) {
* @since 6.1.1 Adjusted rules for min and max font sizes. * @since 6.1.1 Adjusted rules for min and max font sizes.
* @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support. * @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support.
* @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale. * @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale.
* @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
* *
* @param array $preset { * @param array $preset {
* Required. fontSizes preset value as seen in theme.json. * Required. fontSizes preset value as seen in theme.json.
@ -517,14 +518,21 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
: array(); : array();
// Defaults. // Defaults.
$default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( wp_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : '1600px'; $default_maximum_viewport_width = '1600px';
$default_minimum_viewport_width = '320px'; $default_minimum_viewport_width = '320px';
$default_minimum_font_size_factor_max = 0.75; $default_minimum_font_size_factor_max = 0.75;
$default_minimum_font_size_factor_min = 0.25; $default_minimum_font_size_factor_min = 0.25;
$default_scale_factor = 1; $default_scale_factor = 1;
$has_min_font_size = isset( $fluid_settings['minFontSize'] ) && $default_minimum_font_size_limit = '14px';
! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
$default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px'; // Defaults overrides.
$minimum_viewport_width = isset( $fluid_settings['minViewportWidth'] ) ? $fluid_settings['minViewportWidth'] : $default_minimum_viewport_width;
$maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( wp_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width;
if ( isset( $fluid_settings['maxViewportWidth'] ) ) {
$maximum_viewport_width = $fluid_settings['maxViewportWidth'];
}
$has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
$minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : $default_minimum_font_size_limit;
// Font sizes. // Font sizes.
$fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null; $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;
@ -551,7 +559,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
* in order to perform comparative checks. * in order to perform comparative checks.
*/ */
$minimum_font_size_limit = wp_get_typography_value_and_unit( $minimum_font_size_limit = wp_get_typography_value_and_unit(
$default_minimum_font_size_limit, $minimum_font_size_limit,
array( array(
'coerce_to' => $preferred_size['unit'], 'coerce_to' => $preferred_size['unit'],
) )
@ -600,8 +608,8 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
$fluid_font_size_value = wp_get_computed_fluid_typography_value( $fluid_font_size_value = wp_get_computed_fluid_typography_value(
array( array(
'minimum_viewport_width' => $default_minimum_viewport_width, 'minimum_viewport_width' => $minimum_viewport_width,
'maximum_viewport_width' => $default_maximum_viewport_width, 'maximum_viewport_width' => $maximum_viewport_width,
'minimum_font_size' => $minimum_font_size_raw, 'minimum_font_size' => $minimum_font_size_raw,
'maximum_font_size' => $maximum_font_size_raw, 'maximum_font_size' => $maximum_font_size_raw,
'scale_factor' => $default_scale_factor, 'scale_factor' => $default_scale_factor,

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.4-alpha-56534'; $wp_version = '6.4-alpha-56535';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.