Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Font size picker regression on edit site global styles #26603

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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