@promakeai/inspector 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +111 -0
  2. package/dist/App.d.ts.map +1 -0
  3. package/dist/__tests__/App.test.d.ts.map +1 -0
  4. package/dist/components/Badge.d.ts.map +1 -0
  5. package/dist/components/ControlBox/ContentArea.d.ts.map +1 -0
  6. package/dist/components/ControlBox/PromptInput.d.ts.map +1 -0
  7. package/dist/components/ControlBox/index.d.ts.map +1 -0
  8. package/dist/components/ImageEditor/UploadBox.d.ts.map +1 -0
  9. package/dist/components/ImageEditor/index.d.ts.map +1 -0
  10. package/dist/components/Overlay.d.ts.map +1 -0
  11. package/dist/components/StyleEditor/BorderSection.d.ts.map +1 -0
  12. package/dist/components/StyleEditor/ColorPicker.d.ts.map +1 -0
  13. package/dist/components/StyleEditor/DisplaySection.d.ts.map +1 -0
  14. package/dist/components/StyleEditor/ImageSection.d.ts.map +1 -0
  15. package/dist/components/StyleEditor/LayoutSection.d.ts.map +1 -0
  16. package/dist/components/StyleEditor/NumberInput.d.ts.map +1 -0
  17. package/dist/components/StyleEditor/SliderInput.d.ts.map +1 -0
  18. package/dist/components/StyleEditor/SpacingSection.d.ts.map +1 -0
  19. package/dist/components/StyleEditor/TextSection.d.ts.map +1 -0
  20. package/dist/components/StyleEditor/index.d.ts.map +1 -0
  21. package/dist/components/TextEditor/index.d.ts.map +1 -0
  22. package/dist/components/ui/CustomCollapsible.d.ts.map +1 -0
  23. package/dist/components/ui/button.d.ts.map +1 -0
  24. package/dist/components/ui/color-picker.d.ts.map +1 -0
  25. package/dist/components/ui/input.d.ts.map +1 -0
  26. package/dist/components/ui/popover.d.ts.map +1 -0
  27. package/dist/components/ui/select.d.ts.map +1 -0
  28. package/dist/components/ui/slider.d.ts.map +1 -0
  29. package/dist/components/ui/textarea.d.ts.map +1 -0
  30. package/dist/components/ui/tooltip.d.ts.map +1 -0
  31. package/dist/core/highlighter.d.ts.map +1 -0
  32. package/dist/hooks/useMessageBridge.d.ts.map +1 -0
  33. package/dist/hooks/useStylePreview.d.ts.map +1 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/lib/utils.d.ts.map +1 -0
  36. package/dist/plugin.d.ts.map +1 -0
  37. package/dist/store/useInspectorStore.d.ts.map +1 -0
  38. package/dist/styles.d.ts.map +1 -0
  39. package/dist/utils/colorUtils.d.ts.map +1 -0
  40. package/dist/utils/elementNames.d.ts.map +1 -0
  41. package/dist/utils/elementUtils.d.ts.map +1 -0
  42. package/dist/utils/errorTracker.d.ts.map +1 -0
  43. package/dist/utils/inputStyles.d.ts.map +1 -0
  44. package/dist/utils/styleUtils.d.ts.map +1 -0
  45. package/dist/utils/tailwindMapper.d.ts.map +1 -0
  46. package/dist/utils/urlTracker.d.ts.map +1 -0
  47. package/package.json +15 -10
  48. package/dist/packages/inspector/src/App.d.ts.map +0 -1
  49. package/dist/packages/inspector/src/__tests__/App.test.d.ts.map +0 -1
  50. package/dist/packages/inspector/src/components/Badge.d.ts.map +0 -1
  51. package/dist/packages/inspector/src/components/ControlBox/ContentArea.d.ts.map +0 -1
  52. package/dist/packages/inspector/src/components/ControlBox/PromptInput.d.ts.map +0 -1
  53. package/dist/packages/inspector/src/components/ControlBox/index.d.ts.map +0 -1
  54. package/dist/packages/inspector/src/components/ImageEditor/UploadBox.d.ts.map +0 -1
  55. package/dist/packages/inspector/src/components/ImageEditor/index.d.ts.map +0 -1
  56. package/dist/packages/inspector/src/components/Overlay.d.ts.map +0 -1
  57. package/dist/packages/inspector/src/components/StyleEditor/BorderSection.d.ts.map +0 -1
  58. package/dist/packages/inspector/src/components/StyleEditor/ColorPicker.d.ts.map +0 -1
  59. package/dist/packages/inspector/src/components/StyleEditor/DisplaySection.d.ts.map +0 -1
  60. package/dist/packages/inspector/src/components/StyleEditor/ImageSection.d.ts.map +0 -1
  61. package/dist/packages/inspector/src/components/StyleEditor/LayoutSection.d.ts.map +0 -1
  62. package/dist/packages/inspector/src/components/StyleEditor/NumberInput.d.ts.map +0 -1
  63. package/dist/packages/inspector/src/components/StyleEditor/SliderInput.d.ts.map +0 -1
  64. package/dist/packages/inspector/src/components/StyleEditor/SpacingSection.d.ts.map +0 -1
  65. package/dist/packages/inspector/src/components/StyleEditor/TextSection.d.ts.map +0 -1
  66. package/dist/packages/inspector/src/components/StyleEditor/index.d.ts.map +0 -1
  67. package/dist/packages/inspector/src/components/TextEditor/index.d.ts.map +0 -1
  68. package/dist/packages/inspector/src/components/ui/CustomCollapsible.d.ts.map +0 -1
  69. package/dist/packages/inspector/src/components/ui/button.d.ts.map +0 -1
  70. package/dist/packages/inspector/src/components/ui/color-picker.d.ts.map +0 -1
  71. package/dist/packages/inspector/src/components/ui/input.d.ts.map +0 -1
  72. package/dist/packages/inspector/src/components/ui/popover.d.ts.map +0 -1
  73. package/dist/packages/inspector/src/components/ui/select.d.ts.map +0 -1
  74. package/dist/packages/inspector/src/components/ui/slider.d.ts.map +0 -1
  75. package/dist/packages/inspector/src/components/ui/textarea.d.ts.map +0 -1
  76. package/dist/packages/inspector/src/components/ui/tooltip.d.ts.map +0 -1
  77. package/dist/packages/inspector/src/core/highlighter.d.ts.map +0 -1
  78. package/dist/packages/inspector/src/hooks/useMessageBridge.d.ts.map +0 -1
  79. package/dist/packages/inspector/src/hooks/useStylePreview.d.ts.map +0 -1
  80. package/dist/packages/inspector/src/index.d.ts.map +0 -1
  81. package/dist/packages/inspector/src/lib/utils.d.ts.map +0 -1
  82. package/dist/packages/inspector/src/plugin.d.ts.map +0 -1
  83. package/dist/packages/inspector/src/store/useInspectorStore.d.ts.map +0 -1
  84. package/dist/packages/inspector/src/styles.d.ts.map +0 -1
  85. package/dist/packages/inspector/src/utils/colorUtils.d.ts.map +0 -1
  86. package/dist/packages/inspector/src/utils/elementNames.d.ts.map +0 -1
  87. package/dist/packages/inspector/src/utils/elementUtils.d.ts.map +0 -1
  88. package/dist/packages/inspector/src/utils/errorTracker.d.ts.map +0 -1
  89. package/dist/packages/inspector/src/utils/inputStyles.d.ts.map +0 -1
  90. package/dist/packages/inspector/src/utils/styleUtils.d.ts.map +0 -1
  91. package/dist/packages/inspector/src/utils/tailwindMapper.d.ts.map +0 -1
  92. package/dist/packages/inspector/src/utils/urlTracker.d.ts.map +0 -1
  93. package/dist/packages/inspector/tsconfig.tsbuildinfo +0 -1
  94. package/src/App.tsx +0 -912
  95. package/src/__tests__/App.test.tsx +0 -373
  96. package/src/assets/fonts/Satoshi-Variable.woff +0 -0
  97. package/src/assets/fonts/Satoshi-Variable.woff2 +0 -0
  98. package/src/components/Badge.tsx +0 -118
  99. package/src/components/ControlBox/ContentArea.tsx +0 -13
  100. package/src/components/ControlBox/PromptInput.module.css +0 -66
  101. package/src/components/ControlBox/PromptInput.tsx +0 -104
  102. package/src/components/ControlBox/index.module.css +0 -81
  103. package/src/components/ControlBox/index.tsx +0 -409
  104. package/src/components/ImageEditor/UploadBox.module.css +0 -69
  105. package/src/components/ImageEditor/UploadBox.tsx +0 -113
  106. package/src/components/ImageEditor/index.module.css +0 -11
  107. package/src/components/ImageEditor/index.tsx +0 -84
  108. package/src/components/Overlay.tsx +0 -157
  109. package/src/components/StyleEditor/BorderSection.tsx +0 -147
  110. package/src/components/StyleEditor/ColorPicker.tsx +0 -182
  111. package/src/components/StyleEditor/DisplaySection.tsx +0 -349
  112. package/src/components/StyleEditor/ImageSection.tsx +0 -105
  113. package/src/components/StyleEditor/LayoutSection.tsx +0 -63
  114. package/src/components/StyleEditor/NumberInput.tsx +0 -138
  115. package/src/components/StyleEditor/SliderInput.tsx +0 -121
  116. package/src/components/StyleEditor/SpacingSection.tsx +0 -365
  117. package/src/components/StyleEditor/TextSection.tsx +0 -381
  118. package/src/components/StyleEditor/index.module.css +0 -133
  119. package/src/components/StyleEditor/index.tsx +0 -612
  120. package/src/components/StyleEditor/shared.module.css +0 -193
  121. package/src/components/TextEditor/index.module.css +0 -31
  122. package/src/components/TextEditor/index.tsx +0 -166
  123. package/src/components/ui/CustomCollapsible.tsx +0 -159
  124. package/src/components/ui/button.module.css +0 -141
  125. package/src/components/ui/button.tsx +0 -73
  126. package/src/components/ui/color-picker.module.css +0 -112
  127. package/src/components/ui/color-picker.tsx +0 -146
  128. package/src/components/ui/input.module.css +0 -49
  129. package/src/components/ui/input.tsx +0 -34
  130. package/src/components/ui/popover.module.css +0 -42
  131. package/src/components/ui/popover.tsx +0 -59
  132. package/src/components/ui/select.module.css +0 -160
  133. package/src/components/ui/select.tsx +0 -216
  134. package/src/components/ui/slider.module.css +0 -75
  135. package/src/components/ui/slider.tsx +0 -60
  136. package/src/components/ui/textarea.module.css +0 -30
  137. package/src/components/ui/textarea.tsx +0 -23
  138. package/src/components/ui/tooltip.module.css +0 -11
  139. package/src/components/ui/tooltip.tsx +0 -37
  140. package/src/core/highlighter.ts +0 -197
  141. package/src/hooks/useMessageBridge.ts +0 -49
  142. package/src/hooks/useStylePreview.ts +0 -332
  143. package/src/index.ts +0 -20
  144. package/src/lib/utils.ts +0 -5
  145. package/src/plugin.ts +0 -11
  146. package/src/store/useInspectorStore.ts +0 -235
  147. package/src/styles/fonts.css +0 -15
  148. package/src/styles/global.css +0 -138
  149. package/src/styles/variables.css +0 -151
  150. package/src/styles.ts +0 -5
  151. package/src/utils/colorUtils.ts +0 -133
  152. package/src/utils/elementNames.ts +0 -103
  153. package/src/utils/elementUtils.ts +0 -90
  154. package/src/utils/errorTracker.ts +0 -186
  155. package/src/utils/inputStyles.ts +0 -30
  156. package/src/utils/styleUtils.ts +0 -226
  157. package/src/utils/tailwindMapper.ts +0 -554
  158. package/src/utils/urlTracker.ts +0 -75
  159. package/src/vite-env.d.ts +0 -7
  160. /package/dist/{packages/inspector/src/App.d.ts → App.d.ts} +0 -0
  161. /package/dist/{packages/inspector/src/__tests__ → __tests__}/App.test.d.ts +0 -0
  162. /package/dist/{packages/inspector/src/components → components}/Badge.d.ts +0 -0
  163. /package/dist/{packages/inspector/src/components → components}/ControlBox/ContentArea.d.ts +0 -0
  164. /package/dist/{packages/inspector/src/components → components}/ControlBox/PromptInput.d.ts +0 -0
  165. /package/dist/{packages/inspector/src/components → components}/ControlBox/index.d.ts +0 -0
  166. /package/dist/{packages/inspector/src/components → components}/ImageEditor/UploadBox.d.ts +0 -0
  167. /package/dist/{packages/inspector/src/components → components}/ImageEditor/index.d.ts +0 -0
  168. /package/dist/{packages/inspector/src/components → components}/Overlay.d.ts +0 -0
  169. /package/dist/{packages/inspector/src/components → components}/StyleEditor/BorderSection.d.ts +0 -0
  170. /package/dist/{packages/inspector/src/components → components}/StyleEditor/ColorPicker.d.ts +0 -0
  171. /package/dist/{packages/inspector/src/components → components}/StyleEditor/DisplaySection.d.ts +0 -0
  172. /package/dist/{packages/inspector/src/components → components}/StyleEditor/ImageSection.d.ts +0 -0
  173. /package/dist/{packages/inspector/src/components → components}/StyleEditor/LayoutSection.d.ts +0 -0
  174. /package/dist/{packages/inspector/src/components → components}/StyleEditor/NumberInput.d.ts +0 -0
  175. /package/dist/{packages/inspector/src/components → components}/StyleEditor/SliderInput.d.ts +0 -0
  176. /package/dist/{packages/inspector/src/components → components}/StyleEditor/SpacingSection.d.ts +0 -0
  177. /package/dist/{packages/inspector/src/components → components}/StyleEditor/TextSection.d.ts +0 -0
  178. /package/dist/{packages/inspector/src/components → components}/StyleEditor/index.d.ts +0 -0
  179. /package/dist/{packages/inspector/src/components → components}/TextEditor/index.d.ts +0 -0
  180. /package/dist/{packages/inspector/src/components → components}/ui/CustomCollapsible.d.ts +0 -0
  181. /package/dist/{packages/inspector/src/components → components}/ui/button.d.ts +0 -0
  182. /package/dist/{packages/inspector/src/components → components}/ui/color-picker.d.ts +0 -0
  183. /package/dist/{packages/inspector/src/components → components}/ui/input.d.ts +0 -0
  184. /package/dist/{packages/inspector/src/components → components}/ui/popover.d.ts +0 -0
  185. /package/dist/{packages/inspector/src/components → components}/ui/select.d.ts +0 -0
  186. /package/dist/{packages/inspector/src/components → components}/ui/slider.d.ts +0 -0
  187. /package/dist/{packages/inspector/src/components → components}/ui/textarea.d.ts +0 -0
  188. /package/dist/{packages/inspector/src/components → components}/ui/tooltip.d.ts +0 -0
  189. /package/dist/{packages/inspector/src/core → core}/highlighter.d.ts +0 -0
  190. /package/dist/{packages/inspector/src/hooks → hooks}/useMessageBridge.d.ts +0 -0
  191. /package/dist/{packages/inspector/src/hooks → hooks}/useStylePreview.d.ts +0 -0
  192. /package/dist/{packages/inspector/src/index.d.ts → index.d.ts} +0 -0
  193. /package/dist/{packages/inspector/src/lib → lib}/utils.d.ts +0 -0
  194. /package/dist/{packages/inspector/src/plugin.d.ts → plugin.d.ts} +0 -0
  195. /package/dist/{packages/inspector/src/store → store}/useInspectorStore.d.ts +0 -0
  196. /package/dist/{packages/inspector/src/styles.d.ts → styles.d.ts} +0 -0
  197. /package/dist/{packages/inspector/src/utils → utils}/colorUtils.d.ts +0 -0
  198. /package/dist/{packages/inspector/src/utils → utils}/elementNames.d.ts +0 -0
  199. /package/dist/{packages/inspector/src/utils → utils}/elementUtils.d.ts +0 -0
  200. /package/dist/{packages/inspector/src/utils → utils}/errorTracker.d.ts +0 -0
  201. /package/dist/{packages/inspector/src/utils → utils}/inputStyles.d.ts +0 -0
  202. /package/dist/{packages/inspector/src/utils → utils}/styleUtils.d.ts +0 -0
  203. /package/dist/{packages/inspector/src/utils → utils}/tailwindMapper.d.ts +0 -0
  204. /package/dist/{packages/inspector/src/utils → utils}/urlTracker.d.ts +0 -0
@@ -1,121 +0,0 @@
1
- /**
2
- * SliderInput - Canva-style slider with synchronized number input
3
- */
4
-
5
- import { RotateCcw } from "lucide-react";
6
- import { useInspectorStore } from "../../store/useInspectorStore";
7
-
8
- interface SliderInputProps {
9
- label: string;
10
- value: string;
11
- min: number;
12
- max: number;
13
- unit?: string;
14
- onChange: (value: string) => void;
15
- originalValue?: string;
16
- onReset?: () => void;
17
- }
18
-
19
- export function SliderInput({
20
- label,
21
- value,
22
- min,
23
- max,
24
- unit = "px",
25
- onChange,
26
- originalValue,
27
- onReset,
28
- }: SliderInputProps) {
29
- const { theme } = useInspectorStore();
30
- const hasChanged = originalValue !== undefined && value !== originalValue;
31
-
32
- // Parse numeric value from string (e.g., "16px" -> 16)
33
- const numericValue = parseFloat(value) || 0;
34
-
35
- const handleSliderChange = (e: Event) => {
36
- const target = e.target as HTMLInputElement;
37
- const newValue = target.value;
38
- onChange(`${newValue}${unit}`);
39
- };
40
-
41
- const handleNumberChange = (e: Event) => {
42
- const target = e.target as HTMLInputElement;
43
- let newValue = parseFloat(target.value) || 0;
44
-
45
- // Clamp value
46
- newValue = Math.max(min, Math.min(max, newValue));
47
-
48
- onChange(`${newValue}${unit}`);
49
- };
50
-
51
- return (
52
- <div style={{ marginBottom: "12px" }}>
53
- <label
54
- style={{
55
- display: "flex",
56
- justifyContent: "space-between",
57
- alignItems: "center",
58
- marginBottom: "4px",
59
- fontSize: "12px",
60
- color: theme.textColor || "#6b7280",
61
- }}
62
- >
63
- <div style={{ display: "flex", alignItems: "center", gap: "6px" }}>
64
- <span>{label}</span>
65
- {hasChanged && onReset && (
66
- <button
67
- type="button"
68
- onClick={onReset}
69
- style={{
70
- background: "none",
71
- border: "none",
72
- padding: "2px",
73
- cursor: "pointer",
74
- display: "flex",
75
- alignItems: "center",
76
- color: theme.secondaryTextColor || "#9ca3af",
77
- opacity: 0.7,
78
- }}
79
- title="Reset to original"
80
- onMouseEnter={(e) => (e.currentTarget.style.opacity = "1")}
81
- onMouseLeave={(e) => (e.currentTarget.style.opacity = "0.7")}
82
- >
83
- <RotateCcw size={12} />
84
- </button>
85
- )}
86
- </div>
87
- <input
88
- type="number"
89
- value={numericValue}
90
- onInput={(e) => handleNumberChange(e as unknown as Event)}
91
- min={min}
92
- max={max}
93
- style={{
94
- width: "60px",
95
- padding: "4px 8px",
96
- border: "1px solid #e5e7eb",
97
- borderRadius: "4px",
98
- textAlign: "right",
99
- fontSize: "12px",
100
- fontFamily: "monospace",
101
- }}
102
- />
103
- </label>
104
- <input
105
- type="range"
106
- min={min}
107
- max={max}
108
- value={numericValue}
109
- onInput={(e) => handleSliderChange(e as unknown as Event)}
110
- style={{
111
- width: "100%",
112
- height: "6px",
113
- background: "#e5e7eb",
114
- borderRadius: "3px",
115
- outline: "none",
116
- cursor: "pointer",
117
- }}
118
- />
119
- </div>
120
- );
121
- }
@@ -1,365 +0,0 @@
1
- /**
2
- * SpacingSection - Padding and Margin (Vertical & Horizontal or All Sides)
3
- */
4
-
5
- import { useState, useEffect, useRef } from "react";
6
- import type { StyleChanges } from "@promakeai/inspector-types";
7
- import { NumberInput } from "./NumberInput";
8
- import { SplitSquareVertical, Grid3x3 } from "lucide-react";
9
- import { useInspectorStore } from "../../store/useInspectorStore";
10
- import styles from "./shared.module.css";
11
-
12
- interface SpacingSectionProps {
13
- styles: StyleChanges;
14
- onChange: (property: keyof StyleChanges, value: string) => void;
15
- originalStyles: StyleChanges;
16
- onResetProperty: (property: keyof StyleChanges) => void;
17
- }
18
-
19
- type SpacingMode = "vh" | "all"; // vh = vertical/horizontal, all = all sides
20
-
21
- export function SpacingSection({
22
- styles: styleValues,
23
- onChange,
24
- originalStyles,
25
- onResetProperty,
26
- }: SpacingSectionProps) {
27
- const { labels, theme } = useInspectorStore();
28
- const [paddingMode, setPaddingMode] = useState<SpacingMode>("vh");
29
- const [marginMode, setMarginMode] = useState<SpacingMode>("all");
30
-
31
- const prevPaddingMode = useRef<SpacingMode>("vh");
32
- const prevMarginMode = useRef<SpacingMode>("all");
33
-
34
- // Smart auto-fill for padding mode changes
35
- useEffect(() => {
36
- if (prevPaddingMode.current !== paddingMode) {
37
- if (prevPaddingMode.current === "vh" && paddingMode === "all") {
38
- // VH → All Sides: vertical → top/bottom, horizontal → left/right
39
- const vertical = styleValues.paddingVertical || styleValues.paddingTop || "0px";
40
- const horizontal = styleValues.paddingHorizontal || styleValues.paddingLeft || "0px";
41
-
42
- onChange("paddingTop", vertical);
43
- onChange("paddingBottom", vertical);
44
- onChange("paddingLeft", horizontal);
45
- onChange("paddingRight", horizontal);
46
- } else if (prevPaddingMode.current === "all" && paddingMode === "vh") {
47
- // All Sides → VH: use top for vertical, left for horizontal (or pick smallest if different)
48
- const top = styleValues.paddingTop || "0px";
49
- const bottom = styleValues.paddingBottom || "0px";
50
- const left = styleValues.paddingLeft || "0px";
51
- const right = styleValues.paddingRight || "0px";
52
-
53
- // Parse values
54
- const topVal = parseFloat(top);
55
- const bottomVal = parseFloat(bottom);
56
- const leftVal = parseFloat(left);
57
- const rightVal = parseFloat(right);
58
-
59
- // Use minimum non-zero value, or the first value
60
- const verticalVal = topVal > 0 || bottomVal > 0 ? Math.min(topVal || 999999, bottomVal || 999999) : 0;
61
- const horizontalVal = leftVal > 0 || rightVal > 0 ? Math.min(leftVal || 999999, rightVal || 999999) : 0;
62
-
63
- onChange("paddingVertical", verticalVal > 0 ? `${verticalVal}px` : "0px");
64
- onChange("paddingHorizontal", horizontalVal > 0 ? `${horizontalVal}px` : "0px");
65
- }
66
- prevPaddingMode.current = paddingMode;
67
- }
68
- }, [paddingMode, styleValues, onChange]);
69
-
70
- // Smart auto-fill for margin mode changes
71
- useEffect(() => {
72
- if (prevMarginMode.current !== marginMode) {
73
- if (prevMarginMode.current === "vh" && marginMode === "all") {
74
- // VH → All Sides: vertical → top/bottom, horizontal → left/right
75
- const vertical = styleValues.marginVertical || styleValues.marginTop || "0px";
76
- const horizontal = styleValues.marginHorizontal || styleValues.marginLeft || "0px";
77
-
78
- onChange("marginTop", vertical);
79
- onChange("marginBottom", vertical);
80
- onChange("marginLeft", horizontal);
81
- onChange("marginRight", horizontal);
82
- } else if (prevMarginMode.current === "all" && marginMode === "vh") {
83
- // All Sides → VH: use top for vertical, left for horizontal (or pick smallest if different)
84
- const top = styleValues.marginTop || "0px";
85
- const bottom = styleValues.marginBottom || "0px";
86
- const left = styleValues.marginLeft || "0px";
87
- const right = styleValues.marginRight || "0px";
88
-
89
- // Parse values
90
- const topVal = parseFloat(top);
91
- const bottomVal = parseFloat(bottom);
92
- const leftVal = parseFloat(left);
93
- const rightVal = parseFloat(right);
94
-
95
- // Use minimum non-zero value, or the first value
96
- const verticalVal = topVal > 0 || bottomVal > 0 ? Math.min(topVal || 999999, bottomVal || 999999) : 0;
97
- const horizontalVal = leftVal > 0 || rightVal > 0 ? Math.min(leftVal || 999999, rightVal || 999999) : 0;
98
-
99
- onChange("marginVertical", verticalVal > 0 ? `${verticalVal}px` : "0px");
100
- onChange("marginHorizontal", horizontalVal > 0 ? `${horizontalVal}px` : "0px");
101
- }
102
- prevMarginMode.current = marginMode;
103
- }
104
- }, [marginMode, styleValues, onChange]);
105
-
106
- return (
107
- <div className={styles.section}>
108
- {/* Padding */}
109
- <div>
110
- <div
111
- style={{
112
- display: "flex",
113
- alignItems: "center",
114
- justifyContent: "space-between",
115
- marginBottom: "var(--spacing-2)",
116
- }}
117
- >
118
- <div className={styles.sectionTitle} style={{ color: theme.textColor }}>
119
- {labels.paddingLabel || "Padding"}
120
- </div>
121
- <div style={{ display: "flex", gap: "4px" }}>
122
- <button
123
- type="button"
124
- onClick={() => setPaddingMode("vh")}
125
- style={{
126
- background: "none",
127
- border: "none",
128
- padding: "4px",
129
- cursor: "pointer",
130
- display: "flex",
131
- alignItems: "center",
132
- color: theme.textColor,
133
- opacity: paddingMode === "vh" ? 1 : 0.4,
134
- fontWeight: paddingMode === "vh" ? "bold" : "normal",
135
- }}
136
- title="Vertical/Horizontal mode"
137
- >
138
- <SplitSquareVertical size={16} />
139
- </button>
140
- <button
141
- type="button"
142
- onClick={() => setPaddingMode("all")}
143
- style={{
144
- background: "none",
145
- border: "none",
146
- padding: "4px",
147
- cursor: "pointer",
148
- display: "flex",
149
- alignItems: "center",
150
- color: theme.textColor,
151
- opacity: paddingMode === "all" ? 1 : 0.4,
152
- fontWeight: paddingMode === "all" ? "bold" : "normal",
153
- }}
154
- title="All sides mode"
155
- >
156
- <Grid3x3 size={16} />
157
- </button>
158
- </div>
159
- </div>
160
-
161
- {paddingMode === "vh" ? (
162
- <div className={styles.grid2}>
163
- <NumberInput
164
- label={labels.paddingVerticalLabel || "Vertical"}
165
- value={styleValues.paddingVertical}
166
- onChange={(value) => onChange("paddingVertical", value)}
167
- min={0}
168
- max={500}
169
- step={1}
170
- unit="px"
171
- originalValue={originalStyles.paddingVertical}
172
- onReset={() => onResetProperty("paddingVertical")}
173
- />
174
- <NumberInput
175
- label={labels.paddingHorizontalLabel || "Horizontal"}
176
- value={styleValues.paddingHorizontal}
177
- onChange={(value) => onChange("paddingHorizontal", value)}
178
- min={0}
179
- max={500}
180
- step={1}
181
- unit="px"
182
- originalValue={originalStyles.paddingHorizontal}
183
- onReset={() => onResetProperty("paddingHorizontal")}
184
- />
185
- </div>
186
- ) : (
187
- <div className={styles.grid2}>
188
- <NumberInput
189
- label="Top"
190
- value={styleValues.paddingTop}
191
- onChange={(value) => onChange("paddingTop", value)}
192
- min={0}
193
- max={500}
194
- step={1}
195
- unit="px"
196
- originalValue={originalStyles.paddingTop}
197
- onReset={() => onResetProperty("paddingTop")}
198
- />
199
- <NumberInput
200
- label="Right"
201
- value={styleValues.paddingRight}
202
- onChange={(value) => onChange("paddingRight", value)}
203
- min={0}
204
- max={500}
205
- step={1}
206
- unit="px"
207
- originalValue={originalStyles.paddingRight}
208
- onReset={() => onResetProperty("paddingRight")}
209
- />
210
- <NumberInput
211
- label="Bottom"
212
- value={styleValues.paddingBottom}
213
- onChange={(value) => onChange("paddingBottom", value)}
214
- min={0}
215
- max={500}
216
- step={1}
217
- unit="px"
218
- originalValue={originalStyles.paddingBottom}
219
- onReset={() => onResetProperty("paddingBottom")}
220
- />
221
- <NumberInput
222
- label="Left"
223
- value={styleValues.paddingLeft}
224
- onChange={(value) => onChange("paddingLeft", value)}
225
- min={0}
226
- max={500}
227
- step={1}
228
- unit="px"
229
- originalValue={originalStyles.paddingLeft}
230
- onReset={() => onResetProperty("paddingLeft")}
231
- />
232
- </div>
233
- )}
234
- </div>
235
-
236
- {/* Margin */}
237
- <div>
238
- <div
239
- style={{
240
- display: "flex",
241
- alignItems: "center",
242
- justifyContent: "space-between",
243
- marginBottom: "var(--spacing-2)",
244
- }}
245
- >
246
- <div className={styles.sectionTitle} style={{ color: theme.textColor }}>
247
- {labels.marginLabel || "Margin"}
248
- </div>
249
- <div style={{ display: "flex", gap: "4px" }}>
250
- <button
251
- type="button"
252
- onClick={() => setMarginMode("vh")}
253
- style={{
254
- background: "none",
255
- border: "none",
256
- padding: "4px",
257
- cursor: "pointer",
258
- display: "flex",
259
- alignItems: "center",
260
- color: theme.textColor,
261
- opacity: marginMode === "vh" ? 1 : 0.4,
262
- fontWeight: marginMode === "vh" ? "bold" : "normal",
263
- }}
264
- title="Vertical/Horizontal mode"
265
- >
266
- <SplitSquareVertical size={16} />
267
- </button>
268
- <button
269
- type="button"
270
- onClick={() => setMarginMode("all")}
271
- style={{
272
- background: "none",
273
- border: "none",
274
- padding: "4px",
275
- cursor: "pointer",
276
- display: "flex",
277
- alignItems: "center",
278
- color: theme.textColor,
279
- opacity: marginMode === "all" ? 1 : 0.4,
280
- fontWeight: marginMode === "all" ? "bold" : "normal",
281
- }}
282
- title="All sides mode"
283
- >
284
- <Grid3x3 size={16} />
285
- </button>
286
- </div>
287
- </div>
288
-
289
- {marginMode === "vh" ? (
290
- <div className={styles.grid2}>
291
- <NumberInput
292
- label={labels.marginVerticalLabel || "Vertical"}
293
- value={styleValues.marginVertical}
294
- onChange={(value) => onChange("marginVertical", value)}
295
- min={0}
296
- max={500}
297
- step={1}
298
- unit="px"
299
- originalValue={originalStyles.marginVertical}
300
- onReset={() => onResetProperty("marginVertical")}
301
- />
302
- <NumberInput
303
- label={labels.marginHorizontalLabel || "Horizontal"}
304
- value={styleValues.marginHorizontal}
305
- onChange={(value) => onChange("marginHorizontal", value)}
306
- min={0}
307
- max={500}
308
- step={1}
309
- unit="px"
310
- originalValue={originalStyles.marginHorizontal}
311
- onReset={() => onResetProperty("marginHorizontal")}
312
- />
313
- </div>
314
- ) : (
315
- <div className={styles.grid2}>
316
- <NumberInput
317
- label="Top"
318
- value={styleValues.marginTop}
319
- onChange={(value) => onChange("marginTop", value)}
320
- min={0}
321
- max={500}
322
- step={1}
323
- unit="px"
324
- originalValue={originalStyles.marginTop}
325
- onReset={() => onResetProperty("marginTop")}
326
- />
327
- <NumberInput
328
- label="Right"
329
- value={styleValues.marginRight}
330
- onChange={(value) => onChange("marginRight", value)}
331
- min={0}
332
- max={500}
333
- step={1}
334
- unit="px"
335
- originalValue={originalStyles.marginRight}
336
- onReset={() => onResetProperty("marginRight")}
337
- />
338
- <NumberInput
339
- label="Bottom"
340
- value={styleValues.marginBottom}
341
- onChange={(value) => onChange("marginBottom", value)}
342
- min={0}
343
- max={500}
344
- step={1}
345
- unit="px"
346
- originalValue={originalStyles.marginBottom}
347
- onReset={() => onResetProperty("marginBottom")}
348
- />
349
- <NumberInput
350
- label="Left"
351
- value={styleValues.marginLeft}
352
- onChange={(value) => onChange("marginLeft", value)}
353
- min={0}
354
- max={500}
355
- step={1}
356
- unit="px"
357
- originalValue={originalStyles.marginLeft}
358
- onReset={() => onResetProperty("marginLeft")}
359
- />
360
- </div>
361
- )}
362
- </div>
363
- </div>
364
- );
365
- }