Skip to content

Commit

Permalink
Show theme_name + style where there is no typography font family info.
Browse files Browse the repository at this point in the history
Remove unused file.
  • Loading branch information
ramonjd committed Feb 5, 2024
1 parent db4be58 commit cde7009
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 120 deletions.
103 changes: 0 additions & 103 deletions packages/edit-site/src/components/global-styles/typeset.js

This file was deleted.

7 changes: 6 additions & 1 deletion packages/edit-site/src/components/global-styles/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ export const getVariationsByProperty = ( user, variations, property ) => {
);

const variationsWithOnlyProperty = variations.map( ( variation ) => {
return filterObjectByProperty( variation, property );
return {
...filterObjectByProperty( variation, property ),
// Add variation title and description to every variation item.
title: variation?.title,
description: variation?.description,
};
} );

return variationsWithOnlyProperty.map( ( variation ) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ function TypographyVariation( { variation } ) {
const [ bodyFontFamilies, headingFontFamilies ] = getFontFamilies(
mergeBaseAndUserConfigs( base, variation )
);

const bodyPreviewStyle = getFamilyPreviewStyle( bodyFontFamilies );
const bodyPreviewStyle = bodyFontFamilies
? getFamilyPreviewStyle( bodyFontFamilies )
: {};
const headingPreviewStyle = {
...getFamilyPreviewStyle( headingFontFamilies ),
...( headingFontFamilies &&
getFamilyPreviewStyle( headingFontFamilies ) ),
fontSize: '1.2rem',
};

Expand Down Expand Up @@ -154,10 +156,10 @@ function TypographyVariation( { variation } ) {
} }
>
<div style={ headingPreviewStyle }>
{ headingFontFamilies.name }
{ headingFontFamilies?.name || variation?.title }
</div>
<div style={ bodyPreviewStyle }>
{ bodyFontFamilies.name }
{ bodyFontFamilies?.name || __( 'Typeset' ) }
</div>
</VStack>
</div>
Expand All @@ -173,10 +175,8 @@ export default function TypographyVariations() {
}, [] );

const { base, user } = useContext( GlobalStylesContext );

const typographyVariations =
variations && getVariationsByProperty( user, variations, 'typography' );

const uniqueTypographyVariations = [];
const uniqueTypographyNames = [];
const isDup = ( x, y ) => {
Expand Down Expand Up @@ -204,15 +204,16 @@ export default function TypographyVariations() {
columns={ 2 }
className="edit-site-global-styles-style-variations-container"
>
{ uniqueTypographyVariations &&
uniqueTypographyVariations.map( ( variation, index ) => {
return (
<TypographyVariation
key={ index }
variation={ variation }
/>
);
} ) }
{ typographyVariations && typographyVariations.length
? uniqueTypographyVariations.map( ( variation, index ) => {
return (
<TypographyVariation
key={ index }
variation={ variation }
/>
);
} )
: null }
</Grid>
</VStack>
);
Expand Down

0 comments on commit cde7009

Please sign in to comment.