Skip to content

Commit

Permalink
make the styles look nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Dec 6, 2023
1 parent 270afc1 commit a39c4c8
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
__experimentalHeading as Heading,
__experimentalGrid as Grid,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalZStack as ZStack,
ColorIndicator,
} from '@wordpress/components';
Expand Down Expand Up @@ -117,6 +118,9 @@ const getFontFamilyNames = ( themeJson ) => {
return [ bodyFontFamily?.name, headingFontFamily?.name ];
};

const normalizedHeight = 100;
const ratio = 1;

function Variation( { variation, isColor, isFont } ) {
const [ isFocused, setIsFocused ] = useState( false );
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
Expand Down Expand Up @@ -244,12 +248,9 @@ function ColorVariation( { variation } ) {
return (
<GlobalStylesContext.Provider value={ context }>
<div
className={ classnames(
'edit-site-global-styles-variations_item',
{
'is-active': isActive,
}
) }
className={ classnames( {
'is-active': isActive,
} ) }
role="button"
onClick={ selectVariation }
onKeyDown={ selectOnEnter }
Expand Down Expand Up @@ -336,7 +337,7 @@ function TypographyVariation( { variation } ) {
const bodyPreviewStyle = getFamilyPreviewStyle( bodyFontFamilies );
const headingPreviewStyle = {
...getFamilyPreviewStyle( headingFontFamilies ),
fontSize: '1.5rem',
fontSize: '1.2rem',
};

return (
Expand All @@ -357,17 +358,22 @@ function TypographyVariation( { variation } ) {
onFocus={ () => setIsFocused( true ) }
onBlur={ () => setIsFocused( false ) }
>
<div
<VStack
className="edit-site-global-styles-variations_item-preview"
isFocused={ isFocused }
style={ {
height: normalizedHeight * ratio,
lineHeight: 1.2,
textAlign: 'center',
} }
>
<div style={ headingPreviewStyle }>
{ headingFontFamilies.name }
</div>
<div style={ bodyPreviewStyle }>
{ bodyFontFamilies.name }
</div>
</div>
</VStack>
</div>
</GlobalStylesContext.Provider>
);
Expand All @@ -376,7 +382,7 @@ function TypographyVariation( { variation } ) {
function ColorVariations( { variations } ) {
const { user } = useContext( GlobalStylesContext );
const colorVariations =
variations && getVariationsByType( user, variations, 'color' );
variations && getVariationsByType( user, variations, 'color' ); // should also get filter?

return (
<>
Expand Down

0 comments on commit a39c4c8

Please sign in to comment.