Skip to content

Commit

Permalink
feat: first batch of core substitution and removal integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Arukuen committed Oct 24, 2024
1 parent 1354cb9 commit 56551e1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 46 deletions.
11 changes: 6 additions & 5 deletions src/block/accordion/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<svg data-prefix="fas" data-icon="chevron-down" class="svg-inline--fa fa-chevron-down fa-w-14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"></path></svg>'

Expand Down Expand Up @@ -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' ],
Expand Down Expand Up @@ -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' ],
Expand Down
34 changes: 22 additions & 12 deletions src/block/card/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' ],
},
Expand All @@ -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',
Expand All @@ -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: {
Expand All @@ -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,
Expand All @@ -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' } ],
],
] ),
] ],
] ],
],
Expand Down
17 changes: 9 additions & 8 deletions src/block/image-box/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -53,21 +54,21 @@ 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)',
opacityParentHover: 1,
transformParentHover: 'translateY(0px)',
textColorClass: 'has-white-color',
textColor1: '#FFFFFF',
} ],
} ),
[ 'stackable/icon', {
blockMargin: { top: 56 },
opacity: 0,
Expand Down Expand Up @@ -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)',
Expand Down
39 changes: 20 additions & 19 deletions src/block/notification/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { i18n, isPro } from 'stackable'
import { substituteCoreIfDisabled, removeChildIfDisabled } from '~stackable/util'

/**
* WordPress dependencies
Expand Down Expand Up @@ -37,17 +38,17 @@ const variations = applyFilters(
pickerTitle: __( 'Default', i18n ),
pickerIcon: ImageDefault,
isActive: [ 'className' ],
innerBlocks: [
innerBlocks: removeChildIfDisabled( 'stackable/icon', [
[ 'stackable/icon', {
icon: '<svg data-prefix="fas" data-icon="exclamation-triangle" class="svg-inline--fa fa-exclamation-triangle fa-w-18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" aria-hidden="true" width="32" height="32"><path fill="currentColor" d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"></path></svg>',
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',
Expand All @@ -60,9 +61,9 @@ const variations = applyFilters(
bottom: 1,
left: 1,
},
} ],
] ],
],
} ),
] ),
] ),
scope: [ 'block' ],
},
{
Expand All @@ -83,21 +84,21 @@ const variations = applyFilters(
pickerTitle: __( 'Plain', i18n ),
pickerIcon: ImagePlain,
isActive: [ 'className' ],
innerBlocks: [
innerBlocks: removeChildIfDisabled( 'stackable/icon', [
[ 'stackable/icon', {
icon: '<svg data-prefix="fas" data-icon="exclamation-triangle" class="svg-inline--fa fa-exclamation-triangle fa-w-18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" aria-hidden="true" width="32" height="32"><path fill="currentColor" d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"></path></svg>',
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',
Expand All @@ -109,9 +110,9 @@ const variations = applyFilters(
bottom: 1,
left: 1,
},
} ],
] ],
],
} ),
] ),
] ),
scope: [ 'block' ],
},
{
Expand Down
5 changes: 3 additions & 2 deletions src/block/timeline/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
withQueryLoopContext,
} from '~stackable/higher-order'
import { range } from 'lodash'
import { substituteCoreIfDisabled } from '~stackable/util'

/**
* WordPress dependencies
Expand All @@ -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 ),
} ],
} ),
] ],
]

Expand Down

0 comments on commit 56551e1

Please sign in to comment.