PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.8
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.8
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / blocks / taxonomy-filter / styleTab.js

styleTab.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/blocks/taxonomy-filter/styleTab.js

535 lines 12.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from "@wordpress/i18n";
2 import {
3 Border,
4 BoxShadow,
5 Divider,
6 InputControl,
7 Spacing,
8 SpColorPicker,
9 SPRangeControl,
10 SPToggleGroupControl,
11 } from "../../components";
12 import Toggle from "../../components/toggle/toggle";
13
14 import { useState } from "@wordpress/element";
15
16 const FieldStyle = ({ attributes, setAttributes }) => {
17 const { fieldLabelColor, fieldPadding, fieldBorder, fieldBorderWidth, fieldBorderRadius } = attributes;
18
19 return (
20 <>
21 <SpColorPicker
22 label={__("Label Color", "post-carousel")}
23 value={fieldLabelColor}
24 onChange={(newColor) =>
25 setAttributes({
26 fieldLabelColor: newColor,
27 })
28 }
29 defaultColor="#333333"
30 />
31 <Border
32 label="Border"
33 attributes={{
34 border: fieldBorder,
35 borderWidth: fieldBorderWidth,
36 }}
37 setAttributes={setAttributes}
38 attributesKey={{
39 border: "fieldBorder",
40 borderWidth: "fieldBorderWidth",
41 }}
42 btnType="normal"
43 />
44 <Spacing
45 label={__("Border Radius", "post-carousel")}
46 attributes={fieldBorderRadius}
47 attributesKey={"fieldBorderRadius"}
48 setAttributes={setAttributes}
49 units={["px", "%", "em"]}
50 defaultValue={{
51 unit: "px",
52 value: {
53 top: "",
54 right: "",
55 bottom: "",
56 left: "",
57 },
58 }}
59 indicator={"radius"}
60 />
61 <Spacing
62 label={__("Padding", "post-carousel")}
63 attributes={fieldPadding}
64 attributesKey={"fieldPadding"}
65 setAttributes={setAttributes}
66 units={["px", "%", "em"]}
67 defaultValue={{
68 unit: "px",
69 value: {
70 top: 10,
71 right: 12,
72 bottom: 10,
73 left: 12,
74 },
75 }}
76 />
77 </>
78 );
79 };
80 const DropdownStyle = ({ attributes, setAttributes }) => {
81 const [colorType, setColorType] = useState("normal");
82 const {
83 dropdownOptionColor,
84 dropdownOptionBg,
85 dropdownOptionBorder,
86 dropdownOptionBorderHover,
87 dropdownOptionBorderWidth,
88 dropdownOptionBorderWidthHover,
89 dropdownBorderRadius,
90 dropdownBorderRadiusHover,
91 dropdownAlignment,
92 dropdownShadowEnable,
93 dropdownShadow,
94 dropdownShadowHover,
95 dropdownShadowEnableHover,
96 dropdownHoverColor,
97 dropdownHoverBgColor,
98 dropdownPadding,
99 dropdownMargin,
100 } = attributes;
101
102 return (
103 <>
104 <SPToggleGroupControl
105 // label={ __( 'Filter Type', 'post-carousel' ) }
106 attributes={colorType}
107 attributesKey={"colorType"}
108 onClick={(newValue) => setColorType(newValue)}
109 items={[
110 {
111 label: __("Normal", "post-carousel"),
112 value: "normal",
113 },
114 {
115 label: __("Hover & Active", "post-carousel"),
116 value: "hover",
117 },
118 ]}
119 />
120 {"normal" === colorType && (
121 <>
122 <SpColorPicker
123 label={__("Option Color", "post-carousel")}
124 value={dropdownOptionColor.color}
125 onChange={(newColor) =>
126 setAttributes({
127 dropdownOptionColor: {
128 ...dropdownOptionColor,
129 color: newColor,
130 },
131 })
132 }
133 defaultColor="#333333"
134 />
135 <SpColorPicker
136 label={__("Background Color", "post-carousel")}
137 value={dropdownOptionBg.color}
138 onChange={(newColor) =>
139 setAttributes({
140 dropdownOptionBg: {
141 ...dropdownOptionBg,
142 color: newColor,
143 },
144 })
145 }
146 defaultColor="#ffffff"
147 />
148 </>
149 )}
150 {"hover" === colorType && (
151 <>
152 <SpColorPicker
153 label={__("Option Color", "post-carousel")}
154 value={dropdownOptionColor.hover}
155 onChange={(newColor) =>
156 setAttributes({
157 dropdownOptionColor: {
158 ...dropdownOptionColor,
159 hover: newColor,
160 },
161 })
162 }
163 defaultColor="#ffffff"
164 />
165 <SpColorPicker
166 label={__("Background Color", "post-carousel")}
167 value={dropdownOptionBg.hover}
168 onChange={(newColor) =>
169 setAttributes({
170 dropdownOptionBg: {
171 ...dropdownOptionBg,
172 hover: newColor,
173 },
174 })
175 }
176 defaultColor="var(--sp-smart-primary-2-600)"
177 />
178 </>
179 )}
180 <Divider position={"sp-w-100pct bottom"} />
181 <Border
182 label="Border"
183 attributes={{
184 border: dropdownOptionBorder,
185 borderWidth: dropdownOptionBorderWidth,
186 }}
187 setAttributes={setAttributes}
188 attributesKey={{
189 border: "dropdownOptionBorder",
190 borderWidth: "dropdownOptionBorderWidth",
191 }}
192 btnType="normal"
193 />
194 <Spacing
195 label={__("Border Radius", "post-carousel")}
196 attributes={dropdownBorderRadius}
197 attributesKey={"dropdownBorderRadius"}
198 setAttributes={setAttributes}
199 units={["px", "%", "em"]}
200 defaultValue={{
201 unit: "px",
202 value: {
203 top: "2",
204 right: "2",
205 bottom: "2",
206 left: "2",
207 },
208 }}
209 indicator={"radius"}
210 />
211 <Toggle
212 label={__("Box Shadow", "post-carousel")}
213 attributes={dropdownShadowEnable}
214 attributesKey={"dropdownShadowEnable"}
215 setAttributes={setAttributes}
216 />
217 {dropdownShadowEnable && (
218 <BoxShadow
219 label={__("Box Shadow", "post-carousel")}
220 attributes={dropdownShadow}
221 attributesKey={"dropdownShadow"}
222 setAttributes={setAttributes}
223 />
224 )}
225 <Spacing
226 label={__("Padding", "post-carousel")}
227 attributes={dropdownPadding}
228 attributesKey={"dropdownPadding"}
229 setAttributes={setAttributes}
230 units={["px", "%", "em"]}
231 defaultValue={{
232 unit: "px",
233 value: {
234 top: "5",
235 right: "10",
236 bottom: "5",
237 left: "10",
238 },
239 }}
240 />
241 <Spacing
242 label={__("Margin", "post-carousel")}
243 attributes={dropdownMargin}
244 attributesKey={"dropdownMargin"}
245 setAttributes={setAttributes}
246 units={["px", "%", "em"]}
247 defaultValue={{
248 unit: "px",
249 value: {
250 top: 8,
251 right: 0,
252 bottom: 0,
253 left: 0,
254 },
255 }}
256 />
257 </>
258 );
259 };
260 const SearchStyle = ({ attributes, setAttributes }) => {
261 const { searchPlaceholderText, searchBorder, searchBorderWidth } = attributes;
262
263 return (
264 <>
265 <InputControl
266 label={__("Placeholder Text", "post-carousel")}
267 attributes={searchPlaceholderText}
268 attributesKey={"searchPlaceholderText"}
269 setAttributes={setAttributes}
270 placeholder={__("Search…", "post-carousel")}
271 flex={false}
272 inputType="text"
273 />
274
275 <Border
276 label="Border"
277 attributes={{
278 border: searchBorder,
279 borderWidth: searchBorderWidth,
280 }}
281 setAttributes={setAttributes}
282 attributesKey={{
283 border: "searchBorder",
284 borderWidth: "searchBorderWidth",
285 }}
286 btnType="normal"
287 />
288 {/* <Spacing
289 label={__(
290 'Border Radius',
291 'post-carousel'
292 )}
293 attributes={searchBorderRadius}
294 attributesKey={'searchBorderRadius'}
295 setAttributes={setAttributes}
296 units={['px', '%', 'em']}
297 defaultValue={{
298 unit: 'px',
299 value: {
300 top: '',
301 right: '',
302 bottom: '',
303 left: '',
304 },
305 }}
306 /> */}
307 </>
308 );
309 };
310
311 const StyleTab = ({ attributes, setAttributes }) => {
312 const [fieldType, setFieldType] = useState("field");
313 const [colorType, setColorType] = useState("normal");
314 const {
315 searchInDropdown,
316 buttonColor,
317 buttonBg,
318 buttonBorder,
319 buttonBorderWidth,
320 buttonBorderRadius,
321 buttonBorderHover,
322 buttonBorderWidthHover,
323 buttonBorderRadiusHover,
324 buttonPadding,
325 filterType,
326 buttonGap,
327 } = attributes;
328
329 const fieldItemsList = [
330 { label: __("Field", "post-carousel"), value: "field" },
331 { label: __("Dropdown", "post-carousel"), value: "dropdown" },
332 ];
333
334 if (searchInDropdown) {
335 fieldItemsList.push({
336 label: __("Search", "post-carousel"),
337 value: "search",
338 });
339 }
340
341 return (
342 <>
343 {"dropdown" === filterType && (
344 <>
345 <SPToggleGroupControl
346 // label={ __( 'Filter Type', 'post-carousel' ) }
347 attributes={fieldType}
348 onClick={(newValue) => setFieldType(newValue)}
349 setAttributes={setAttributes}
350 items={fieldItemsList}
351 />
352
353 {"field" === fieldType && <FieldStyle attributes={attributes} setAttributes={setAttributes} />}
354
355 {"dropdown" === fieldType && (
356 <DropdownStyle attributes={attributes} setAttributes={setAttributes} />
357 )}
358
359 {"search" === fieldType && <SearchStyle attributes={attributes} setAttributes={setAttributes} />}
360 </>
361 )}
362 {"button" === filterType && (
363 <>
364 <SPToggleGroupControl
365 // label={ __( 'Filter Type', 'post-carousel' ) }
366 attributes={colorType}
367 attributesKey={"colorType"}
368 onClick={(newValue) => setColorType(newValue)}
369 items={[
370 {
371 label: __("Normal", "post-carousel"),
372 value: "normal",
373 },
374 {
375 label: __("Hover & Active", "post-carousel"),
376 value: "hover",
377 },
378 ]}
379 />
380
381 {"normal" === colorType && (
382 <>
383 <SpColorPicker
384 label={__("Option Color", "post-carousel")}
385 value={buttonColor.color}
386 onChange={(newColor) =>
387 setAttributes({
388 buttonColor: {
389 ...buttonColor,
390 color: newColor,
391 },
392 })
393 }
394 defaultColor="#333333"
395 />
396 <SpColorPicker
397 label={__("Background Color", "post-carousel")}
398 value={buttonBg.color}
399 onChange={(newColor) =>
400 setAttributes({
401 buttonBg: {
402 ...buttonBg,
403 color: newColor,
404 },
405 })
406 }
407 defaultColor="var(--sp-smart-primary-2-600)"
408 />
409 <Border
410 label="Border"
411 attributes={{
412 border: buttonBorder,
413 borderWidth: buttonBorderWidth,
414 }}
415 setAttributes={setAttributes}
416 attributesKey={{
417 border: "buttonBorder",
418 borderWidth: "buttonBorderWidth",
419 }}
420 btnType="normal"
421 />
422 <Spacing
423 label={__("Border Radius", "post-carousel")}
424 attributes={buttonBorderRadius}
425 attributesKey={"buttonBorderRadius"}
426 setAttributes={setAttributes}
427 units={["px", "%", "em"]}
428 defaultValue={{
429 unit: "px",
430 value: {
431 top: "2",
432 right: "2",
433 bottom: "2",
434 left: "2",
435 },
436 }}
437 indicator={"radius"}
438 />
439 </>
440 )}
441
442 {"hover" === colorType && (
443 <>
444 <SpColorPicker
445 label={__("Option Color", "post-carousel")}
446 value={buttonColor.hover}
447 onChange={(newColor) =>
448 setAttributes({
449 buttonColor: {
450 ...buttonColor,
451 hover: newColor,
452 },
453 })
454 }
455 defaultColor="#ffffff"
456 />
457 <SpColorPicker
458 label={__("Background Color", "post-carousel")}
459 value={buttonBg.hover}
460 onChange={(newColor) =>
461 setAttributes({
462 buttonBg: {
463 ...buttonBg,
464 hover: newColor,
465 },
466 })
467 }
468 defaultColor="var(--sp-smart-primary-2-600)"
469 />
470 <Border
471 label="Border"
472 attributes={{
473 border: buttonBorderHover,
474 borderWidth: buttonBorderWidthHover,
475 }}
476 setAttributes={setAttributes}
477 attributesKey={{
478 border: "buttonBorderHover",
479 borderWidth: "buttonBorderWidthHover",
480 }}
481 btnType="normal"
482 />
483 <Spacing
484 label={__("Border Radius", "post-carousel")}
485 attributes={buttonBorderRadiusHover}
486 attributesKey={"buttonBorderRadiusHover"}
487 setAttributes={setAttributes}
488 units={["px", "%", "em"]}
489 defaultValue={{
490 unit: "px",
491 value: {
492 top: "2",
493 right: "2",
494 bottom: "2",
495 left: "2",
496 },
497 }}
498 indicator={"radius"}
499 />
500 </>
501 )}
502 <Divider position={"sp-w-100pct bottom"} />
503 <SPRangeControl
504 label={__("Gap", "post-carousel")}
505 attributes={buttonGap}
506 attributesKey={"buttonGap"}
507 setAttributes={setAttributes}
508 resetIcon={true}
509 max={200}
510 defaultValue={{ unit: "px", value: 10 }}
511 />
512 <Spacing
513 label={__("Padding", "post-carousel")}
514 attributes={buttonPadding}
515 attributesKey={"buttonPadding"}
516 setAttributes={setAttributes}
517 units={["px", "%", "em"]}
518 defaultValue={{
519 unit: "px",
520 value: {
521 top: "2",
522 right: "2",
523 bottom: "2",
524 left: "2",
525 },
526 }}
527 />
528 </>
529 )}
530 </>
531 );
532 };
533
534 export default StyleTab;
535