PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
betterdocs / react-src / gutenberg / util / border-shadow-control / index.js

index.js in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.5, at react-src/gutenberg/util/border-shadow-control/index.js

495 lines 18.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 const { __ } = wp.i18n;
5 const {
6 ToggleControl,
7 TextControl,
8 Button,
9 RangeControl,
10 BaseControl,
11 ButtonGroup,
12 SelectControl,
13 Dropdown,
14 } = wp.components;
15
16 /**
17 * Internal dependencies
18 */
19
20 import ColorControl from "../color-control";
21 import ResetControl from "../reset-control";
22 import ResponsiveDimensionsControl from "../dimensions-control-v2";
23 import { TypographyIcon } from "../icons";
24
25 export default function BorderShadowControl({
26 resRequiredProps,
27 controlName,
28 noBorder,
29 noShadow,
30 noBdrHover,
31 noShdowHover,
32 }) {
33 const { setAttributes, attributes, objAttributes } = resRequiredProps;
34
35 const {
36 [`${controlName}borderStyle`]: borderStyle,
37 [`${controlName}borderColor`]: borderColor,
38 [`${controlName}shadowType`]: shadowType,
39 [`${controlName}shadowColor`]: shadowColor,
40 [`${controlName}hOffset`]: hOffset,
41 [`${controlName}vOffset`]: vOffset,
42 [`${controlName}blur`]: blur,
43 [`${controlName}spread`]: spread,
44 [`${controlName}hoverShadowColor`]: hoverShadowColor,
45 [`${controlName}hoverHOffset`]: hoverHOffset,
46 [`${controlName}hoverVOffset`]: hoverVOffset,
47 [`${controlName}hoverBlur`]: hoverBlur,
48 [`${controlName}hoverSpread`]: hoverSpread,
49 [`${controlName}inset`]: inset,
50
51 [`${controlName}BorderType`]: BorderType,
52 [`${controlName}HborderStyle`]: HborderStyle,
53 [`${controlName}HborderColor`]: HborderColor,
54
55 [`${controlName}borderTransition`]: borderTransition,
56 [`${controlName}radiusTransition`]: radiusTransition,
57 [`${controlName}shadowTransition`]: shadowTransition,
58 } = attributes;
59
60 return (
61 <>
62 {noBorder !== true && (
63 <>
64 {!noBdrHover && (
65 <BaseControl id="eb-infobox-border-hover-ptions">
66 <ButtonGroup id="eb-infobox-border-hover-ptions">
67 {[
68 { label: "Normal", value: "normal" },
69 { label: "Hover", value: "hover" },
70 ].map(({ value, label }) => (
71 <Button
72 isLarge
73 isSecondary={BorderType !== value}
74 isPrimary={BorderType === value}
75 onClick={() =>
76 setAttributes({ [`${controlName}BorderType`]: value })
77 }
78 >
79 {label}
80 </Button>
81 ))}
82 </ButtonGroup>
83 </BaseControl>
84 )}
85
86 {(BorderType === "normal" || noBdrHover) && (
87 <>
88 <SelectControl
89 label={__("Border Style", "betterdocs")}
90 value={borderStyle}
91 options={[
92 { label: __("None", "betterdocs"), value: "none" },
93 { label: __("Dashed", "betterdocs"), value: "dashed" },
94 { label: __("Solid", "betterdocs"), value: "solid" },
95 { label: __("Dotted", "betterdocs"), value: "dotted" },
96 { label: __("Double", "betterdocs"), value: "double" },
97 { label: __("Groove", "betterdocs"), value: "groove" },
98 { label: __("Inset", "betterdocs"), value: "inset" },
99 { label: __("Outset", "betterdocs"), value: "outset" },
100 { label: __("Ridge", "betterdocs"), value: "ridge" },
101 ]}
102 onChange={(borderStyle) =>
103 setAttributes({
104 [`${controlName}borderStyle`]: borderStyle,
105 })
106 }
107 />
108
109 {borderStyle !== "none" && (
110 <>
111 <ColorControl
112 defaultColor={
113 (objAttributes[`${controlName}borderColor`] || {}).default
114 }
115 label={__("Border Color", "betterdocs")}
116 color={borderColor}
117 onChange={(borderColor) =>
118 setAttributes({
119 [`${controlName}borderColor`]: borderColor,
120 })
121 }
122 />
123
124 <ResponsiveDimensionsControl
125 resRequiredProps={resRequiredProps}
126 controlName={`${controlName}Bdr_`}
127 baseLabel="Border Width"
128 />
129 </>
130 )}
131
132 <ResponsiveDimensionsControl
133 forBorderRadius
134 resRequiredProps={resRequiredProps}
135 controlName={`${controlName}Rds_`}
136 baseLabel="Border Radius"
137 />
138 </>
139 )}
140
141 {BorderType === "hover" && !noBdrHover && (
142 <>
143 <SelectControl
144 label={__("Border Style", "betterdocs")}
145 value={HborderStyle}
146 options={[
147 { label: __("None", "betterdocs"), value: "none" },
148 { label: __("Dashed", "betterdocs"), value: "dashed" },
149 { label: __("Solid", "betterdocs"), value: "solid" },
150 { label: __("Dotted", "betterdocs"), value: "dotted" },
151 { label: __("Double", "betterdocs"), value: "double" },
152 { label: __("Groove", "betterdocs"), value: "groove" },
153 { label: __("Inset", "betterdocs"), value: "inset" },
154 { label: __("Outset", "betterdocs"), value: "outset" },
155 { label: __("Ridge", "betterdocs"), value: "ridge" },
156 ]}
157 onChange={(HborderStyle) =>
158 setAttributes({
159 [`${controlName}HborderStyle`]: HborderStyle,
160 })
161 }
162 />
163
164 {HborderStyle !== "none" && (
165 <>
166 <ColorControl
167 defaultColor={
168 (objAttributes[`${controlName}HborderColor`] || {})
169 .default
170 }
171 label={__("Border Color", "betterdocs")}
172 color={HborderColor}
173 onChange={(HborderColor) =>
174 setAttributes({
175 [`${controlName}HborderColor`]: HborderColor,
176 })
177 }
178 />
179
180 <ResponsiveDimensionsControl
181 resRequiredProps={resRequiredProps}
182 controlName={`${controlName}HBdr_`}
183 baseLabel="Border Width"
184 />
185
186 <RangeControl
187 label={__("Border Transition", "betterdocs")}
188 value={borderTransition}
189 onChange={(borderTransition) =>
190 setAttributes({
191 [`${controlName}borderTransition`]: borderTransition,
192 })
193 }
194 step={0.01}
195 min={0}
196 max={5}
197 />
198 </>
199 )}
200
201 <ResponsiveDimensionsControl
202 forBorderRadius
203 resRequiredProps={resRequiredProps}
204 controlName={`${controlName}HRds_`}
205 baseLabel="Border Radius"
206 />
207
208 <RangeControl
209 label={__("Border Radius Transition", "betterdocs")}
210 value={radiusTransition}
211 onChange={(radiusTransition) =>
212 setAttributes({
213 [`${controlName}radiusTransition`]: radiusTransition,
214 })
215 }
216 step={0.01}
217 min={0}
218 max={5}
219 />
220 </>
221 )}
222 </>
223 )}
224
225 {noShadow !== true && (
226 <>
227 <BaseControl label={__("Box Shadow", "betterdocs")} className="eb-typography-base">
228 <Dropdown
229 className="eb-typography-dropdown"
230 contentClassName="my-popover-content-classname"
231 position="bottom right"
232 renderToggle={({ isOpen, onToggle }) => (
233 <Button isSmall onClick={onToggle} aria-expanded={isOpen}>
234 <TypographyIcon />
235 </Button>
236 )}
237 renderContent={() => (
238 <>
239 <div
240 className="eb-panel-control"
241 style={{ minWidth: "230px", padding: "10px" }}
242 >
243 {!noShdowHover && (
244 <BaseControl id="eb-infobox-shadow-hover-ptions">
245 <ButtonGroup id="eb-infobox-shadow-hover-ptions">
246 {[
247 { label: "Normal", value: "normal" },
248 { label: "Hover", value: "hover" },
249 ].map(({ value, label }) => (
250 <Button
251 isLarge
252 isSecondary={shadowType !== value}
253 isPrimary={shadowType === value}
254 onClick={() =>
255 setAttributes({
256 [`${controlName}shadowType`]: value,
257 })
258 }
259 >
260 {label}
261 </Button>
262 ))}
263 </ButtonGroup>
264 </BaseControl>
265 )}
266
267 <ToggleControl
268 label={__("Inset", "betterdocs")}
269 checked={inset}
270 onChange={() =>
271 setAttributes({ [`${controlName}inset`]: !inset })
272 }
273 />
274
275 {(shadowType === "normal" || noShdowHover) && (
276 <>
277 <ColorControl
278 defaultColor={
279 (objAttributes[`${controlName}shadowColor`] || {})
280 .default
281 }
282 label={__("Shadow Color", "betterdocs")}
283 color={shadowColor}
284 onChange={(shadowColor) =>
285 setAttributes({
286 [`${controlName}shadowColor`]: shadowColor,
287 })
288 }
289 />
290
291 <ResetControl
292 onReset={() =>
293 setAttributes({
294 [`${controlName}hOffset`]: undefined,
295 })
296 }
297 >
298 <RangeControl
299 label={__("Horizontal Offset", "betterdocs")}
300 value={hOffset}
301 onChange={(hOffset) =>
302 setAttributes({
303 [`${controlName}hOffset`]: hOffset,
304 })
305 }
306 min={0}
307 max={200}
308 />
309 </ResetControl>
310
311 <ResetControl
312 onReset={() =>
313 setAttributes({
314 [`${controlName}vOffset`]: undefined,
315 })
316 }
317 >
318 <RangeControl
319 label={__("Vertical Offset", "betterdocs")}
320 value={vOffset}
321 onChange={(vOffset) =>
322 setAttributes({
323 [`${controlName}vOffset`]: vOffset,
324 })
325 }
326 min={0}
327 max={200}
328 />
329 </ResetControl>
330
331 <ResetControl
332 onReset={() =>
333 setAttributes({ [`${controlName}blur`]: undefined })
334 }
335 >
336 <RangeControl
337 label={__("Shadow Blur", "betterdocs")}
338 value={blur}
339 onChange={(blur) =>
340 setAttributes({
341 [`${controlName}blur`]: blur,
342 })
343 }
344 min={0}
345 max={200}
346 />
347 </ResetControl>
348
349 <ResetControl
350 onReset={() =>
351 setAttributes({
352 [`${controlName}spread`]: undefined,
353 })
354 }
355 >
356 <RangeControl
357 label={__("Shadow Spread", "betterdocs")}
358 value={spread}
359 onChange={(spread) =>
360 setAttributes({
361 [`${controlName}spread`]: spread,
362 })
363 }
364 min={0}
365 max={200}
366 />
367 </ResetControl>
368 </>
369 )}
370
371 {shadowType === "hover" && !noShdowHover && (
372 <>
373 <ColorControl
374 defaultColor={
375 (
376 objAttributes[`${controlName}hoverShadowColor`] ||
377 {}
378 ).default
379 }
380 label={__("Hover Shadow Color", "betterdocs")}
381 color={hoverShadowColor}
382 onChange={(hoverShadowColor) =>
383 setAttributes({
384 [`${controlName}hoverShadowColor`]:
385 hoverShadowColor,
386 })
387 }
388 />
389
390 <ResetControl
391 onReset={() =>
392 setAttributes({
393 [`${controlName}hoverHOffset`]: undefined,
394 })
395 }
396 >
397 <RangeControl
398 label={__("Horizontal Offset", "betterdocs")}
399 value={hoverHOffset}
400 onChange={(hoverHOffset) =>
401 setAttributes({
402 [`${controlName}hoverHOffset`]: hoverHOffset,
403 })
404 }
405 min={0}
406 max={200}
407 />
408 </ResetControl>
409
410 <ResetControl
411 onReset={() =>
412 setAttributes({
413 [`${controlName}hoverVOffset`]: undefined,
414 })
415 }
416 >
417 <RangeControl
418 label={__("Vertical Offset", "betterdocs")}
419 value={hoverVOffset}
420 onChange={(hoverVOffset) =>
421 setAttributes({
422 [`${controlName}hoverVOffset`]: hoverVOffset,
423 })
424 }
425 min={0}
426 max={200}
427 />
428 </ResetControl>
429
430 <ResetControl
431 onReset={() =>
432 setAttributes({
433 [`${controlName}hoverBlur`]: undefined,
434 })
435 }
436 >
437 <RangeControl
438 label={__("Shadow Blur", "betterdocs")}
439 value={hoverBlur}
440 onChange={(hoverBlur) =>
441 setAttributes({
442 [`${controlName}hoverBlur`]: hoverBlur,
443 })
444 }
445 min={0}
446 max={200}
447 />
448 </ResetControl>
449
450 <ResetControl
451 onReset={() =>
452 setAttributes({
453 [`${controlName}hoverSpread`]: undefined,
454 })
455 }
456 >
457 <RangeControl
458 label={__("Shadow Spread", "betterdocs")}
459 value={hoverSpread}
460 onChange={(hoverSpread) =>
461 setAttributes({
462 [`${controlName}hoverSpread`]: hoverSpread,
463 })
464 }
465 min={0}
466 max={200}
467 />
468 </ResetControl>
469
470 <RangeControl
471 label={__("Shadow Transition", "betterdocs")}
472 value={shadowTransition}
473 onChange={(shadowTransition) =>
474 setAttributes({
475 [`${controlName}shadowTransition`]:
476 shadowTransition,
477 })
478 }
479 step={0.01}
480 min={0}
481 max={5}
482 />
483 </>
484 )}
485 </div>
486 </>
487 )}
488 />
489 </BaseControl>
490 </>
491 )}
492 </>
493 );
494 }
495