-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathsubstitute.js
More file actions
26 lines (24 loc) · 1.02 KB
/
substitute.js
File metadata and controls
26 lines (24 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { BLOCK_STATE } from '~stackable/util'
export const substitute = {
from: 'stackable/button-group',
variants: [ 'stackable/button-group|icon-button', 'stackable/button-group|button' ],
transform: ( oldAttributes, innerBlocks, disabledBlocks ) => {
if ( 'stackable/button-group|icon-button' in disabledBlocks && disabledBlocks[ 'stackable/button-group|icon-button' ] === BLOCK_STATE.DISABLED && // eslint-disable-line camelcase
innerBlocks.length &&
innerBlocks[ 0 ][ 0 ] === 'stackable/icon-button'
) {
return [ 'core/social-links',
{ align: oldAttributes.contentAlign },
[
[ 'core/social-link', { service: 'facebook' } ],
[ 'core/social-link', { service: 'twitter' } ],
],
]
}
if ( 'stackable/button-group|button' in disabledBlocks && disabledBlocks[ 'stackable/button-group|button' ] === BLOCK_STATE.DISABLED ) { // eslint-disable-line camelcase
return [ 'core/buttons', {}, innerBlocks ]
}
return [ 'stackable/button-group', oldAttributes, innerBlocks ]
},
}
export default substitute