From 56551e1928353b692a65b6862bb87a5006cfa491 Mon Sep 17 00:00:00 2001 From: Alquen Antonio Sarmiento Date: Thu, 24 Oct 2024 13:02:31 +0800 Subject: [PATCH] feat: first batch of core substitution and removal integration --- src/block/accordion/variations.js | 11 ++++---- src/block/card/variations.js | 34 +++++++++++++++--------- src/block/image-box/variations.js | 17 ++++++------ src/block/notification/variations.js | 39 ++++++++++++++-------------- src/block/timeline/edit.js | 5 ++-- 5 files changed, 60 insertions(+), 46 deletions(-) diff --git a/src/block/accordion/variations.js b/src/block/accordion/variations.js index 591025296..c69d7a3b7 100644 --- a/src/block/accordion/variations.js +++ b/src/block/accordion/variations.js @@ -13,12 +13,13 @@ import ImagePlus from './images/plus.svg' import { __, _x, sprintf, } from '@wordpress/i18n' +import { applyFilters } from '@wordpress/hooks' /** * External dependencies */ import { i18n, isPro } from 'stackable' -import { applyFilters } from '@wordpress/hooks' +import { substituteCoreIfDisabled } from '~stackable/util' export const defaultIcon = '' @@ -56,9 +57,9 @@ const variations = applyFilters( ] ], ] ], [ 'stackable/column', { templateLock: false, className: 'stk-block-accordion__content' }, [ - [ 'stackable/text', { + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ), - } ], + } ), ] ], ], scope: [ 'block' ], @@ -102,9 +103,9 @@ const variations = applyFilters( top: 0, right: 0, bottom: 0, left: 0, }, }, [ - [ 'stackable/text', { + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ), - } ], + } ), ] ], ], scope: [ 'block' ], diff --git a/src/block/card/variations.js b/src/block/card/variations.js index a93871140..68a171751 100644 --- a/src/block/card/variations.js +++ b/src/block/card/variations.js @@ -11,6 +11,7 @@ import ImageFaded from './images/faded.svg' * External dependencies */ import { i18n, isPro } from 'stackable' +import { substituteCoreIfDisabled, substituteIfDisabled } from '~stackable/util' /** * WordPress dependencies @@ -49,12 +50,12 @@ const variations = applyFilters( pickerTitle: __( 'Default', i18n ), pickerIcon: ImageDefault, innerBlocks: [ - [ 'stackable/heading', {} ], - [ 'stackable/subtitle', { text: _x( 'Subtitle for This Block', 'Subtitle placeholder', i18n ) } ], - [ 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ], - [ 'stackable/button-group', {}, [ - [ 'stackable/button', { text: _x( 'Button', 'Button placeholder', i18n ) } ], - ] ], + substituteCoreIfDisabled( 'stackable/heading', {} ), + substituteCoreIfDisabled( 'stackable/subtitle', { text: _x( 'Subtitle for This Block', 'Subtitle placeholder', i18n ) } ), + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ), + substituteCoreIfDisabled( 'stackable/button-group', {}, [ + substituteCoreIfDisabled( 'stackable/button', { text: _x( 'Button', 'Button placeholder', i18n ) } ), + ] ), ], scope: [ 'block' ], }, @@ -79,8 +80,8 @@ const variations = applyFilters( pickerTitle: __( 'Default 2', i18n ), pickerIcon: ImageDefault2, innerBlocks: [ - [ 'stackable/heading', {} ], - [ 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ], + substituteCoreIfDisabled( 'stackable/heading', {} ), + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ), [ 'stackable/columns', { rowAlign: 'center', innerBlockContentAlign: 'alignfull', @@ -94,9 +95,9 @@ const variations = applyFilters( left: 0, }, }, [ - [ 'stackable/button-group', {}, [ - [ 'stackable/button', { text: _x( 'Button', 'Button placeholder', i18n ) } ], - ] ], + substituteCoreIfDisabled( 'stackable/button-group', {}, [ + substituteCoreIfDisabled( 'stackable/button', { text: _x( 'Button', 'Button placeholder', i18n ) } ), + ] ), ] ], [ 'stackable/column', { columnSpacing: { @@ -105,7 +106,7 @@ const variations = applyFilters( bottom: 0, left: 0, }, - }, [ + }, [ substituteIfDisabled( [ 'stackable/button-group|social-buttons', 'stackable/button-group|icon-button' ], [ 'stackable/button-group', { columnSpacing: { top: 0, @@ -132,6 +133,15 @@ const variations = applyFilters( className: 'is-style-plain', } ], ] ], + [ 'core/social-links', + { + align: 'right', + }, + [ + [ 'core/social-link', { service: 'facebook' } ], + [ 'core/social-link', { service: 'twitter' } ], + ], + ] ), ] ], ] ], ], diff --git a/src/block/image-box/variations.js b/src/block/image-box/variations.js index 8bf382934..47a06ef6b 100644 --- a/src/block/image-box/variations.js +++ b/src/block/image-box/variations.js @@ -20,6 +20,7 @@ import { applyFilters } from '@wordpress/hooks' * External dependencies */ import { i18n, isPro } from 'stackable' +import { substituteCoreIfDisabled } from '~stackable/util' /** * Template option choices for predefined columns layouts. @@ -53,13 +54,13 @@ const variations = applyFilters( textColor1: '#FFFFFF', opacityParentHover: 1, } ], - [ 'stackable/heading', { + substituteCoreIfDisabled( 'stackable/heading', { text: _x( 'Title for This Block', 'Heading placeholder', i18n ), textTag: 'h4', textColorClass: 'has-white-color', textColor1: '#FFFFFF', - } ], - [ 'stackable/text', { + } ), + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Text for This Block', 'Text placeholder', i18n ), opacity: 0, transform: 'translateY(-24px)', @@ -67,7 +68,7 @@ const variations = applyFilters( transformParentHover: 'translateY(0px)', textColorClass: 'has-white-color', textColor1: '#FFFFFF', - } ], + } ), [ 'stackable/icon', { blockMargin: { top: 56 }, opacity: 0, @@ -108,21 +109,21 @@ const variations = applyFilters( textColorClass: 'has-white-color', textColor1: '#FFFFFF', } ], - [ 'stackable/heading', { + substituteCoreIfDisabled( 'stackable/heading', { text: _x( 'Title for This Block', 'Heading placeholder', i18n ), textTag: 'h4', transform: 'translateY(32px)', transformParentHover: 'translateY(0px)', textColorClass: 'has-white-color', textColor1: '#FFFFFF', - } ], - [ 'stackable/text', { + } ), + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Text for This Block', 'Text placeholder', i18n ), opacity: 0, opacityParentHover: 1, textColorClass: 'has-white-color', textColor1: '#FFFFFF', - } ], + } ), [ 'stackable/icon', { opacity: 0, transform: 'translateY(-32px)', diff --git a/src/block/notification/variations.js b/src/block/notification/variations.js index 84a7cb1c5..cb5b6d79a 100644 --- a/src/block/notification/variations.js +++ b/src/block/notification/variations.js @@ -2,6 +2,7 @@ * External dependencies */ import { i18n, isPro } from 'stackable' +import { substituteCoreIfDisabled, removeChildIfDisabled } from '~stackable/util' /** * WordPress dependencies @@ -37,17 +38,17 @@ const variations = applyFilters( pickerTitle: __( 'Default', i18n ), pickerIcon: ImageDefault, isActive: [ 'className' ], - innerBlocks: [ + innerBlocks: removeChildIfDisabled( 'stackable/icon', [ [ 'stackable/icon', { icon: '', iconColor1: '#FFFFFF', } ], - [ 'stackable/heading', { + substituteCoreIfDisabled( 'stackable/heading', { text: _x( 'Title for This Block', 'Heading placeholder', i18n ), textTag: 'h3', - } ], - [ 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ], - [ 'stackable/button-group', {}, [ - [ 'stackable/button', { + } ), + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ), + substituteCoreIfDisabled( 'stackable/button-group', {}, [ + substituteCoreIfDisabled( 'stackable/button', { text: _x( 'Button', 'Button placeholder', i18n ), buttonBackgroundColor: 'transparent', buttonBorderType: 'solid', @@ -60,9 +61,9 @@ const variations = applyFilters( bottom: 1, left: 1, }, - } ], - ] ], - ], + } ), + ] ), + ] ), scope: [ 'block' ], }, { @@ -83,21 +84,21 @@ const variations = applyFilters( pickerTitle: __( 'Plain', i18n ), pickerIcon: ImagePlain, isActive: [ 'className' ], - innerBlocks: [ + innerBlocks: removeChildIfDisabled( 'stackable/icon', [ [ 'stackable/icon', { icon: '', iconColor1: 'var(--stk-container-background-color, #40ba7b)', } ], - [ 'stackable/heading', { + substituteCoreIfDisabled( 'stackable/heading', { text: _x( 'Title for This Block', 'Heading placeholder', i18n ), textTag: 'h3', textColor1: 'var(--stk-container-background-color, #40ba7b)', - } ], - [ 'stackable/text', { + } ), + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ), textColor1: 'var(--stk-container-background-color, #40ba7b)', - } ], - [ 'stackable/button-group', {}, [ - [ 'stackable/button', { + } ), + substituteCoreIfDisabled( 'stackable/button-group', {}, [ + substituteCoreIfDisabled( 'stackable/button', { text: _x( 'Button', 'Button placeholder', i18n ), buttonBackgroundColor: 'transparent', buttonBorderType: 'solid', @@ -109,9 +110,9 @@ const variations = applyFilters( bottom: 1, left: 1, }, - } ], - ] ], - ], + } ), + ] ), + ] ), scope: [ 'block' ], }, { diff --git a/src/block/timeline/edit.js b/src/block/timeline/edit.js index b5edcf3f3..e895076c6 100644 --- a/src/block/timeline/edit.js +++ b/src/block/timeline/edit.js @@ -42,6 +42,7 @@ import { withQueryLoopContext, } from '~stackable/higher-order' import { range } from 'lodash' +import { substituteCoreIfDisabled } from '~stackable/util' /** * WordPress dependencies @@ -68,9 +69,9 @@ const TEMPLATE = [ left: 0, }, }, [ - [ 'stackable/text', { + substituteCoreIfDisabled( 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do.', 'Content placeholder', i18n ), - } ], + } ), ] ], ]