Skip to content

Commit 0fce075

Browse files
added accordion and cta
1 parent 00adbdf commit 0fce075

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

src/block/accordion/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import metadata from './block.json'
1717
import variations from './variations'
1818
import example from './example'
1919
import deprecated from './deprecated'
20+
import substitute from './substitute'
2021

2122
/**
2223
* WordPress dependencies
@@ -39,4 +40,5 @@ export const settings = {
3940
variations,
4041
edit,
4142
save,
43+
substitute,
4244
}

src/block/accordion/substitute.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const substitute = {
2+
from: 'stackable/accordion',
3+
variations: [ 'stackable/accordion' ],
4+
to: 'core/details',
5+
transform: ( oldAttributes, innerBlocks ) => {
6+
// Get the heading
7+
const heading = innerBlocks[ 0 ][ 2 ][ 0 ][ 2 ][ 0 ][ 1 ].text
8+
const insideBlocks = innerBlocks[ 1 ][ 2 ]
9+
10+
return [
11+
'core/details',
12+
{
13+
open: false,
14+
summary: heading,
15+
},
16+
[ insideBlocks ],
17+
]
18+
},
19+
}
20+
21+
export default substitute

src/block/call-to-action/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import save from './save'
1111
import schema from './schema'
1212
import example from './example'
1313
import deprecated from './deprecated'
14+
import substitute from './substitute'
1415

1516
/**
1617
* External dependencies
@@ -40,4 +41,5 @@ export const settings = {
4041
deprecated,
4142
edit,
4243
save,
44+
substitute,
4345
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const substitute = {
2+
from: 'stackable/call-to-action',
3+
variants: [ 'stackable/call-to-action' ],
4+
to: [ 'stackable/columns' ],
5+
transform: ( oldAttributes, innerBlocks ) => {
6+
return [
7+
'stackable/columns',
8+
{
9+
// TODO: See if passing the entire oldAttributes works.
10+
...oldAttributes,
11+
// hasBackground: oldAttributes.hasBackground,
12+
// blockBackgroundMediaUrl: oldAttributes.blockBackgroundMediaUrl,
13+
// align: oldAttributes.align,
14+
// contentAlign: oldAttributes.contentAlign,
15+
// innerBlockContentAlign: oldAttributes.innerBlockContentAlign,
16+
// blockHeight: oldAttributes.blockHeight,
17+
// blockVerticalAlign: oldAttributes.blockVerticalAlign,
18+
// hasContainer: oldAttributes.hasContainer,
19+
},
20+
[ 'stackable/column', {}, innerBlocks ],
21+
]
22+
},
23+
}
24+
25+
export default substitute

0 commit comments

Comments
 (0)