Skip to content

Commit

Permalink
Updating site editor presets
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Jul 28, 2022
1 parent 0d2d286 commit e3ac832
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty
// Font sizes.
$fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;

// A font size has explicitly bypassed fluid calculations.
if ( false === $fluid_font_size_settings ) {
return $preset['size'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ describe( 'typography utils', () => {
typographySettings: undefined,
expected: '28px',
},
// Should return non-fluid value when fluid is `false`.
{
preset: {
size: '28px',
fluid: false,
},
typographySettings: {
fluid: true,
},
expected: '28px',
},
// Should return fluid value.
{
preset: {
Expand All @@ -38,6 +49,20 @@ describe( 'typography utils', () => {
expected:
'clamp(21px, 1.3125rem + ((1vw - 7.68px) * 2.524), 42px)',
},

// Should return default fluid values with null values.
{
preset: {
size: '28px',
fluid: null,
},
typographySettings: {
fluid: true,
},
expected:
'clamp(21px, 1.3125rem + ((1vw - 7.68px) * 2.524), 42px)',
},

// Should return size with invalid fluid units.
{
preset: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export function getTypographyFontSizeValue( preset, typographySettings ) {
const DEFAULT_SCALE_FACTOR = 1;

// Font sizes.
// A font size has explicitly bypassed fluid calculations.
if ( false === preset?.fluid ) {
return defaultSize;
}

const fluidFontSizeSettings = preset?.fluid || {};

// Try to grab explicit min and max fluid font sizes.
Expand Down

0 comments on commit e3ac832

Please sign in to comment.