Skip to content

Commit

Permalink
Initial commit:
Browse files Browse the repository at this point in the history
- add min and max viewport width to the theme.json schema
- supporting min and max viewport widths in PHP typography block supports
  • Loading branch information
ramonjd committed Aug 4, 2023
1 parent 9dfe094 commit 314ea97
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,11 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty
$fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array();

// Defaults.
$default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px';
$default_minimum_viewport_width = '320px';
$default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px';
if ( isset( $typography_settings['maxViewportWidth'] ) ) {
$default_maximum_viewport_width = $typography_settings['maxViewportWidth'];
}
$default_minimum_viewport_width = isset( $typography_settings['minViewportWidth'] ) ? $typography_settings['minViewportWidth'] : '320px';
$default_minimum_font_size_factor_max = 0.75;
$default_minimum_font_size_factor_min = 0.25;
$default_scale_factor = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function getTypographyFontSizeValue( preset, typographyOptions ) {
fontSize: defaultSize,
minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
maximumViewportWidth: fluidTypographySettings?.maxViewportWidth,
minimumViewportWidth: fluidTypographySettings?.minViewportWidth,
} );

if ( !! fluidFontSizeValue ) {
Expand Down
8 changes: 8 additions & 0 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,14 @@
"minFontSize": {
"description": "Allow users to set a global minimum font size boundary in px, rem or em. Custom font sizes below this value will not be clamped, and all calculated minimum font sizes will be, a at minimum, this value.",
"type": "string"
},
"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 size.",
"type": "string"
},
"minViewPortWidth": {
"description": "Allow users to set a custom min viewport width in px, rem or em, used to set the minimum size boundary of a fluid font size.",
"type": "string"
}
},
"additionalProperties": false
Expand Down

0 comments on commit 314ea97

Please sign in to comment.