Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles: Try color and typography presets in Site View #59594

Merged
merged 8 commits into from
Mar 15, 2024
Prev Previous commit
Next Next commit
only output the preset headers if there are presets
  • Loading branch information
scruffian committed Mar 15, 2024
commit c9b7390c80ead06495d3a570629b0e81c0f5b635
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import useGlobalStylesRevisions from '../global-styles/screen-revisions/use-glob
import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';
import ColorVariations from '../global-styles/variations/variations-color';
import TypographyVariations from '../global-styles/variations/variations-typography';
import { useCurrentMergeThemeStyleVariationsWithUserConfig } from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';

const noop = () => {};

Expand Down Expand Up @@ -74,6 +75,15 @@ function SidebarNavigationScreenGlobalStylesContent() {
};
}, [] );

const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig( {
property: 'color',
} );

const typographyVariations =
useCurrentMergeThemeStyleVariationsWithUserConfig( {
property: 'typography',
} );

// Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are
// loaded. This is necessary because the Iframe component waits until
// the block editor store's `__internalIsInitialized` is true before
Expand All @@ -90,18 +100,22 @@ function SidebarNavigationScreenGlobalStylesContent() {
className="edit-site-global-styles-variation-container"
>
<StyleVariationsContainer />
<div>
<h3 className="edit-site-global-styles-variation-title">
{ __( 'Colors' ) }
</h3>
<ColorVariations />
</div>
<div>
<h3 className="edit-site-global-styles-variation-title">
{ __( 'Typography' ) }
</h3>
<TypographyVariations />
</div>
{ colorVariations && (
<div>
<h3 className="edit-site-global-styles-variation-title">
{ __( 'Colors' ) }
</h3>
<ColorVariations />
</div>
) }
{ typographyVariations && (
<div>
<h3 className="edit-site-global-styles-variation-title">
{ __( 'Typography' ) }
</h3>
<TypographyVariations />
</div>
) }
</VStack>
</BlockEditorProvider>
);
Expand Down