Skip to content

Commit

Permalink
Fix: Font size picker regression on edit site global styles (#26603)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored Oct 30, 2020
1 parent 336ab24 commit 7982ce7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
13 changes: 0 additions & 13 deletions packages/edit-site/src/components/editor/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ export const PRESET_CATEGORIES = {
export const LINK_COLOR = '--wp--style--color--link';
export const LINK_COLOR_DECLARATION = `a { color: var(${ LINK_COLOR }, #00e); }`;

/* Helpers for unit processing */
export const fromPx = ( value ) => {
switch ( typeof value ) {
case 'string':
return +value.replace( 'px', '' );
case 'number':
default:
return value;
}
};

export const toPx = ( value ) => ( value ? value + 'px' : value );

export function useEditorFeature( featurePath, blockName = GLOBAL_CONTEXT ) {
const settings = useSelect( ( select ) => {
return select( 'core/edit-site' ).getSettings();
Expand Down
6 changes: 3 additions & 3 deletions packages/edit-site/src/components/sidebar/typography-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { fromPx, toPx, useEditorFeature } from '../editor/utils';
import { useEditorFeature } from '../editor/utils';

export default ( {
context: { supports, name },
Expand All @@ -32,9 +32,9 @@ export default ( {
<PanelBody title={ __( 'Typography' ) } initialOpen={ true }>
{ supports.includes( 'fontSize' ) && (
<FontSizePicker
value={ fromPx( getStyleProperty( name, 'fontSize' ) ) }
value={ getStyleProperty( name, 'fontSize' ) }
onChange={ ( value ) =>
setStyleProperty( name, 'fontSize', toPx( value ) )
setStyleProperty( name, 'fontSize', value )
}
fontSizes={ fontSizes }
disableCustomFontSizes={ disableCustomFontSizes }
Expand Down

0 comments on commit 7982ce7

Please sign in to comment.