diff --git a/lib/patterns/two-buttons.php b/lib/patterns/two-buttons.php index 90564c4c30487d..8cd24997ce20ed 100644 --- a/lib/patterns/two-buttons.php +++ b/lib/patterns/two-buttons.php @@ -7,7 +7,7 @@ return array( 'title' => __( 'Two buttons', 'gutenberg' ), - 'content' => "\n
\n", + 'content' => "\n \n", 'viewportWidth' => 500, 'categories' => array( 'buttons' ), 'description' => _x( 'Two buttons, one filled and one outlined, side by side.', 'Block pattern description', 'gutenberg' ), diff --git a/packages/block-library/src/buttons/block.json b/packages/block-library/src/buttons/block.json index a1e4c33c2ed3eb..b534316ce8f970 100644 --- a/packages/block-library/src/buttons/block.json +++ b/packages/block-library/src/buttons/block.json @@ -2,9 +2,13 @@ "apiVersion": 2, "name": "core/buttons", "category": "design", + "attributes": { + "contentJustification": { + "type": "string" + } + }, "supports": { "anchor": true, - "align": true, - "alignWide": false + "align": [ "wide", "full" ] } } diff --git a/packages/block-library/src/buttons/content-justification-dropdown.js b/packages/block-library/src/buttons/content-justification-dropdown.js new file mode 100644 index 00000000000000..10c02c5524bfa6 --- /dev/null +++ b/packages/block-library/src/buttons/content-justification-dropdown.js @@ -0,0 +1,73 @@ +/** + * WordPress dependencies + */ +import { DropdownMenu } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import { + contentJustificationCenterIcon, + contentJustificationLeftIcon, + contentJustificationRightIcon, +} from './icons'; + +const DEFAULT_ALLOWED_VALUES = [ 'left', 'center', 'right' ]; + +const CONTROLS = { + left: { + icon: contentJustificationLeftIcon, + title: __( 'Justify content left' ), + }, + center: { + icon: contentJustificationCenterIcon, + title: __( 'Justify content center' ), + }, + right: { + icon: contentJustificationRightIcon, + title: __( 'Justify content right' ), + }, +}; + +const DEFAULT_ICON = CONTROLS.center.icon; + +/** + * Dropdown for selecting a content justification option. + * + * @param {Object} props Component props. + * @param {string[]} [props.allowedValues] List of options to include. Default: + * ['left', 'center', 'right']. + * @param {()=>void} props.onChange Callback to run when an option is + * selected in the dropdown. + * @param {Object} props.toggleProps Props to pass to the dropdown toggle. + * @param {string} props.value The current content justification + * value. + * + * @return {WPComponent} The component. + */ +export default function ContentJustificationDropdown( { + onChange, + allowedValues = DEFAULT_ALLOWED_VALUES, + toggleProps, + value, +} ) { + return ( +