Skip to content

Commit

Permalink
Fallback to default max viewport if layout wide size is fluid. (#53551)
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Aug 14, 2023
1 parent dc993b0 commit 864ad25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ 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_maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( gutenberg_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : '1600px';
$default_minimum_viewport_width = '320px';
$default_minimum_font_size_factor_max = 0.75;
$default_minimum_font_size_factor_min = 0.25;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
/**
* Internal dependencies
*/
import { getComputedFluidTypographyValue } from '../font-sizes/fluid-utils';
import {
getComputedFluidTypographyValue,
getTypographyValueAndUnit,
} from '../font-sizes/fluid-utils';

/**
* @typedef {Object} FluidPreset
Expand Down Expand Up @@ -98,11 +101,16 @@ function isFluidTypographyEnabled( typographySettings ) {
export function getFluidTypographyOptionsFromSettings( settings ) {
const typographySettings = settings?.typography;
const layoutSettings = settings?.layout;
return isFluidTypographyEnabled( typographySettings ) &&
const defaultMaxViewportWidth = getTypographyValueAndUnit(
layoutSettings?.wideSize
)
? layoutSettings?.wideSize
: null;
return isFluidTypographyEnabled( typographySettings ) &&
defaultMaxViewportWidth
? {
fluid: {
maxViewPortWidth: layoutSettings.wideSize,
maxViewportWidth: defaultMaxViewportWidth,
...typographySettings.fluid,
},
}
Expand Down

0 comments on commit 864ad25

Please sign in to comment.