From e3d93066e50df752b461b87603b1a1a4232ee9e3 Mon Sep 17 00:00:00 2001 From: Thomas Gollenia Date: Fri, 2 Feb 2024 17:04:22 +0100 Subject: [PATCH] auto spacer fix --- src/blocks/card/editor.scss | 2 +- src/common/styles/editor.scss | 5 ++ src/index.js | 1 + src/mods/listClass.js | 21 +++++++ src/mods/postTitleProps.js | 112 ---------------------------------- src/mods/spacerAutoOption.js | 5 +- 6 files changed, 31 insertions(+), 115 deletions(-) create mode 100644 src/mods/listClass.js delete mode 100644 src/mods/postTitleProps.js diff --git a/src/blocks/card/editor.scss b/src/blocks/card/editor.scss index 0a669c2..f4b0d0f 100644 --- a/src/blocks/card/editor.scss +++ b/src/blocks/card/editor.scss @@ -65,7 +65,7 @@ } } - &__content { + &-content { padding: 15px; position: relative; flex: 1; diff --git a/src/common/styles/editor.scss b/src/common/styles/editor.scss index e159a80..ee04408 100644 --- a/src/common/styles/editor.scss +++ b/src/common/styles/editor.scss @@ -38,3 +38,8 @@ .has-primary-background-color { background-color: var(--primary) !important; } + +.ctx-auto-spacer { + flex: 1; + height: auto !important; +} diff --git a/src/index.js b/src/index.js index d16e45e..904c915 100644 --- a/src/index.js +++ b/src/index.js @@ -22,6 +22,7 @@ import * as inlineSvg from './blocks/svg'; /** * Core Block modification dependencies. */ + import './mods/paragraphJustify'; import './mods/scrollAnimation'; import './mods/spacerAutoOption'; diff --git a/src/mods/listClass.js b/src/mods/listClass.js new file mode 100644 index 0000000..18db04a --- /dev/null +++ b/src/mods/listClass.js @@ -0,0 +1,21 @@ +const { createHigherOrderComponent } = wp.compose; +const { InspectorControls, URLInput } = wp.blockEditor; +const { PanelBody, TextControl, RadioControl } = wp.components; +const { addFilter } = wp.hooks; +const { __ } = wp.i18n; + +const addListClass = (props, name) => { + if (name !== 'core/post-title') { + return props; + } + + const attributes = { + ...props.attributes, + }; + + attributes.className = 'core-block'; + + return { ...props, attributes }; +}; + +addFilter('blocks.registerBlockType', 'ctx-blocks/list', addListClass); diff --git a/src/mods/postTitleProps.js b/src/mods/postTitleProps.js deleted file mode 100644 index 90e1d08..0000000 --- a/src/mods/postTitleProps.js +++ /dev/null @@ -1,112 +0,0 @@ -const { createHigherOrderComponent } = wp.compose; -const { InspectorControls, URLInput } = wp.blockEditor; -const { PanelBody, TextControl, RadioControl } = wp.components; -const { addFilter } = wp.hooks; -const { __ } = wp.i18n; - -const addPostTitleAttribute = ( props, name ) => { - if ( name !== 'core/post-title' ) { - return props; - } - - const attributes = { - ...props.attributes, - linkTitle: { - type: 'string', - default: '', - }, - url: { - type: 'string', - default: '', - }, - linkIcon: { - type: 'string', - default: '', - }, - linkIconOrientation: { - type: 'string', - default: 'right', - }, - }; - - return { ...props, attributes }; -}; - -addFilter( - 'blocks.registerBlockType', - 'ctx-blocks/title', - addPostTitleAttribute -); - -const withPostTitleControl = createHigherOrderComponent( ( BlockEdit ) => { - return ( props ) => { - if ( props.name !== 'core/post-title' ) { - return ; - } - - const { attributes, setAttributes } = props; - const { linkTitle, linkIcon, linkIconOrientation, url } = attributes; - - return ( - <> - - - - - setAttributes( { - url, - text: - ( post && post.title ) || - __( 'Click here', 'ctx-blocks' ), - } ) - } - /> - { - setAttributes( { linkTitle: value } ); - } } - value={ linkTitle } - /> - { - setAttributes( { linkIcon: value } ); - } } - value={ linkIcon } - /> - - - setAttributes( { linkIconOrientation: value } ) - } - /> - - - - ); - }; -}, 'withPostTitleControl' ); - -addFilter( 'editor.BlockEdit', 'ctx-blocks/title', withPostTitleControl ); diff --git a/src/mods/spacerAutoOption.js b/src/mods/spacerAutoOption.js index 653758c..a4c7741 100644 --- a/src/mods/spacerAutoOption.js +++ b/src/mods/spacerAutoOption.js @@ -38,7 +38,7 @@ const withAutoMarginControl = createHigherOrderComponent((BlockEdit) => { const { attributes, setAttributes } = props; const { autoMargin } = attributes; - + console.log(attributes); return ( @@ -49,12 +49,13 @@ const withAutoMarginControl = createHigherOrderComponent((BlockEdit) => { > { setAttributes({ autoMargin: value }); + setAttributes({ className: 'ctx-auto-spacer' }); }} />