diff --git a/blocks/src/block/button/block.json b/blocks/src/block/button/block.json
index d8076c022..fe755d8e3 100644
--- a/blocks/src/block/button/block.json
+++ b/blocks/src/block/button/block.json
@@ -52,6 +52,9 @@
},
"fontSize": {
"type": "string"
+ },
+ "width": {
+ "type": "string"
}
},
"example": {
diff --git a/blocks/src/block/button/edit.js b/blocks/src/block/button/edit.js
index 1c52a6e7c..70f2d68e4 100644
--- a/blocks/src/block/button/edit.js
+++ b/blocks/src/block/button/edit.js
@@ -14,6 +14,8 @@ import {
SelectControl,
TextControl,
ToggleControl,
+ Button,
+ ButtonGroup,
} from '@wordpress/components';
import { Fragment } from '@wordpress/element';
import { compose } from '@wordpress/compose';
@@ -45,6 +47,7 @@ export function ButtonEdit( props ) {
customBackgroundColor,
customTextColor,
customBorderColor,
+ width,
} = attributes;
const classes = classnames( className, {
@@ -57,6 +60,35 @@ export function ButtonEdit( props ) {
'--cocoon-custom-text-color': customTextColor || undefined,
};
+ function WidthPanel( { selectedWidth, setAttributes } ) {
+ function handleChange( newWidth ) {
+ // Check if we are toggling the width off
+ const width = selectedWidth === newWidth ? undefined : newWidth;
+
+ // Update attributes
+ setAttributes( { width } );
+ }
+
+ return (
+
+
+ { [ 25, 50, 75, 100 ].map( ( widthValue ) => {
+ return (
+
+ );
+ } ) }
+
+
+ );
+ }
+
const blockProps = useBlockProps( {
className: classes,
style: styles,
@@ -121,6 +153,8 @@ export function ButtonEdit( props ) {
/>
+
+