Skip to content

Commit

Permalink
Reinstating the commit in edeaca7 so we can test fluid configuration
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
ramonjd committed Oct 6, 2022
1 parent 9004df2 commit 6257800
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,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 | |
Expand Down
16 changes: 8 additions & 8 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,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;
Expand Down
26 changes: 24 additions & 2 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,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.",
Expand Down

0 comments on commit 6257800

Please sign in to comment.