-
Notifications
You must be signed in to change notification settings - Fork 44
/
edit.js
173 lines (163 loc) · 4.81 KB
/
edit.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import { THEME_NAME, LIST_ICONS } from '../../helpers';
import { __ } from '@wordpress/i18n';
import {
InspectorControls,
InnerBlocks,
withColors,
PanelColorSettings,
withFontSizes,
useBlockProps,
} from '@wordpress/block-editor';
import { PanelBody, SelectControl } from '@wordpress/components';
import { Component, Fragment } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import classnames from 'classnames';
const ALLOWED_BLOCKS = [ 'core/list' ];
export function TabBoxEdit( props ) {
const {
attributes,
setAttributes,
className,
backgroundColor,
setBackgroundColor,
textColor,
setTextColor,
borderColor,
setBorderColor,
fontSize,
} = props;
const { label, customBackgroundColor, customTextColor, customBorderColor } =
attributes;
const classes = classnames( className, {
'blank-box': true,
'bb-tab': true,
[ label ]: !! label,
'block-box': true,
'has-text-color': textColor.color,
'has-background': backgroundColor.color,
'has-border-color': borderColor.color,
[ backgroundColor.class ]: backgroundColor.class,
[ textColor.class ]: textColor.class,
[ borderColor.class ]: borderColor.class,
[ fontSize.class ]: fontSize.class,
} );
const styles = {
'--cocoon-custom-border-color': customBorderColor || undefined,
'--cocoon-custom-background-color': customBackgroundColor || undefined,
'--cocoon-custom-text-color': customTextColor || undefined,
};
const blockProps = useBlockProps( {
className: classes,
style: styles,
} );
return (
<Fragment>
<InspectorControls>
<PanelBody title={ __( 'スタイル設定', THEME_NAME ) }>
<SelectControl
label={ __( 'ラベル', THEME_NAME ) }
value={ label }
onChange={ ( value ) => setAttributes( { label: value } ) }
options={ [
{
value: 'bb-check',
label: __( 'チェック', THEME_NAME ),
},
{
value: 'bb-comment',
label: __( 'コメント', THEME_NAME ),
},
{
value: 'bb-point',
label: __( 'ポイント', THEME_NAME ),
},
{
value: 'bb-tips',
label: __( 'ティップス', THEME_NAME ),
},
{
value: 'bb-hint',
label: __( 'ヒント', THEME_NAME ),
},
{
value: 'bb-pickup',
label: __( 'ピックアップ', THEME_NAME ),
},
{
value: 'bb-bookmark',
label: __( 'ブックマーク', THEME_NAME ),
},
{
value: 'bb-memo',
label: __( 'メモ', THEME_NAME ),
},
{
value: 'bb-download',
label: __( 'ダウンロード', THEME_NAME ),
},
{
value: 'bb-break',
label: __( 'ブレイク', THEME_NAME ),
},
{
value: 'bb-amazon',
label: __( 'Amazon', THEME_NAME ),
},
{
value: 'bb-ok',
label: __( 'OK', THEME_NAME ),
},
{
value: 'bb-ng',
label: __( 'NG', THEME_NAME ),
},
{
value: 'bb-good',
label: __( 'GOOD', THEME_NAME ),
},
{
value: 'bb-bad',
label: __( 'BAD', THEME_NAME ),
},
{
value: 'bb-profile',
label: __( 'プロフィール', THEME_NAME ),
},
] }
/>
</PanelBody>
<PanelColorSettings
title={ __( '色設定', THEME_NAME ) }
colorSettings={ [
{
label: __( 'ボーダー色', THEME_NAME ),
onChange: setBorderColor,
value: borderColor.color,
},
{
label: __( '背景色', THEME_NAME ),
onChange: setBackgroundColor,
value: backgroundColor.color,
},
{
label: __( '文字色', THEME_NAME ),
onChange: setTextColor,
value: textColor.color,
},
] }
__experimentalIsRenderedInSidebar={ true }
/>
</InspectorControls>
<div { ...blockProps }>
<InnerBlocks />
</div>
</Fragment>
);
}
export default compose( [
withColors( 'backgroundColor', {
textColor: 'color',
borderColor: 'border-color',
} ),
withFontSizes( 'fontSize' ),
] )( TabBoxEdit );