PluginProbe ʕ •ᴥ•ʔ
VK Blocks / trunk
VK Blocks vtrunk
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 2 months ago block.json 1 month ago edit.js 2 weeks ago icon.svg 2 months ago index.js 2 months ago index.php 2 months ago save.js 2 months ago style.scss 2 months ago
edit.js
374 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 { sanitizeSlug } from '@vkblocks/utils/sanitizeSlug';
26 import { AdvancedColorPalette } from '@vkblocks/components/advanced-color-palette';
27
28 export default function StaffEdit(props) {
29 const { attributes, setAttributes, className, clientId } = props;
30 // id生成
31 const vkStaffNameColorId = `vk_staff_name-color-${clientId}`;
32 const vkStaffCaptionColorId = `vk_staff_caption-color-${clientId}`;
33 const vkStaffPositionColorId = `vk_staff_position-color-${clientId}`;
34 const vkStaffProfileTitleColorId = `vk_staff_profileTitle-color-${clientId}`;
35 const vkStaffProfileTextColorId = `vk_staff_profileText-color-${clientId}`;
36 const {
37 vk_staff_layout,
38 vk_staff_nameColor,
39 vk_staff_captionColor,
40 vk_staff_positionColor,
41 vk_staff_profileTitleColor,
42 vk_staff_profileTextColor,
43 vk_staff_photo_image_alt,
44 vk_staff_photoBorder,
45 vk_staff_text_name,
46 vk_staff_text_caption,
47 vk_staff_text_role,
48 vk_staff_text_profileTitle,
49 vk_staff_text_profileText,
50 vk_staff_photo_image,
51 vk_staff_fontFamily,
52 } = attributes;
53
54 const classes = classnames('vk_staff', {
55 [className]: !!className,
56 [`vk_staff-layout-${vk_staff_layout}`]: !!vk_staff_layout,
57 });
58
59 const blockProps = useBlockProps({
60 className: classes,
61 });
62
63 // 画像の線のクラスとimgタグの親タグのクラス名を生成.
64 const imgBorderClassName = classnames('vk_staff_photo', {
65 [`vk_staff_photo-border-${vk_staff_photoBorder}`]:
66 !!vk_staff_photoBorder,
67 });
68
69 let staffTextClassName = classnames;
70 if (vk_staff_fontFamily === '1') {
71 staffTextClassName = classnames(
72 'vk_staff_text',
73 staffTextClassName,
74 'vk_staff-headingFont-serif'
75 );
76 } else {
77 staffTextClassName = classnames('vk_staff_text', staffTextClassName);
78 }
79
80 let staffNameColorInlineStyle = {};
81 let staffTextNameClassName = '';
82 if (vk_staff_nameColor !== undefined) {
83 staffTextNameClassName += ` has-text-color`;
84 if (isHexColor(vk_staff_nameColor)) {
85 staffNameColorInlineStyle = { color: `${vk_staff_nameColor}` };
86 } else {
87 staffTextNameClassName += ` has-${sanitizeSlug(vk_staff_nameColor)}-color`;
88 }
89 }
90
91 let staffCaptionColorInlineStyle = {};
92 let staffCaptionClassName = '';
93 if (vk_staff_captionColor !== undefined) {
94 staffCaptionClassName += ` has-text-color`;
95 if (isHexColor(vk_staff_captionColor)) {
96 staffCaptionColorInlineStyle = {
97 color: `${vk_staff_captionColor}`,
98 };
99 } else {
100 staffCaptionClassName += ` has-${sanitizeSlug(vk_staff_captionColor)}-color`;
101 }
102 }
103
104 let staffPositionColorInlineStyle = {};
105 let staffPositionClassName = '';
106 if (vk_staff_positionColor !== undefined) {
107 staffPositionClassName += ` has-text-color`;
108 if (isHexColor(vk_staff_positionColor)) {
109 staffPositionColorInlineStyle = {
110 color: `${vk_staff_positionColor}`,
111 };
112 } else {
113 staffPositionClassName += ` has-${sanitizeSlug(vk_staff_positionColor)}-color`;
114 }
115 }
116
117 let staffProfileTitleColorInlineStyle = {};
118 let staffProfileTitleClassName = '';
119 if (vk_staff_profileTitleColor !== undefined) {
120 staffProfileTitleClassName += ` has-text-color`;
121 if (isHexColor(vk_staff_profileTitleColor)) {
122 staffProfileTitleColorInlineStyle = {
123 color: `${vk_staff_profileTitleColor}`,
124 };
125 } else {
126 staffProfileTitleClassName += ` has-${sanitizeSlug(vk_staff_profileTitleColor)}-color`;
127 }
128 }
129
130 let staffProfileTextColorInlineStyle = {};
131 let staffProfileTextClassName = '';
132 if (vk_staff_profileTextColor !== undefined) {
133 staffProfileTextClassName += ` has-text-color`;
134 if (isHexColor(vk_staff_profileTextColor)) {
135 staffProfileTextColorInlineStyle = {
136 color: `${vk_staff_profileTextColor}`,
137 };
138 } else {
139 staffProfileTextClassName += ` has-${sanitizeSlug(vk_staff_profileTextColor)}-color`;
140 }
141 }
142
143 return (
144 <>
145 <InspectorControls>
146 <PanelBody title={__('Layout', 'vk-blocks')}>
147 <SelectControl
148 value={vk_staff_layout}
149 onChange={(value) =>
150 setAttributes({ vk_staff_layout: value })
151 }
152 options={[
153 {
154 value: 'default',
155 label: __('Default', 'vk-blocks'),
156 },
157 {
158 value: 'imageLeft',
159 label: __('Image left', 'vk-blocks'),
160 },
161 ]}
162 />
163 </PanelBody>
164 <PanelBody title={__('Image border', 'vk-blocks')}>
165 <SelectControl
166 value={vk_staff_photoBorder}
167 onChange={(value) =>
168 setAttributes({ vk_staff_photoBorder: value })
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}
191 onChange={(value) =>
192 setAttributes({
193 vk_staff_photo_image_alt: value,
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}
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}
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}
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}
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={(value) =>
331 setAttributes({
332 vk_staff_text_profileText: value,
333 })
334 }
335 value={vk_staff_text_profileText}
336 placeholder={__('Profile text', 'vk-blocks')}
337 />
338 </div>
339 <div className={imgBorderClassName}>
340 <MediaUpload
341 onSelect={(value) =>
342 setAttributes({
343 vk_staff_photo_image: value.sizes.full.url,
344 })
345 }
346 type="image"
347 value={vk_staff_photo_image}
348 render={({ open }) => (
349 <Button
350 onClick={open}
351 className={
352 vk_staff_photo_image
353 ? 'image-button'
354 : 'button button-large'
355 }
356 >
357 {!vk_staff_photo_image ? (
358 __('Select image', 'vk-blocks')
359 ) : (
360 <img
361 className={`vk_staff_photo_image`}
362 src={vk_staff_photo_image}
363 alt={vk_staff_photo_image_alt}
364 />
365 )}
366 </Button>
367 )}
368 />
369 </div>
370 </div>
371 </>
372 );
373 }
374