Skip to content

Commit

Permalink
Fix: Font Weight and Style don't work independently on global styles. (
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored Dec 10, 2020
1 parent 35da6d8 commit 138288f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/edit-site/src/components/sidebar/typography-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ function useHasLineHeightControl( { supports, name } ) {
function useHasAppearenceControl( { supports, name } ) {
const fontStyles = useEditorFeature( 'typography.fontStyles', name );
const fontWeights = useEditorFeature( 'typography.fontWeights', name );
const hasFontAppearance = !! fontStyles?.length && !! fontWeights?.length;

return (
hasFontAppearance &&
supports.includes( 'fontStyle' ) &&
supports.includes( 'fontWeight' )
( supports.includes( 'fontStyle' ) && !! fontStyles?.length ) ||
( supports.includes( 'fontWeight' ) && !! fontWeights?.length )
);
}

Expand All @@ -56,6 +53,8 @@ export default function TypographyPanel( {
const fontWeights = useEditorFeature( 'typography.fontWeights', name );
const hasLineHeightEnabled = useHasLineHeightControl( { supports, name } );
const hasAppearenceControl = useHasAppearenceControl( { supports, name } );
const hasFontStyleSupport = supports.includes( 'fontStyle' );
const hasFontWeightSupport = supports.includes( 'fontWeight' );

return (
<PanelBody title={ __( 'Typography' ) } initialOpen={ true }>
Expand Down Expand Up @@ -92,7 +91,14 @@ export default function TypographyPanel( {
fontStyle: getStyleProperty( name, 'fontStyle' ),
fontWeight: getStyleProperty( name, 'fontWeight' ),
} }
options={ { fontStyles, fontWeights } }
options={ {
fontStyles: hasFontStyleSupport
? fontStyles
: undefined,
fontWeights: hasFontWeightSupport
? fontWeights
: undefined,
} }
onChange={ ( { fontStyle, fontWeight } ) => {
setStyleProperty( name, 'fontStyle', fontStyle );
setStyleProperty( name, 'fontWeight', fontWeight );
Expand Down

0 comments on commit 138288f

Please sign in to comment.