mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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:
parent
4b87f197f4
commit
337a910076
@ -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.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.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
|
||||
*
|
||||
* @param array $preset {
|
||||
* 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();
|
||||
|
||||
// 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_font_size_factor_max = 0.75;
|
||||
$default_minimum_font_size_factor_min = 0.25;
|
||||
$default_scale_factor = 1;
|
||||
$has_min_font_size = isset( $fluid_settings['minFontSize'] ) &&
|
||||
! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
|
||||
$default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px';
|
||||
$default_minimum_font_size_limit = '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.
|
||||
$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.
|
||||
*/
|
||||
$minimum_font_size_limit = wp_get_typography_value_and_unit(
|
||||
$default_minimum_font_size_limit,
|
||||
$minimum_font_size_limit,
|
||||
array(
|
||||
'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(
|
||||
array(
|
||||
'minimum_viewport_width' => $default_minimum_viewport_width,
|
||||
'maximum_viewport_width' => $default_maximum_viewport_width,
|
||||
'minimum_viewport_width' => $minimum_viewport_width,
|
||||
'maximum_viewport_width' => $maximum_viewport_width,
|
||||
'minimum_font_size' => $minimum_font_size_raw,
|
||||
'maximum_font_size' => $maximum_font_size_raw,
|
||||
'scale_factor' => $default_scale_factor,
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @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.
|
||||
|
Loading…
Reference in New Issue
Block a user