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 / dimensions-control-v2 / index.js

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

139 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import DimensionsControl from "./dimensions";
2 import UnitControl from "../unit-control";
3
4 export default function ResponsiveDimensionsControl({
5 resRequiredProps,
6 controlName,
7 baseLabel,
8 forBorderRadius,
9 disableLeftRight = false,
10 }) {
11 const { attributes, setAttributes, resOption } = resRequiredProps;
12
13 const {
14 [`${controlName}isLinked`]: dimensionIsLinked,
15
16 [`${controlName}Unit`]: dimensionUnit,
17 [`${controlName}Top`]: dimensionTop,
18 [`${controlName}Right`]: dimensionRight,
19 [`${controlName}Bottom`]: dimensionBottom,
20 [`${controlName}Left`]: dimensionLeft,
21
22 [`TAB${controlName}Unit`]: TABdimensionUnit,
23 [`TAB${controlName}Top`]: TABdimensionTop,
24 [`TAB${controlName}Right`]: TABdimensionRight,
25 [`TAB${controlName}Bottom`]: TABdimensionBottom,
26 [`TAB${controlName}Left`]: TABdimensionLeft,
27
28 [`MOB${controlName}Unit`]: MOBdimensionUnit,
29 [`MOB${controlName}Top`]: MOBdimensionTop,
30 [`MOB${controlName}Right`]: MOBdimensionRight,
31 [`MOB${controlName}Bottom`]: MOBdimensionBottom,
32 [`MOB${controlName}Left`]: MOBdimensionLeft,
33 } = attributes;
34
35 const UNITS = [
36 { label: "px", value: "px" },
37 { label: "em", value: "em" },
38 { label: "%", value: "%" },
39 ];
40
41 const neededProps = {
42 resOption,
43 baseLabel,
44 forBorderRadius,
45 setAttributes,
46 dimensionIsLinked,
47 controlName,
48 };
49
50 return (
51 <>
52 {resOption == "Desktop" && (
53 <>
54 <UnitControl
55 selectedUnit={dimensionUnit}
56 unitTypes={UNITS}
57 onClick={(dimensionUnit) =>
58 setAttributes({ [`${controlName}Unit`]: dimensionUnit })
59 }
60 />
61
62 <DimensionsControl
63 top={dimensionTop}
64 right={dimensionRight}
65 bottom={dimensionBottom}
66 left={dimensionLeft}
67 neededProps={neededProps}
68 disableLeftRight={disableLeftRight}
69 onChange={({ top, right, bottom, left }) =>
70 setAttributes({
71 [`${controlName}Top`]: top,
72 [`${controlName}Right`]: right,
73 [`${controlName}Bottom`]: bottom,
74 [`${controlName}Left`]: left,
75 })
76 }
77 />
78 </>
79 )}
80 {resOption == "Tablet" && (
81 <>
82 <UnitControl
83 selectedUnit={TABdimensionUnit}
84 unitTypes={UNITS}
85 onClick={(TABdimensionUnit) =>
86 setAttributes({ [`TAB${controlName}Unit`]: TABdimensionUnit })
87 }
88 />
89
90 <DimensionsControl
91 top={TABdimensionTop}
92 right={TABdimensionRight}
93 bottom={TABdimensionBottom}
94 left={TABdimensionLeft}
95 neededProps={neededProps}
96 disableLeftRight={disableLeftRight}
97 onChange={({ top, right, bottom, left }) =>
98 setAttributes({
99 [`TAB${controlName}Top`]: top,
100 [`TAB${controlName}Right`]: right,
101 [`TAB${controlName}Bottom`]: bottom,
102 [`TAB${controlName}Left`]: left,
103 })
104 }
105 />
106 </>
107 )}
108 {resOption == "Mobile" && (
109 <>
110 <UnitControl
111 selectedUnit={MOBdimensionUnit}
112 unitTypes={UNITS}
113 onClick={(MOBdimensionUnit) =>
114 setAttributes({ [`MOB${controlName}Unit`]: MOBdimensionUnit })
115 }
116 />
117
118 <DimensionsControl
119 top={MOBdimensionTop}
120 right={MOBdimensionRight}
121 bottom={MOBdimensionBottom}
122 left={MOBdimensionLeft}
123 neededProps={neededProps}
124 disableLeftRight={disableLeftRight}
125 onChange={({ top, right, bottom, left }) =>
126 setAttributes({
127 [`MOB${controlName}Top`]: top,
128 [`MOB${controlName}Right`]: right,
129 [`MOB${controlName}Bottom`]: bottom,
130 [`MOB${controlName}Left`]: left,
131 })
132 }
133 />
134 </>
135 )}
136 </>
137 );
138 }
139