Skip to content

Commit 4e55017

Browse files
committed
substitute(non-design): separator, tabs, timeline
1 parent 9f65930 commit 4e55017

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

src/block/divider/substitute.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export const substitute = {
22
from: 'stackable/divider',
3-
to: 'core/separator',
43
transform: () => {
54
return [
65
'core/separator',

src/block/separator/substitute.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const substitute = {
2+
from: 'stackable/separator',
3+
transform: () => {
4+
return [
5+
'core/separator',
6+
]
7+
},
8+
}
9+
10+
export default substitute

src/block/tabs/substitute.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export const substitute = {
2+
from: 'stackable/tabs',
3+
transform: ( oldAttributes, innerBlocks ) => {
4+
const labels = innerBlocks[ 0 ][ 1 ]?.tabLabels
5+
const contents = innerBlocks[ 1 ][ 2 ]
6+
7+
const insideBlocks = []
8+
9+
labels.forEach( ( label, index ) => {
10+
insideBlocks.push( [ 'stackable/heading', { text: label?.label } ] )
11+
if ( contents[ index ] ) {
12+
insideBlocks.push( contents[ index ] )
13+
}
14+
} )
15+
16+
return [
17+
'stackable/columns',
18+
{
19+
...oldAttributes,
20+
},
21+
[ [ 'stackable/column', {}, insideBlocks ] ],
22+
]
23+
},
24+
}
25+
26+
export default substitute

src/block/timeline/substitute.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const substitute = {
2+
from: 'stackable/timeline',
3+
transform: ( oldAttributes, innerBlocks ) => {
4+
const formattedDate = new Date().toLocaleDateString( 'en-US', {
5+
month: 'short',
6+
day: '2-digit',
7+
year: 'numeric',
8+
} )
9+
return [
10+
'stackable/columns',
11+
{
12+
...oldAttributes,
13+
},
14+
[
15+
[ 'stackable/column', {}, innerBlocks ],
16+
[ 'stackable/column', {}, [
17+
[ 'stackable/text', { text: formattedDate } ],
18+
] ],
19+
],
20+
]
21+
},
22+
}
23+
24+
export default substitute

0 commit comments

Comments
 (0)