Skip to content

Commit

Permalink
Hide typeset button when there are no typesets available (#64515)
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Aug 22, 2024
1 parent e7674d6 commit 8572b17
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/edit-site/src/components/global-styles/typeset-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ import { getFontFamilies } from './utils';
import { NavigationButtonAsItem } from './navigation-button';
import Subtitle from './subtitle';
import { unlock } from '../../lock-unlock';
import { filterObjectByProperties } from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';
import {
filterObjectByProperties,
useCurrentMergeThemeStyleVariationsWithUserConfig,
} from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';

const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );

function TypesetButton() {
const { base } = useContext( GlobalStylesContext );
const { user: userConfig } = useContext( GlobalStylesContext );
const propertiesToFilter = [ 'typography' ];
const typographyVariations =
useCurrentMergeThemeStyleVariationsWithUserConfig( propertiesToFilter );
const hasTypographyVariations = typographyVariations?.length > 1;
const { base, user: userConfig } = useContext( GlobalStylesContext );
const config = mergeBaseAndUserConfigs( base, userConfig );
const allFontFamilies = getFontFamilies( config );
const hasFonts =
Expand Down Expand Up @@ -63,6 +69,7 @@ function TypesetButton() {
}, [ allFontFamilies, userTypographyConfig, variations ] );

return (
hasTypographyVariations &&
hasFonts && (
<VStack spacing={ 2 }>
<HStack justify="space-between">
Expand Down

0 comments on commit 8572b17

Please sign in to comment.