PluginProbe ʕ •ᴥ•ʔ
VK Blocks / 1.26.2
VK Blocks v1.26.2
1.126.4 1.126.3 1.126.1 1.126.2 1.126.0 1.125.0 1.124.0 1.123.0 1.122.0 1.121.0 1.120.0 1.119.2 1.119.1 1.119.0 1.118.7 1.82.0.0 1.82.0.1 1.83.0.0 1.83.0.1 1.84.0.0 1.84.0.1 1.85.0.2 1.85.0.3 1.85.1.0 1.85.1.1 1.86.0.0 1.86.0.1 1.86.1.0 1.87.0.0 1.87.0.1 1.88.0.1 1.88.0.2 1.89.0.0 1.9.2 1.90.0.0 1.90.0.1 1.90.1.1 1.91.0.0 1.91.1.1 1.92.0.0 1.92.0.1 1.92.1.0 1.92.1.1 1.93.0.0 trunk 1.93.0.1 0.1.1 1.93.1.0 0.10.3 1.93.1.1 0.11.0 1.94.0.0 0.12.6 1.94.0.1 0.15.1 1.94.1.0 0.16.2 1.94.2.1 0.17.6 1.94.2.2 0.2.2 1.95.0.3 0.22.4 1.95.0.4 0.26.7 1.96.2.0 0.3.2 1.96.2.1 0.31.0 1.97.0.1 0.35.5 1.97.0.2 0.37.5 1.99.0.0 0.38.8 1.99.0.1 0.39.4 0.4.7 0.41.0 0.42.0 0.44.13 0.45.2 0.46.1 0.47.0 0.48.0 0.49.8 0.5.2 0.50.3 0.51.0 0.52.2 0.53.2 0.54.0 0.55.0 0.56.2 0.56.3 0.57.6 0.58.10 0.59.0 0.6.0 0.60.1 0.61.2 0.7.1 0.8.2 1.0.16 1.10.0 1.100.0.0 1.100.0.1 1.102.0.0 1.102.0.1 1.103.0.0 1.104.0.0 1.104.0.1 1.105.1.0 1.105.1.1 1.106.0.0 1.106.0.1 1.107.0.0 1.107.0.1 1.107.0.2 1.108.0.0 1.108.0.1 1.109.0.0 1.109.0.1 1.11.4 1.110.0.0 1.110.0.1 1.111.0.0 1.111.0.1 1.111.0.2 1.112.0.0 1.112.0.1 1.113.0.0 1.113.0.1 1.114.0.0 1.114.0.1 1.114.2.0 1.114.2.1 1.115.0.0 1.115.0.1 1.115.1.0 1.115.1.1 1.115.2.0 1.115.2.1 1.116.0.0 1.116.0.1 1.116.1.0 1.116.1.1 1.116.2.0 1.117.0.0 1.117.0.1 1.117.1.0 1.118.2 1.118.5 1.12.0 1.13.2 1.14.1 1.15.1 1.16.11 1.17.0 1.18.6 1.19.0 1.19.1 1.2.3 1.20.7 1.21.0 1.22.4 1.23.0 1.24.5 1.25.1 1.26.2 1.27.7.2 1.28.0.1 1.29.2.0 1.3.9 1.30.0.1 1.31.0.1 1.32.0.2 1.33.2.1 1.36.1.5 1.37.0.0 1.39.2.1 1.4.6 1.40.0.1 1.40.1.0 1.40.1.1 1.41.0.0 1.41.0.1 1.41.2.2 1.41.2.3 1.43.0.0 1.43.0.1 1.43.0.2 1.44.0.0 1.44.0.1 1.45.0.0 1.45.0.1 1.46.0.0 1.46.0.1 1.47.0.0 1.47.0.1 1.47.1.0 1.48.0.0 1.48.0.1 1.48.0.2 1.48.1.0 1.48.1.1 1.5.0 1.50.0.0 1.50.0.1 1.51.0.0 1.51.0.1 1.52.0.0 1.52.0.1 1.53.0.0 1.53.0.1 1.54.0.0 1.54.0.1 1.55.0.0 1.55.0.1 1.56.0.0 1.56.0.1 1.57.0.0 1.57.0.2 1.57.0.3 1.57.0.4 1.57.0.5 1.57.1.0 1.57.1.1 1.57.1.2 1.58.0.0 1.58.0.1 1.59.0.0 1.59.0.1 1.6.0 1.60.0.0 1.60.0.1 1.63.0.0 1.63.0.1 1.64.0.0 1.64.0.1 1.64.1.0 1.64.1.2 1.67.0.0 1.67.0.1 1.68.0.0 1.68.0.1 1.69.0.0 1.69.0.1 1.69.1.1 1.69.1.2 1.7.1 1.70.0.0 1.70.0.1 1.71.0.0 1.71.0.1 1.72.0.0 1.72.1.0 1.72.1.1 1.73.0.0 1.73.0.1 1.74.0.0 1.74.0.1 1.75.0.0 1.75.1.0 1.75.1.1 1.76.0.0 1.76.0.1 1.76.1.0 1.76.1.1 1.76.2.0 1.76.2.1 1.77.0.0 1.77.0.1 1.78.0.0 1.78.0.1 1.79.0.0 1.79.0.1 1.79.0.2 1.79.0.3 1.79.1.0 1.79.1.1 1.8.2 1.80.1.0 1.80.1.1 1.80.1.2 1.81.0.1 1.81.0.2
vk-blocks / src / blocks / staff / edit.js
vk-blocks / src / blocks / staff Last commit date
deprecated 4 years ago block.json 4 years ago edit.js 4 years ago icon.svg 5 years ago index.js 4 years ago index.php 4 years ago save.js 4 years ago style.scss 4 years ago
edit.js
375 lines
1 /**
2 * External dependencies
3 */
4 import classnames from 'classnames';
5
6 /**
7 * WordPress dependencies
8 */
9 import { __ } from '@wordpress/i18n';
10 import {
11 TextControl,
12 PanelBody,
13 RadioControl,
14 BaseControl,
15 SelectControl,
16 Button,
17 } from '@wordpress/components';
18 import {
19 InspectorControls,
20 useBlockProps,
21 RichText,
22 MediaUpload,
23 } from '@wordpress/block-editor';
24 import { isHexColor } from '@vkblocks/utils/is-hex-color';
25 import { AdvancedColorPalette } from '@vkblocks/components/advanced-color-palette';
26
27 export default function StaffEdit(props) {
28 const { attributes, setAttributes, className, clientId } = props;
29 // id生成
30 const vkStaffNameColorId = `vk_staff_name-color-${clientId}`;
31 const vkStaffCaptionColorId = `vk_staff_caption-color-${clientId}`;
32 const vkStaffPositionColorId = `vk_staff_position-color-${clientId}`;
33 const vkStaffProfileTitleColorId = `vk_staff_profileTitle-color-${clientId}`;
34 const vkStaffProfileTextColorId = `vk_staff_profileText-color-${clientId}`;
35 const {
36 vk_staff_layout, // eslint-disable-line camelcase
37 vk_staff_nameColor, // eslint-disable-line camelcase
38 vk_staff_captionColor, // eslint-disable-line camelcase
39 vk_staff_positionColor, // eslint-disable-line camelcase
40 vk_staff_profileTitleColor, // eslint-disable-line camelcase
41 vk_staff_profileTextColor, // eslint-disable-line camelcase
42 vk_staff_photo_image_alt, // eslint-disable-line camelcase
43 vk_staff_photoBorder, // eslint-disable-line camelcase
44 vk_staff_text_name, // eslint-disable-line camelcase
45 vk_staff_text_caption, // eslint-disable-line camelcase
46 vk_staff_text_role, // eslint-disable-line camelcase
47 vk_staff_text_profileTitle, // eslint-disable-line camelcase
48 vk_staff_text_profileText, // eslint-disable-line camelcase
49 vk_staff_photo_image, // eslint-disable-line camelcase
50 vk_staff_fontFamily,
51 } = attributes;
52
53 const classes = classnames('vk_staff', {
54 [className]: !!className,
55 [`vk_staff-layout-${vk_staff_layout}`]: !!vk_staff_layout, // eslint-disable-line camelcase
56 });
57
58 const blockProps = useBlockProps({
59 className: classes,
60 });
61
62 // 画像の線のクラスとimgタグの親タグのクラス名を生成.
63 const imgBorderClassName = classnames('vk_staff_photo', {
64 [`vk_staff_photo-border-${vk_staff_photoBorder}`]:
65 !!vk_staff_photoBorder, // eslint-disable-line camelcase
66 });
67
68 let staffTextClassName = classnames;
69 if (vk_staff_fontFamily === '1') {
70 staffTextClassName = classnames(
71 'vk_staff_text',
72 staffTextClassName,
73 'vk_staff-headingFont-serif'
74 );
75 } else {
76 staffTextClassName = classnames('vk_staff_text', staffTextClassName);
77 }
78
79 let staffNameColorInlineStyle = {};
80 let staffTextNameClassName = '';
81 if (vk_staff_nameColor !== undefined) {
82 staffTextNameClassName += ` has-text-color`;
83 if (isHexColor(vk_staff_nameColor)) {
84 staffNameColorInlineStyle = { color: `${vk_staff_nameColor}` };
85 } else {
86 staffTextNameClassName += ` has-${vk_staff_nameColor}-color`;
87 }
88 }
89
90 let staffCaptionColorInlineStyle = {};
91 let staffCaptionClassName = '';
92 if (vk_staff_captionColor !== undefined) {
93 staffCaptionClassName += ` has-text-color`;
94 if (isHexColor(vk_staff_captionColor)) {
95 staffCaptionColorInlineStyle = {
96 color: `${vk_staff_captionColor}`,
97 };
98 } else {
99 staffCaptionClassName += ` has-${vk_staff_captionColor}-color`;
100 }
101 }
102
103 let staffPositionColorInlineStyle = {};
104 let staffPositionClassName = '';
105 if (vk_staff_positionColor !== undefined) {
106 staffPositionClassName += ` has-text-color`;
107 if (isHexColor(vk_staff_positionColor)) {
108 staffPositionColorInlineStyle = {
109 color: `${vk_staff_positionColor}`,
110 };
111 } else {
112 staffPositionClassName += ` has-${vk_staff_positionColor}-color`;
113 }
114 }
115
116 let staffProfileTitleColorInlineStyle = {};
117 let staffProfileTitleClassName = '';
118 if (vk_staff_profileTitleColor !== undefined) {
119 staffProfileTitleClassName += ` has-text-color`;
120 if (isHexColor(vk_staff_profileTitleColor)) {
121 staffProfileTitleColorInlineStyle = {
122 color: `${vk_staff_profileTitleColor}`,
123 };
124 } else {
125 staffProfileTitleClassName += ` has-${vk_staff_profileTitleColor}-color`;
126 }
127 }
128
129 let staffProfileTextColorInlineStyle = {};
130 let staffProfileTextClassName = '';
131 if (vk_staff_profileTextColor !== undefined) {
132 staffProfileTextClassName += ` has-text-color`;
133 if (isHexColor(vk_staff_profileTextColor)) {
134 staffProfileTextColorInlineStyle = {
135 color: `${vk_staff_profileTextColor}`,
136 };
137 } else {
138 staffProfileTextClassName += ` has-${vk_staff_profileTextColor}-color`;
139 }
140 }
141
142 return (
143 <>
144 <InspectorControls>
145 <PanelBody title={__('Layout', 'vk-blocks')}>
146 <SelectControl
147 value={vk_staff_layout} // eslint-disable-line camelcase
148 onChange={
149 (value) => setAttributes({ vk_staff_layout: value }) // eslint-disable-line camelcase
150 }
151 options={[
152 {
153 value: 'default',
154 label: __('Default', 'vk-blocks'),
155 },
156 {
157 value: 'imageLeft',
158 label: __('Image left', 'vk-blocks'),
159 },
160 ]}
161 />
162 </PanelBody>
163 <PanelBody title={__('Image border', 'vk-blocks')}>
164 <SelectControl
165 value={vk_staff_photoBorder} // eslint-disable-line camelcase
166 onChange={
167 (value) =>
168 setAttributes({ vk_staff_photoBorder: value }) // eslint-disable-line camelcase
169 }
170 options={[
171 {
172 value: 'default',
173 label: __('Default', 'vk-blocks'),
174 },
175 {
176 value: 'none',
177 label: __('None', 'vk-blocks'),
178 },
179 ]}
180 />
181 </PanelBody>
182 <PanelBody title={__('Alt text', 'vk-blocks')}>
183 <BaseControl
184 help={__(
185 'Set the alt text for profile image',
186 'vk-blocks'
187 )}
188 >
189 <TextControl
190 value={vk_staff_photo_image_alt} // eslint-disable-line camelcase
191 onChange={(value) =>
192 setAttributes({
193 vk_staff_photo_image_alt: value, // eslint-disable-line camelcase
194 })
195 }
196 />
197 </BaseControl>
198 </PanelBody>
199 <PanelBody title={__('Color', 'vk-blocks')}>
200 <BaseControl
201 id={vkStaffNameColorId}
202 label={__('Staff name', 'vk-blocks')}
203 >
204 <AdvancedColorPalette
205 id={vkStaffNameColorId}
206 schema={'vk_staff_nameColor'}
207 {...props}
208 />
209 </BaseControl>
210 <BaseControl
211 id={vkStaffCaptionColorId}
212 label={__('Name caption', 'vk-blocks')}
213 >
214 <AdvancedColorPalette
215 id={vkStaffCaptionColorId}
216 schema={'vk_staff_captionColor'}
217 {...props}
218 />
219 </BaseControl>
220 <BaseControl
221 id={vkStaffPositionColorId}
222 label={__('Role position', 'vk-blocks')}
223 >
224 <AdvancedColorPalette
225 id={vkStaffPositionColorId}
226 schema={'vk_staff_positionColor'}
227 {...props}
228 />
229 </BaseControl>
230 <BaseControl
231 id={vkStaffProfileTitleColorId}
232 label={__('Profile title', 'vk-blocks')}
233 >
234 <AdvancedColorPalette
235 id={vkStaffProfileTitleColorId}
236 schema={'vk_staff_profileTitleColor'}
237 {...props}
238 />
239 </BaseControl>
240 <BaseControl
241 id={vkStaffProfileTextColorId}
242 label={__('Profile text', 'vk-blocks')}
243 >
244 <AdvancedColorPalette
245 id={vkStaffProfileTextColorId}
246 schema={'vk_staff_profileTextColor'}
247 {...props}
248 />
249 </BaseControl>
250 </PanelBody>
251 <PanelBody title={__('Heading Font', 'vk-blocks')}>
252 <RadioControl
253 label={__('Font', 'vk-blocks')}
254 selected={vk_staff_fontFamily}
255 options={[
256 {
257 label: __('Unspecified', 'vk-blocks'),
258 value: '0',
259 },
260 {
261 label: __('minchoBody', 'vk-blocks'),
262 value: '1',
263 },
264 ]}
265 onChange={(value) =>
266 setAttributes({ vk_staff_fontFamily: value })
267 }
268 />
269 </PanelBody>
270 </InspectorControls>
271
272 <div {...blockProps}>
273 <div className={staffTextClassName}>
274 <RichText
275 tagName="h3"
276 className={
277 `vk_staff_text_name` + staffTextNameClassName
278 }
279 style={staffNameColorInlineStyle}
280 onChange={(value) =>
281 setAttributes({ vk_staff_text_name: value })
282 }
283 value={vk_staff_text_name} // eslint-disable-line camelcase
284 placeholder={__('Your Name', 'vk-blocks')}
285 />
286 <RichText
287 tagName="p"
288 className={
289 `vk_staff_text_caption` + staffCaptionClassName
290 }
291 style={staffCaptionColorInlineStyle}
292 onChange={(value) =>
293 setAttributes({ vk_staff_text_caption: value })
294 }
295 value={vk_staff_text_caption} // eslint-disable-line camelcase
296 placeholder={__('Caption', 'vk-blocks')}
297 />
298 <RichText
299 tagName="p"
300 className={
301 `vk_staff_text_role` + staffPositionClassName
302 }
303 style={staffPositionColorInlineStyle}
304 onChange={(value) =>
305 setAttributes({ vk_staff_text_role: value })
306 }
307 value={vk_staff_text_role} // eslint-disable-line camelcase
308 placeholder={__('Role position', 'vk-blocks')}
309 />
310 <RichText
311 tagName="h4"
312 className={
313 `vk_staff_text_profileTitle` +
314 staffProfileTitleClassName
315 }
316 style={staffProfileTitleColorInlineStyle}
317 onChange={(value) =>
318 setAttributes({ vk_staff_text_profileTitle: value })
319 }
320 value={vk_staff_text_profileTitle} // eslint-disable-line camelcase
321 placeholder={__('Profile title', 'vk-blocks')}
322 />
323 <RichText
324 tagName="p"
325 className={
326 `vk_staff_text_profileText` +
327 staffProfileTextClassName
328 }
329 style={staffProfileTextColorInlineStyle}
330 onChange={
331 (value) =>
332 setAttributes({
333 vk_staff_text_profileText: value,
334 }) // eslint-disable-line camelcase
335 }
336 value={vk_staff_text_profileText} // eslint-disable-line camelcase
337 placeholder={__('Profile text', 'vk-blocks')}
338 />
339 </div>
340 <div className={imgBorderClassName}>
341 <MediaUpload
342 onSelect={(value) =>
343 setAttributes({
344 vk_staff_photo_image: value.sizes.full.url,
345 })
346 }
347 type="image"
348 value={vk_staff_photo_image} // eslint-disable-line camelcase
349 render={({ open }) => (
350 <Button
351 onClick={open}
352 className={
353 vk_staff_photo_image // eslint-disable-line camelcase
354 ? 'image-button'
355 : 'button button-large'
356 }
357 >
358 {!vk_staff_photo_image ? ( // eslint-disable-line camelcase
359 __('Select image', 'vk-blocks')
360 ) : (
361 <img
362 className={`vk_staff_photo_image`}
363 src={vk_staff_photo_image} // eslint-disable-line camelcase
364 alt={vk_staff_photo_image_alt} // eslint-disable-line camelcase
365 />
366 )}
367 </Button>
368 )}
369 />
370 </div>
371 </div>
372 </>
373 );
374 }
375