-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathvariations.js
113 lines (110 loc) · 2.59 KB
/
variations.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { group, row, stack, grid } from '@wordpress/icons';
const example = {
innerBlocks: [
{
name: 'core/paragraph',
attributes: {
customTextColor: '#cf2e2e',
fontSize: 'large',
content: __( 'One.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#ff6900',
fontSize: 'large',
content: __( 'Two.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#fcb900',
fontSize: 'large',
content: __( 'Three.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#00d084',
fontSize: 'large',
content: __( 'Four.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#0693e3',
fontSize: 'large',
content: __( 'Five.' ),
},
},
{
name: 'core/paragraph',
attributes: {
customTextColor: '#9b51e0',
fontSize: 'large',
content: __( 'Six.' ),
},
},
],
};
const variations = [
{
name: 'group',
title: __( 'Group' ),
description: __( 'Gather blocks in a container.' ),
attributes: { layout: { type: 'constrained' } },
isDefault: true,
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
! blockAttributes.layout ||
! blockAttributes.layout?.type ||
blockAttributes.layout?.type === 'default' ||
blockAttributes.layout?.type === 'constrained',
icon: group,
},
{
name: 'group-row',
title: _x( 'Row', 'single horizontal line' ),
description: __( 'Arrange blocks horizontally.' ),
attributes: { layout: { type: 'flex', flexWrap: 'nowrap' } },
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'flex' &&
( ! blockAttributes.layout?.orientation ||
blockAttributes.layout?.orientation === 'horizontal' ),
icon: row,
example,
},
{
name: 'group-stack',
title: __( 'Stack' ),
description: __( 'Arrange blocks vertically.' ),
attributes: { layout: { type: 'flex', orientation: 'vertical' } },
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'flex' &&
blockAttributes.layout?.orientation === 'vertical',
icon: stack,
example,
},
{
name: 'group-grid',
title: __( 'Grid' ),
description: __( 'Arrange blocks in a grid.' ),
attributes: { layout: { type: 'grid' } },
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'grid',
icon: grid,
example,
},
];
export default variations;