Skip to content

Commit

Permalink
Disable editing on default styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Jan 3, 2023
1 parent 8dab200 commit aac1e1b
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions packages/edit-site/src/components/global-styles/variations-panel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { store as blocksStore } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
Expand Down Expand Up @@ -40,21 +41,41 @@ export function VariationsPanel( { name } ) {

return (
<ItemGroup isBordered isSeparated>
{ coreBlockStyles.map( ( style, index ) => (
<NavigationButtonAsItem
key={ index }
icon={ '+' }
path={
'/blocks/' +
encodeURIComponent( name ) +
'/variations/' +
encodeURIComponent( style.name )
}
aria-label={ style.label }
>
{ style.label }
</NavigationButtonAsItem>
) ) }
{ coreBlockStyles.map( ( style, index ) => {
if ( style?.isDefault ) {
return (
<NavigationButtonAsItem
key={ index }
disabled={ true }
path={
'/blocks/' +
encodeURIComponent( name ) +
'/variations/' +
encodeURIComponent( style.name )
}
aria-label={ `${ style.label } ${ __(
'(Default)'
) }` }
>
{ `${ style.label } ${ __( '(Default)' ) }` }
</NavigationButtonAsItem>
);
}
return (
<NavigationButtonAsItem
key={ index }
path={
'/blocks/' +
encodeURIComponent( name ) +
'/variations/' +
encodeURIComponent( style.name )
}
aria-label={ style.label }
>
{ style.label }
</NavigationButtonAsItem>
);
} ) }
</ItemGroup>
);
}
Expand Down

1 comment on commit aac1e1b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3826707745
📝 Reported issues:

Please sign in to comment.