Skip to content

Commit

Permalink
template should include preferred style
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Apr 22, 2021
1 parent 4a5e07c commit 451a542
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/block-library/src/buttons/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import {
useBlockProps,
__experimentalUseInnerBlocksProps as useInnerBlocksProps,
JustifyContentControl,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import { name as buttonBlockName } from '../button';

const ALLOWED_BLOCKS = [ buttonBlockName ];
const BUTTONS_TEMPLATE = [ [ 'core/button' ] ];

function ButtonsEdit( {
attributes: { contentJustification, orientation },
Expand All @@ -31,9 +32,23 @@ function ButtonsEdit( {
'is-vertical': orientation === 'vertical',
} ),
} );
const preferredStyle = useSelect( ( select ) => {
const preferredStyleVariations = select(
blockEditorStore
).getSettings().__experimentalPreferredStyleVariations;
return preferredStyleVariations?.value?.[ 'core/button' ];
}, [] );

const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: ALLOWED_BLOCKS,
template: BUTTONS_TEMPLATE,
template: [
[
'core/button',
preferredStyle
? { className: `is-style-${ preferredStyle }` }
: {},
],
],
orientation,
__experimentalLayout: {
type: 'default',
Expand Down

0 comments on commit 451a542

Please sign in to comment.