From 5a3d5f96b2c9727f6e84b2899073a4e0c77b42ef Mon Sep 17 00:00:00 2001 From: inc2734 Date: Wed, 3 Jul 2024 23:23:46 +0900 Subject: [PATCH] fix #796 --- src/blocks/box/block.json | 8 +++--- src/blocks/box/deprecated.js | 16 ++++++++++++ src/blocks/box/edit.js | 50 ++---------------------------------- src/blocks/box/save.js | 7 ++--- src/blocks/box/style.scss | 2 ++ 5 files changed, 25 insertions(+), 58 deletions(-) diff --git a/src/blocks/box/block.json b/src/blocks/box/block.json index 26ea2ee2..96cb3ab5 100644 --- a/src/blocks/box/block.json +++ b/src/blocks/box/block.json @@ -1,6 +1,7 @@ { "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, + "version": "21.0.0", "textdomain": "snow-monkey-blocks", "name": "snow-monkey-blocks/box", "title": "Box", @@ -33,10 +34,6 @@ "type": "number", "default": 1 }, - "contentPadding": { - "type": "string", - "default": "" - }, "boxShadow": { "type": "object", "default": { @@ -57,7 +54,8 @@ "supports": { "html": false, "spacing": { - "margin": true + "margin": true, + "padding": true }, "layout": { "allowSwitching": false, diff --git a/src/blocks/box/deprecated.js b/src/blocks/box/deprecated.js index 19a3c470..39b947b1 100644 --- a/src/blocks/box/deprecated.js +++ b/src/blocks/box/deprecated.js @@ -22,6 +22,10 @@ export default [ borderRadius: { type: 'number', }, + contentPadding: { + type: 'string', + default: '', + }, }, supports: { @@ -92,6 +96,10 @@ export default [ borderWidth: { type: 'number', }, + contentPadding: { + type: 'string', + default: '', + }, }, supports: { @@ -168,6 +176,10 @@ export default [ borderWidth: { type: 'number', }, + contentPadding: { + type: 'string', + default: '', + }, }, save( { attributes, className } ) { @@ -201,6 +213,10 @@ export default [ borderWidth: { type: 'number', }, + contentPadding: { + type: 'string', + default: '', + }, }, save( { attributes } ) { diff --git a/src/blocks/box/edit.js b/src/blocks/box/edit.js index 97e39a98..255d8f49 100644 --- a/src/blocks/box/edit.js +++ b/src/blocks/box/edit.js @@ -15,7 +15,6 @@ import { import { RangeControl, - SelectControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalBorderBoxControl as BorderBoxControl, @@ -29,7 +28,7 @@ import { toNumber } from '@smb/helper'; import metadata from './block.json'; -export default function ( { attributes, setAttributes, className, clientId } ) { +export default function ( { attributes, setAttributes, clientId } ) { const { backgroundColor, backgroundGradientColor, @@ -39,7 +38,6 @@ export default function ( { attributes, setAttributes, className, clientId } ) { borderWidth, borderRadius, opacity, - contentPadding, boxShadow, templateLock, } = attributes; @@ -74,9 +72,7 @@ export default function ( { attributes, setAttributes, className, clientId } ) { : borderWidth, }; - const classes = classnames( 'smb-box', className, { - [ `smb-box--p-${ contentPadding }` ]: !! contentPadding, - } ); + const classes = classnames( 'smb-box' ); const blockProps = useBlockProps( { className: classes, @@ -315,48 +311,6 @@ export default function ( { attributes, setAttributes, className, clientId } ) { /> - - - contentPadding !== - metadata.attributes.contentPadding.default - } - isShownByDefault - label={ __( 'Padding', 'snow-monkey-blocks' ) } - onDeselect={ () => - setAttributes( { - contentPadding: - metadata.attributes.contentPadding.default, - } ) - } - panelId={ clientId } - > - - setAttributes( { - contentPadding: value, - } ) - } - /> - - -
diff --git a/src/blocks/box/save.js b/src/blocks/box/save.js index a924ccc8..af29720a 100644 --- a/src/blocks/box/save.js +++ b/src/blocks/box/save.js @@ -3,7 +3,7 @@ import hexToRgba from 'hex-to-rgba'; import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor'; -export default function ( { attributes, className } ) { +export default function ( { attributes } ) { const { backgroundColor, backgroundGradientColor, @@ -13,7 +13,6 @@ export default function ( { attributes, className } ) { borderWidth, borderRadius, opacity, - contentPadding, boxShadow, } = attributes; @@ -40,9 +39,7 @@ export default function ( { attributes, className } ) { : borderWidth, }; - const classes = classnames( 'smb-box', className, { - [ `smb-box--p-${ contentPadding }` ]: !! contentPadding, - } ); + const classes = classnames( 'smb-box' ); return (