Skip to content

Commit 2ed9e67

Browse files
committed
fix: remove removeIfDisabled, make icon required for notification
1 parent 93b3a13 commit 2ed9e67

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

src/block/notification/block.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"textdomain": "stackable-ultimate-gutenberg-blocks",
1616
"stk-type": "special",
1717
"stk-demo": "https://wpstackable.com/notification-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink",
18+
"stk-required-blocks": [
19+
"stackable/icon"
20+
],
1821
"stk-substitution-blocks": [
1922
"stackable/heading",
2023
"stackable/text",

src/block/notification/variations.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* External dependencies
33
*/
44
import { i18n, isPro } from 'stackable'
5-
import { removeChildIfDisabled } from '~stackable/util'
65

76
/**
87
* WordPress dependencies
@@ -38,7 +37,7 @@ const variations = applyFilters(
3837
pickerTitle: __( 'Default', i18n ),
3938
pickerIcon: ImageDefault,
4039
isActive: [ 'className' ],
41-
innerBlocks: removeChildIfDisabled( 'stackable/icon', [
40+
innerBlocks: [
4241
[ 'stackable/icon', {
4342
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>',
4443
iconColor1: '#FFFFFF',
@@ -63,7 +62,7 @@ const variations = applyFilters(
6362
},
6463
} ],
6564
] ],
66-
] ),
65+
],
6766
scope: [ 'block' ],
6867
},
6968
{
@@ -84,7 +83,7 @@ const variations = applyFilters(
8483
pickerTitle: __( 'Plain', i18n ),
8584
pickerIcon: ImagePlain,
8685
isActive: [ 'className' ],
87-
innerBlocks: removeChildIfDisabled( 'stackable/icon', [
86+
innerBlocks: [
8887
[ 'stackable/icon', {
8988
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>',
9089
iconColor1: 'var(--stk-container-background-color, #40ba7b)',
@@ -112,7 +111,7 @@ const variations = applyFilters(
112111
},
113112
} ],
114113
] ],
115-
] ),
114+
],
116115
scope: [ 'block' ],
117116
},
118117
{

src/util/blocks.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -547,21 +547,3 @@ export const substituteCoreIfDisabled = ( blockName, blockAttributes, innerBlock
547547
}
548548
return [ blockName, blockAttributes ]
549549
}
550-
551-
/**
552-
* Remove a given child block from a block tree definition if disabled
553-
*
554-
* @param {Array} blockName The block name of the child to remove
555-
* @param {Array} blockTree The array that contains the child block
556-
*
557-
* @return {Array} The resulting block tree definition
558-
*/
559-
export const removeChildIfDisabled = ( blockName, blockTree ) => {
560-
const disabled_blocks = stackableSettings.stackable_block_states || {} // eslint-disable-line camelcase
561-
562-
if ( blockName in disabled_blocks && disabled_blocks[ blockName ] === BLOCK_STATE.DISABLED ) { // eslint-disable-line camelcase
563-
return blockTree.filter( innerBlock => innerBlock[ 0 ] !== blockName )
564-
}
565-
566-
return blockTree
567-
}

0 commit comments

Comments
 (0)