Skip to content

Commit

Permalink
Fix font appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jan 26, 2023
1 parent ee0817c commit 6ceed6f
Showing 1 changed file with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,29 +205,23 @@ export default function TypographyPanel( {
const hasFontWeights = settings?.typography?.fontWeight;
const fontStyle = decodeValue( inherit?.typography?.fontStyle );
const fontWeight = decodeValue( inherit?.typography?.fontWeight );
const setFontStyle = ( newValue ) => {
const setFontAppearance = ( {
fontStyle: newFontStyle,
fontWeight: newFontWeight,
} ) => {
onChange( {
...value,
typography: {
...value?.typography,
fontStyle: newValue,
},
} );
};
const setFontWeight = ( newValue ) => {
onChange( {
...value,
typography: {
...value?.typography,
fontWeight: newValue,
fontStyle: newFontStyle,
fontWeight: newFontWeight,
},
} );
};
const hasFontAppearance = () =>
!! value?.typography?.fontStyle || !! value?.typography?.fontWeight;
const resetFontAppearance = () => {
setFontStyle( undefined );
setFontWeight( undefined );
setFontAppearance( {} );
};

// Line Height
Expand Down Expand Up @@ -306,12 +300,10 @@ export default function TypographyPanel( {
const resetTextDecoration = () => setTextDecoration( undefined );

const resetAll = () => {
resetFontFamily();
setFontSize();
resetFontAppearance();
resetLineHeight();
resetLetterSpacing();
resetTextDecoration();
onChange( {
...value,
typography: {},
} );
};

return (
Expand Down Expand Up @@ -364,13 +356,7 @@ export default function TypographyPanel( {
fontStyle,
fontWeight,
} }
onChange={ ( {
fontStyle: newFontStyle,
fontWeight: newFontWeight,
} ) => {
setFontStyle( newFontStyle );
setFontWeight( newFontWeight );
} }
onChange={ setFontAppearance }
hasFontStyles={ hasFontStyles }
hasFontWeights={ hasFontWeights }
size="__unstable-large"
Expand Down

0 comments on commit 6ceed6f

Please sign in to comment.