From 7076ce90bd5f3ba7143c712ba2d39b3c47a051df Mon Sep 17 00:00:00 2001 From: ramonjd Date: Mon, 18 Jul 2022 16:09:30 +1000 Subject: [PATCH] Reinstating the commit in edeaca7068196f8960453965fe7fa64632d573ef so we can test fluid configuration Update docs --- .../theme-json-reference/theme-json-living.md | 2 +- lib/block-supports/typography.php | 16 ++++++------ schemas/json/theme.json | 26 +++++++++++++++++-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/docs/reference-guides/theme-json-reference/theme-json-living.md b/docs/reference-guides/theme-json-reference/theme-json-living.md index fdbf14d6b9379..0ec6108781846 100644 --- a/docs/reference-guides/theme-json-reference/theme-json-living.md +++ b/docs/reference-guides/theme-json-reference/theme-json-living.md @@ -98,7 +98,7 @@ Settings related to typography. | customFontSize | boolean | true | | | fontStyle | boolean | true | | | fontWeight | boolean | true | | -| fluid | boolean | | | +| fluid | object | | | | letterSpacing | boolean | true | | | lineHeight | boolean | false | | | textDecoration | boolean | true | | diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 382b897fefcf8..61c9d60dc9e35 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -361,19 +361,19 @@ function gutenberg_get_computed_fluid_typography_value( $args = array() ) { */ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_typography = false ) { // Check if fluid font sizes are activated. - $typography_settings = gutenberg_get_global_settings( array( 'typography' ) ); - $should_use_fluid_typography = isset( $typography_settings['fluid'] ) && true === $typography_settings['fluid'] ? true : $should_use_fluid_typography; + $typography_settings = gutenberg_get_global_settings( array( 'typography' ) ); + $fluid_settings = isset( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : $should_use_fluid_typography; - if ( ! $should_use_fluid_typography ) { + if ( ! $fluid_settings ) { return $preset['size']; } // Defaults. - $default_maximum_viewport_width = '1600px'; - $default_minimum_viewport_width = '768px'; - $default_minimum_font_size_factor = 0.75; - $default_maximum_font_size_factor = 1.5; - $default_scale_factor = 1; + $default_maximum_viewport_width = isset( $fluid_settings['maxViewPortWidth'] ) ? $fluid_settings['maxViewPortWidth'] : '1600px'; + $default_minimum_viewport_width = isset( $fluid_settings['minViewPortWidth'] ) ? $fluid_settings['minViewPortWidth'] : '768px'; + $default_minimum_font_size_factor = isset( $fluid_settings['minFontSizeFactor'] ) && is_numeric( $fluid_settings['minFontSizeFactor'] ) ? $fluid_settings['minFontSizeFactor'] : 0.75; + $default_maximum_font_size_factor = isset( $fluid_settings['maxFontSizeFactor'] ) && is_numeric( $fluid_settings['minFontSizeFactor'] ) ? $fluid_settings['maxFontSizeFactor'] : 1.5; + $default_scale_factor = isset( $fluid_settings['scaleFactor'] ) && is_numeric( $fluid_settings['scaleFactor'] ) ? $fluid_settings['scaleFactor'] : 1; // Font sizes. $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null; diff --git a/schemas/json/theme.json b/schemas/json/theme.json index a218947b92f4a..e96628f4a4d66 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -317,8 +317,30 @@ "default": true }, "fluid": { - "description": "Opts into fluid typography.", - "type": "boolean" + "description": "Enables fluid typography and allows users to set global fluid typography parameters.", + "type": "object", + "properties": { + "maxViewPortWidth": { + "description": "Allow users to set custom a max viewport width in px, rem or em, used to set the maximum size boundary of a fluid font.", + "type": "string" + }, + "minViewPortWidth": { + "description": "Allow users to set custom a min viewport width in px, rem or em, used to set the minimum size boundary of a fluid font", + "type": "string" + }, + "minFontSizeFactor": { + "description": "Used to calculate a minimum font size from a single size value, where `fluidSize.min` is not set.", + "type": "number" + }, + "maxFontSizeFactor": { + "description": "Used to calculate a maximum font size from a single size value, where `fluidSize.max` is not set.", + "type": "number" + }, + "scaleFactor": { + "description": "Determines the rate of font size change between the minimum and maximum font sizes. The higher the value the faster the change.", + "type": "number" + } + } }, "letterSpacing": { "description": "Allow users to set custom letter spacing.",