Skip to content

Commit

Permalink
Change how empty variation is accounted for so it also picks up custo…
Browse files Browse the repository at this point in the history
…m CSS
  • Loading branch information
glendaviesnz committed May 19, 2024
1 parent 45cd61a commit e5d6b08
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ export default function StyleVariationsContainer( { gap = 2 } ) {
);
} );

multiplePropertyVariations.unshift( {
title: __( 'Default' ),
settings: {},
styles: {},
} );

const withEmptyVariation = useMemo( () => {
const themeVariations = useMemo( () => {
const withEmptyVariation = [
{
title: __( 'Default' ),
settings: {},
styles: {},
},
...( multiplePropertyVariations ?? [] ),
];
return [
...( multiplePropertyVariations ?? [] ).map( ( variation ) => {
...withEmptyVariation.map( ( variation ) => {
const blockStyles = { ...variation?.styles?.blocks } || {};
// We need to copy any user custom CSS to the variation to prevent it being lost
// when switching variations.
Expand Down Expand Up @@ -95,7 +97,7 @@ export default function StyleVariationsContainer( { gap = 2 } ) {
className="edit-site-global-styles-style-variations-container"
gap={ gap }
>
{ withEmptyVariation.map( ( variation, index ) => (
{ themeVariations.map( ( variation, index ) => (
<Variation key={ index } variation={ variation }>
{ ( isFocused ) => (
<PreviewStyles
Expand Down

0 comments on commit e5d6b08

Please sign in to comment.