Skip to content

Commit

Permalink
Fallback to default max viewport if layout wide size is fluid.
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Aug 11, 2023
1 parent 042cf89 commit e012478
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 @@ -468,7 +468,7 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty

// Defaults overrides.
$minimum_viewport_width = isset( $fluid_settings['minViewportWidth'] ) ? $fluid_settings['minViewportWidth'] : $default_minimum_viewport_width;
$maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width;
$maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( gutenberg_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'];
}
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 @@ -99,11 +102,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 e012478

Please sign in to comment.