@promakeai/inspector 0.2.1 → 1.0.0
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.
- package/dist/inspector.css +1 -0
- package/dist/inspector.js +8740 -0
- package/dist/packages/inspector/src/App.d.ts +5 -0
- package/dist/packages/inspector/src/App.d.ts.map +1 -0
- package/dist/packages/inspector/src/__tests__/App.test.d.ts +5 -0
- package/dist/packages/inspector/src/__tests__/App.test.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/Badge.d.ts +9 -0
- package/dist/packages/inspector/src/components/Badge.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ControlBox/ContentArea.d.ts +10 -0
- package/dist/packages/inspector/src/components/ControlBox/ContentArea.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ControlBox/PromptInput.d.ts +12 -0
- package/dist/packages/inspector/src/components/ControlBox/PromptInput.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ControlBox/index.d.ts +21 -0
- package/dist/packages/inspector/src/components/ControlBox/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ImageEditor/UploadBox.d.ts +10 -0
- package/dist/packages/inspector/src/components/ImageEditor/UploadBox.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ImageEditor/index.d.ts +11 -0
- package/dist/packages/inspector/src/components/ImageEditor/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/Overlay.d.ts +11 -0
- package/dist/packages/inspector/src/components/Overlay.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/BorderSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/BorderSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/ColorPicker.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/ColorPicker.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/DisplaySection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/DisplaySection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/ImageSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/ImageSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/LayoutSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/LayoutSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/NumberInput.d.ts +17 -0
- package/dist/packages/inspector/src/components/StyleEditor/NumberInput.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/SliderInput.d.ts +16 -0
- package/dist/packages/inspector/src/components/StyleEditor/SliderInput.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/SpacingSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/SpacingSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/TextSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/TextSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/index.d.ts +12 -0
- package/dist/packages/inspector/src/components/StyleEditor/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/TextEditor/index.d.ts +11 -0
- package/dist/packages/inspector/src/components/TextEditor/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/CustomCollapsible.d.ts +26 -0
- package/dist/packages/inspector/src/components/ui/CustomCollapsible.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/button.d.ts +9 -0
- package/dist/packages/inspector/src/components/ui/button.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/color-picker.d.ts +10 -0
- package/dist/packages/inspector/src/components/ui/color-picker.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/input.d.ts +6 -0
- package/dist/packages/inspector/src/components/ui/input.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/popover.d.ts +8 -0
- package/dist/packages/inspector/src/components/ui/popover.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/select.d.ts +16 -0
- package/dist/packages/inspector/src/components/ui/select.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/slider.d.ts +5 -0
- package/dist/packages/inspector/src/components/ui/slider.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/textarea.d.ts +4 -0
- package/dist/packages/inspector/src/components/ui/textarea.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/tooltip.d.ts +8 -0
- package/dist/packages/inspector/src/components/ui/tooltip.d.ts.map +1 -0
- package/dist/packages/inspector/src/core/highlighter.d.ts +40 -0
- package/dist/packages/inspector/src/core/highlighter.d.ts.map +1 -0
- package/dist/packages/inspector/src/hooks/useMessageBridge.d.ts +9 -0
- package/dist/packages/inspector/src/hooks/useMessageBridge.d.ts.map +1 -0
- package/dist/packages/inspector/src/hooks/useStylePreview.d.ts +11 -0
- package/dist/packages/inspector/src/hooks/useStylePreview.d.ts.map +1 -0
- package/dist/packages/inspector/src/index.d.ts +16 -0
- package/dist/packages/inspector/src/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/lib/utils.d.ts +3 -0
- package/dist/packages/inspector/src/lib/utils.d.ts.map +1 -0
- package/dist/packages/inspector/src/plugin.d.ts +4 -0
- package/dist/packages/inspector/src/plugin.d.ts.map +1 -0
- package/dist/packages/inspector/src/store/useInspectorStore.d.ts +13 -0
- package/dist/packages/inspector/src/store/useInspectorStore.d.ts.map +1 -0
- package/dist/packages/inspector/src/styles.d.ts +5 -0
- package/dist/packages/inspector/src/styles.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/colorUtils.d.ts +49 -0
- package/dist/packages/inspector/src/utils/colorUtils.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/elementNames.d.ts +7 -0
- package/dist/packages/inspector/src/utils/elementNames.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/elementUtils.d.ts +28 -0
- package/dist/packages/inspector/src/utils/elementUtils.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/errorTracker.d.ts +48 -0
- package/dist/packages/inspector/src/utils/errorTracker.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/inputStyles.d.ts +23 -0
- package/dist/packages/inspector/src/utils/inputStyles.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/styleUtils.d.ts +27 -0
- package/dist/packages/inspector/src/utils/styleUtils.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/tailwindMapper.d.ts +9 -0
- package/dist/packages/inspector/src/utils/tailwindMapper.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/urlTracker.d.ts +27 -0
- package/dist/packages/inspector/src/utils/urlTracker.d.ts.map +1 -0
- package/dist/packages/inspector/tsconfig.tsbuildinfo +1 -0
- package/dist/plugin.js +10 -1813
- package/package.json +86 -76
- package/src/App.tsx +912 -0
- package/src/__tests__/App.test.tsx +373 -0
- package/src/assets/fonts/Satoshi-Variable.woff +0 -0
- package/src/assets/fonts/Satoshi-Variable.woff2 +0 -0
- package/src/components/Badge.tsx +118 -0
- package/src/components/ControlBox/ContentArea.tsx +13 -0
- package/src/components/ControlBox/PromptInput.module.css +66 -0
- package/src/components/ControlBox/PromptInput.tsx +104 -0
- package/src/components/ControlBox/index.module.css +81 -0
- package/src/components/ControlBox/index.tsx +409 -0
- package/src/components/ImageEditor/UploadBox.module.css +69 -0
- package/src/components/ImageEditor/UploadBox.tsx +113 -0
- package/src/components/ImageEditor/index.module.css +11 -0
- package/src/components/ImageEditor/index.tsx +84 -0
- package/src/components/Overlay.tsx +157 -0
- package/src/components/StyleEditor/BorderSection.tsx +147 -0
- package/src/components/StyleEditor/ColorPicker.tsx +182 -0
- package/src/components/StyleEditor/DisplaySection.tsx +349 -0
- package/src/components/StyleEditor/ImageSection.tsx +105 -0
- package/src/components/StyleEditor/LayoutSection.tsx +63 -0
- package/src/components/StyleEditor/NumberInput.tsx +138 -0
- package/src/components/StyleEditor/SliderInput.tsx +121 -0
- package/src/components/StyleEditor/SpacingSection.tsx +365 -0
- package/src/components/StyleEditor/TextSection.tsx +381 -0
- package/src/components/StyleEditor/index.module.css +133 -0
- package/src/components/StyleEditor/index.tsx +612 -0
- package/src/components/StyleEditor/shared.module.css +193 -0
- package/src/components/TextEditor/index.module.css +31 -0
- package/src/components/TextEditor/index.tsx +166 -0
- package/src/components/ui/CustomCollapsible.tsx +159 -0
- package/src/components/ui/button.module.css +141 -0
- package/src/components/ui/button.tsx +73 -0
- package/src/components/ui/color-picker.module.css +112 -0
- package/src/components/ui/color-picker.tsx +146 -0
- package/src/components/ui/input.module.css +49 -0
- package/src/components/ui/input.tsx +34 -0
- package/src/components/ui/popover.module.css +42 -0
- package/src/components/ui/popover.tsx +59 -0
- package/src/components/ui/select.module.css +160 -0
- package/src/components/ui/select.tsx +216 -0
- package/src/components/ui/slider.module.css +75 -0
- package/src/components/ui/slider.tsx +60 -0
- package/src/components/ui/textarea.module.css +30 -0
- package/src/components/ui/textarea.tsx +23 -0
- package/src/components/ui/tooltip.module.css +11 -0
- package/src/components/ui/tooltip.tsx +37 -0
- package/src/core/highlighter.ts +197 -0
- package/src/hooks/useMessageBridge.ts +49 -0
- package/src/hooks/useStylePreview.ts +332 -0
- package/src/index.ts +20 -0
- package/src/lib/utils.ts +5 -0
- package/src/plugin.ts +11 -0
- package/src/store/useInspectorStore.ts +235 -0
- package/src/styles/fonts.css +15 -0
- package/src/styles/global.css +138 -0
- package/src/styles/variables.css +151 -0
- package/src/styles.ts +5 -0
- package/src/utils/colorUtils.ts +133 -0
- package/src/utils/elementNames.ts +103 -0
- package/src/utils/elementUtils.ts +90 -0
- package/src/utils/errorTracker.ts +186 -0
- package/src/utils/inputStyles.ts +30 -0
- package/src/utils/styleUtils.ts +226 -0
- package/src/utils/tailwindMapper.ts +554 -0
- package/src/utils/urlTracker.ts +75 -0
- package/src/vite-env.d.ts +7 -0
- package/README.md +0 -866
- package/dist/hook.d.ts +0 -115
- package/dist/hook.d.ts.map +0 -1
- package/dist/hook.js +0 -288
- package/dist/plugin.d.ts +0 -44
- package/dist/plugin.d.ts.map +0 -1
- package/dist/types.d.ts +0 -139
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -7
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { useInspectorStore } from "../../store/useInspectorStore";
|
|
5
|
+
import styles from "./button.module.css";
|
|
6
|
+
|
|
7
|
+
interface ButtonProps extends React.ComponentProps<"button"> {
|
|
8
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
|
|
9
|
+
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg";
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function Button({
|
|
14
|
+
className,
|
|
15
|
+
variant = "default",
|
|
16
|
+
size = "default",
|
|
17
|
+
asChild = false,
|
|
18
|
+
style,
|
|
19
|
+
...props
|
|
20
|
+
}: ButtonProps) {
|
|
21
|
+
const Comp = asChild ? Slot : "button";
|
|
22
|
+
const { theme } = useInspectorStore();
|
|
23
|
+
|
|
24
|
+
// Map size prop to CSS module class name
|
|
25
|
+
const sizeClassName = size === "icon" ? "sizeIcon"
|
|
26
|
+
: size === "icon-sm" ? "sizeIconSm"
|
|
27
|
+
: size === "icon-lg" ? "sizeIconLg"
|
|
28
|
+
: `size${size.charAt(0).toUpperCase()}${size.slice(1)}`;
|
|
29
|
+
|
|
30
|
+
// Theme-based styles applied via inline styles
|
|
31
|
+
const variantStyles: Record<string, React.CSSProperties> = {
|
|
32
|
+
default: {
|
|
33
|
+
background: theme.buttonColor,
|
|
34
|
+
color: theme.buttonTextColor,
|
|
35
|
+
},
|
|
36
|
+
destructive: {
|
|
37
|
+
background: theme.dangerButtonColor || theme.errorColor,
|
|
38
|
+
color: "#ffffff",
|
|
39
|
+
},
|
|
40
|
+
outline: {
|
|
41
|
+
background: theme.backgroundColor,
|
|
42
|
+
color: theme.textColor,
|
|
43
|
+
borderColor: theme.borderColor,
|
|
44
|
+
},
|
|
45
|
+
secondary: {
|
|
46
|
+
background: theme.secondaryButtonColor || theme.inputBackgroundColor,
|
|
47
|
+
color: theme.secondaryButtonTextColor || theme.textColor,
|
|
48
|
+
},
|
|
49
|
+
ghost: {
|
|
50
|
+
background: "transparent",
|
|
51
|
+
color: theme.textColor,
|
|
52
|
+
},
|
|
53
|
+
link: {
|
|
54
|
+
background: "transparent",
|
|
55
|
+
color: theme.buttonColor,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Comp
|
|
61
|
+
data-slot="button"
|
|
62
|
+
className={clsx(
|
|
63
|
+
styles[variant],
|
|
64
|
+
styles[sizeClassName],
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
style={{ ...variantStyles[variant], ...style }}
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { Button };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
.defaultTrigger {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
border-radius: var(--radius-full);
|
|
6
|
+
height: fit-content;
|
|
7
|
+
width: fit-content;
|
|
8
|
+
aspect-ratio: 1;
|
|
9
|
+
padding: 0.2rem;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.defaultTriggerInner {
|
|
13
|
+
height: 2rem;
|
|
14
|
+
aspect-ratio: 1;
|
|
15
|
+
border-radius: var(--radius-full);
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.defaultTriggerIcon {
|
|
22
|
+
color: var(--color-white);
|
|
23
|
+
width: 1rem;
|
|
24
|
+
aspect-ratio: 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.pickerContent {
|
|
28
|
+
width: 18rem;
|
|
29
|
+
height: 25rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.container {
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.title {
|
|
42
|
+
font-family: 'Satoshi', var(--font-family-sans);
|
|
43
|
+
font-weight: var(--font-medium);
|
|
44
|
+
font-size: var(--text-xl);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.colorPicker {
|
|
48
|
+
width: 100% !important;
|
|
49
|
+
aspect-ratio: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.controls {
|
|
53
|
+
width: 100%;
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 1.5rem;
|
|
58
|
+
margin-top: 0.5rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.hexRow {
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 2.5rem;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.hexLabel {
|
|
70
|
+
font-family: 'Satoshi', var(--font-family-sans);
|
|
71
|
+
margin-right: 0.5rem;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.hexInput {
|
|
75
|
+
width: 100%;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.alphaInput {
|
|
79
|
+
width: 5rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (min-width: 768px) {
|
|
83
|
+
.defaultTrigger {
|
|
84
|
+
padding: 0.2vw;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.defaultTriggerInner {
|
|
88
|
+
height: 2vw;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.defaultTriggerIcon {
|
|
92
|
+
width: 1vw;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.controls {
|
|
96
|
+
gap: 1.5vw;
|
|
97
|
+
margin-top: 0.5vw;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.hexRow {
|
|
101
|
+
height: 2.5vw;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.hexLabel {
|
|
105
|
+
margin-right: 0.5vw;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.alphaInput {
|
|
109
|
+
width: 5vw;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import React, { useCallback, useMemo } from "react";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover";
|
|
4
|
+
import { Pipette } from "lucide-react";
|
|
5
|
+
import { RgbaColorPicker } from "react-colorful";
|
|
6
|
+
import { debounce } from "lodash";
|
|
7
|
+
import { Input } from "./input";
|
|
8
|
+
import styles from "./color-picker.module.css";
|
|
9
|
+
|
|
10
|
+
const DEFAULT_CHILDREN = (
|
|
11
|
+
<div
|
|
12
|
+
className={styles.defaultTrigger}
|
|
13
|
+
style={{
|
|
14
|
+
background: "linear-gradient(to bottom right, rgba(249, 168, 212, 0.2), rgba(196, 180, 255, 0.2), rgba(164, 179, 255, 0.2))",
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
className={styles.defaultTriggerInner}
|
|
19
|
+
style={{
|
|
20
|
+
background: "linear-gradient(to bottom right, #f9a8d4, #c4b4ff, #a4b3ff)",
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<Pipette className={styles.defaultTriggerIcon} />
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
type TColorPicker = {
|
|
29
|
+
value: string;
|
|
30
|
+
onChange: (value: string) => void;
|
|
31
|
+
handleAdd?: (value: string) => void;
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const ColorPicker: React.FC<TColorPicker> = ({
|
|
36
|
+
value,
|
|
37
|
+
onChange,
|
|
38
|
+
handleAdd,
|
|
39
|
+
children = DEFAULT_CHILDREN,
|
|
40
|
+
}) => {
|
|
41
|
+
const color = useMemo(() => {
|
|
42
|
+
const rgba = hexToRgba(value);
|
|
43
|
+
return { hex: value, alpha: rgba ? rgba.a : 1 };
|
|
44
|
+
}, [value]);
|
|
45
|
+
|
|
46
|
+
const debouncedOnChange = useMemo(
|
|
47
|
+
() => debounce((newValue: string) => onChange(newValue), 50),
|
|
48
|
+
[onChange]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const handleChangeAlpha = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
52
|
+
const newAlpha = parseFloat(e.target.value);
|
|
53
|
+
const rgba = hexToRgba(color.hex);
|
|
54
|
+
if (rgba) {
|
|
55
|
+
const newHex = rgbaToHex(rgba.r, rgba.g, rgba.b, newAlpha);
|
|
56
|
+
onChange(newHex);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const handleChangeColor = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
61
|
+
const newColor: any = e.target.value;
|
|
62
|
+
onChange(newColor);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
function rgbaToHex(r: number, g: number, b: number, a: number = 1) {
|
|
66
|
+
const toHex = (n: number) => {
|
|
67
|
+
let hex = n.toString(16);
|
|
68
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const alpha = isNaN(a) ? 255 : Math.round(a * 255);
|
|
72
|
+
|
|
73
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}${
|
|
74
|
+
alpha === 255 ? "" : toHex(alpha)
|
|
75
|
+
}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function hexToRgba(hex: string) {
|
|
79
|
+
if (!hex) return null;
|
|
80
|
+
hex = hex.replace(/^#/, "");
|
|
81
|
+
|
|
82
|
+
if (hex.length === 3) {
|
|
83
|
+
hex = hex
|
|
84
|
+
.split("")
|
|
85
|
+
.map((char) => char + char)
|
|
86
|
+
.join("");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (hex.length !== 6 && hex.length !== 8) return null;
|
|
90
|
+
|
|
91
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
92
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
93
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
94
|
+
const a = hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1;
|
|
95
|
+
|
|
96
|
+
return { r, g, b, a };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const handleColorChange = useCallback(
|
|
100
|
+
(newColor: { r: number; g: number; b: number; a: number }) => {
|
|
101
|
+
const { r, g, b, a } = newColor;
|
|
102
|
+
const newHex = rgbaToHex(r, g, b, a);
|
|
103
|
+
debouncedOnChange(newHex);
|
|
104
|
+
},
|
|
105
|
+
[debouncedOnChange]
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Popover>
|
|
110
|
+
<PopoverTrigger>{children}</PopoverTrigger>
|
|
111
|
+
<PopoverContent align="center" side="top" className={styles.pickerContent}>
|
|
112
|
+
<div className={styles.container}>
|
|
113
|
+
<h1 className={styles.title}>Colour Picker</h1>
|
|
114
|
+
<RgbaColorPicker
|
|
115
|
+
color={hexToRgba(color.hex) as any}
|
|
116
|
+
onChange={handleColorChange}
|
|
117
|
+
className={styles.colorPicker}
|
|
118
|
+
/>
|
|
119
|
+
<div className={styles.controls}>
|
|
120
|
+
<div className={styles.hexRow}>
|
|
121
|
+
<label className={styles.hexLabel}>HEX</label>
|
|
122
|
+
<Input
|
|
123
|
+
className={styles.hexInput}
|
|
124
|
+
style={{ borderTopRightRadius: 0, borderBottomRightRadius: 0, letterSpacing: "0.1em" }}
|
|
125
|
+
value={color.hex}
|
|
126
|
+
onChange={handleChangeColor}
|
|
127
|
+
/>
|
|
128
|
+
<Input
|
|
129
|
+
type="text"
|
|
130
|
+
min="0"
|
|
131
|
+
max="1"
|
|
132
|
+
step="0.01"
|
|
133
|
+
value={color.alpha.toFixed(2)}
|
|
134
|
+
onChange={handleChangeAlpha}
|
|
135
|
+
className={styles.alphaInput}
|
|
136
|
+
style={{ paddingRight: 0, borderTopLeftRadius: 0, borderBottomLeftRadius: 0, letterSpacing: "0.1em" }}
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</PopoverContent>
|
|
142
|
+
</Popover>
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.input {
|
|
2
|
+
height: var(--spacing-9);
|
|
3
|
+
width: 100%;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
border-radius: var(--radius-md);
|
|
6
|
+
border: 1px solid;
|
|
7
|
+
background: transparent;
|
|
8
|
+
font-family: "Satoshi", var(--font-family-sans);
|
|
9
|
+
font-size: var(--text-base);
|
|
10
|
+
box-shadow: none;
|
|
11
|
+
transition: all var(--transition-fast);
|
|
12
|
+
outline: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.input:focus {
|
|
16
|
+
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
|
|
17
|
+
border-color: rgba(59, 130, 246, 0.5);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.input:disabled {
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
cursor: not-allowed;
|
|
23
|
+
opacity: 0.5;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.input::placeholder {
|
|
27
|
+
opacity: 0.6;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.input::selection {
|
|
31
|
+
background-color: var(--color-blue-500);
|
|
32
|
+
color: var(--color-white);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.input::file-selector-button {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
height: var(--spacing-7);
|
|
38
|
+
border: 0;
|
|
39
|
+
background: transparent;
|
|
40
|
+
font-family: "Satoshi", var(--font-family-sans);
|
|
41
|
+
font-size: var(--text-sm);
|
|
42
|
+
font-weight: var(--font-medium);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@media (min-width: 768px) {
|
|
46
|
+
.input {
|
|
47
|
+
font-size: var(--text-sm);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { useInspectorStore } from "../../store/useInspectorStore";
|
|
4
|
+
import styles from "./input.module.css";
|
|
5
|
+
|
|
6
|
+
export interface InputProps
|
|
7
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
8
|
+
|
|
9
|
+
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
10
|
+
({ className, type, style, ...props }, ref) => {
|
|
11
|
+
const { theme } = useInspectorStore();
|
|
12
|
+
|
|
13
|
+
const inputStyles: React.CSSProperties = {
|
|
14
|
+
borderColor: theme.borderColor,
|
|
15
|
+
color: theme.textColor,
|
|
16
|
+
...style,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<input
|
|
21
|
+
type={type}
|
|
22
|
+
data-slot="input"
|
|
23
|
+
className={clsx(styles.input, className)}
|
|
24
|
+
style={inputStyles}
|
|
25
|
+
ref={ref}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
Input.displayName = "Input";
|
|
33
|
+
|
|
34
|
+
export { Input };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.content {
|
|
2
|
+
z-index: var(--z-inspector-popover);
|
|
3
|
+
border-radius: var(--radius-md);
|
|
4
|
+
border: 1px solid;
|
|
5
|
+
box-shadow: var(--shadow-lg);
|
|
6
|
+
outline: none;
|
|
7
|
+
transform-origin: var(--radix-popover-content-transform-origin);
|
|
8
|
+
animation-duration: 150ms;
|
|
9
|
+
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
|
10
|
+
pointer-events: auto;
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.content[data-state="open"] {
|
|
15
|
+
animation-name: fadeIn;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.content[data-state="closed"] {
|
|
19
|
+
animation-name: fadeOut;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@keyframes fadeIn {
|
|
23
|
+
from {
|
|
24
|
+
opacity: 0;
|
|
25
|
+
transform: scale(0.95);
|
|
26
|
+
}
|
|
27
|
+
to {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
transform: scale(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@keyframes fadeOut {
|
|
34
|
+
from {
|
|
35
|
+
opacity: 1;
|
|
36
|
+
transform: scale(1);
|
|
37
|
+
}
|
|
38
|
+
to {
|
|
39
|
+
opacity: 0;
|
|
40
|
+
transform: scale(0.95);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { useInspectorStore } from "../../store/useInspectorStore";
|
|
5
|
+
import styles from "./popover.module.css";
|
|
6
|
+
|
|
7
|
+
// Get inspector root container for portal
|
|
8
|
+
const getInspectorRoot = () => {
|
|
9
|
+
return document.getElementById('inspector-canvas-root') || document.body;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function Popover({
|
|
13
|
+
...props
|
|
14
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
|
15
|
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function PopoverTrigger({
|
|
19
|
+
...props
|
|
20
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
|
21
|
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function PopoverContent({
|
|
25
|
+
className,
|
|
26
|
+
align = "center",
|
|
27
|
+
sideOffset = 4,
|
|
28
|
+
style,
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
31
|
+
const { theme } = useInspectorStore();
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<PopoverPrimitive.Portal container={getInspectorRoot()}>
|
|
35
|
+
<PopoverPrimitive.Content
|
|
36
|
+
data-slot="popover-content"
|
|
37
|
+
data-inspector-ignore
|
|
38
|
+
align={align}
|
|
39
|
+
sideOffset={sideOffset}
|
|
40
|
+
className={clsx(styles.content, className)}
|
|
41
|
+
style={{
|
|
42
|
+
backgroundColor: theme.backgroundColor,
|
|
43
|
+
color: theme.textColor,
|
|
44
|
+
borderColor: theme.borderColor,
|
|
45
|
+
...style,
|
|
46
|
+
}}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
</PopoverPrimitive.Portal>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function PopoverAnchor({
|
|
54
|
+
...props
|
|
55
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
|
56
|
+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
.trigger {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
gap: var(--spacing-2);
|
|
6
|
+
border-radius: var(--radius-md);
|
|
7
|
+
background: transparent;
|
|
8
|
+
font-family: "Satoshi", var(--font-family-sans);
|
|
9
|
+
font-size: var(--text-sm);
|
|
10
|
+
text-align: left;
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
box-shadow: var(--shadow-xs);
|
|
13
|
+
transition: var(--transition-fast);
|
|
14
|
+
outline: none;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.trigger:hover:not(:disabled) {
|
|
19
|
+
opacity: 0.8;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.trigger:disabled {
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
opacity: 0.5;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.trigger[data-size="default"] {
|
|
28
|
+
height: var(--spacing-9);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.trigger[data-size="sm"] {
|
|
32
|
+
height: var(--spacing-8);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.trigger svg {
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
width: 1rem;
|
|
39
|
+
height: 1rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.content {
|
|
43
|
+
position: relative;
|
|
44
|
+
z-index: var(--z-inspector-popover);
|
|
45
|
+
max-height: var(--radix-select-content-available-height);
|
|
46
|
+
min-width: 8rem;
|
|
47
|
+
overflow-x: hidden;
|
|
48
|
+
overflow-y: auto;
|
|
49
|
+
border-radius: var(--radius-md);
|
|
50
|
+
border: 1px solid;
|
|
51
|
+
box-shadow: var(--shadow-lg);
|
|
52
|
+
animation-duration: 150ms;
|
|
53
|
+
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
|
54
|
+
pointer-events: auto;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.content[data-state="open"] {
|
|
58
|
+
animation-name: slideIn;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.content[data-state="closed"] {
|
|
62
|
+
animation-name: slideOut;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@keyframes slideIn {
|
|
66
|
+
from {
|
|
67
|
+
opacity: 0;
|
|
68
|
+
transform: translateY(-4px);
|
|
69
|
+
}
|
|
70
|
+
to {
|
|
71
|
+
opacity: 1;
|
|
72
|
+
transform: translateY(0);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@keyframes slideOut {
|
|
77
|
+
from {
|
|
78
|
+
opacity: 1;
|
|
79
|
+
transform: translateY(0);
|
|
80
|
+
}
|
|
81
|
+
to {
|
|
82
|
+
opacity: 0;
|
|
83
|
+
transform: translateY(-4px);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.viewport {
|
|
88
|
+
padding: var(--spacing-1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.viewportPopper {
|
|
92
|
+
composes: viewport;
|
|
93
|
+
height: var(--radix-select-trigger-height);
|
|
94
|
+
width: 100%;
|
|
95
|
+
min-width: var(--radix-select-trigger-width);
|
|
96
|
+
scroll-margin-block: var(--spacing-1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.scrollButton {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
height: var(--spacing-6);
|
|
104
|
+
cursor: default;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.item {
|
|
108
|
+
position: relative;
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: flex-start;
|
|
112
|
+
gap: var(--spacing-2);
|
|
113
|
+
width: 100%;
|
|
114
|
+
border-radius: var(--radius-sm);
|
|
115
|
+
padding: var(--spacing-1-5) var(--spacing-2);
|
|
116
|
+
padding-left: var(--spacing-8);
|
|
117
|
+
font-family: "Satoshi", var(--font-family-sans);
|
|
118
|
+
font-size: var(--text-sm);
|
|
119
|
+
text-align: left;
|
|
120
|
+
outline: none;
|
|
121
|
+
cursor: pointer;
|
|
122
|
+
user-select: none;
|
|
123
|
+
transition: var(--transition-fast);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.item:hover:not([data-disabled]) {
|
|
127
|
+
opacity: 0.8;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.item:focus {
|
|
131
|
+
opacity: 0.9;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.item[data-disabled] {
|
|
135
|
+
pointer-events: none;
|
|
136
|
+
opacity: 0.5;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.itemIndicator {
|
|
140
|
+
position: absolute;
|
|
141
|
+
left: var(--spacing-2);
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
width: var(--spacing-3-5);
|
|
146
|
+
height: var(--spacing-3-5);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.separator {
|
|
150
|
+
height: 1px;
|
|
151
|
+
margin: var(--spacing-1) calc(var(--spacing-1) * -1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.label {
|
|
155
|
+
padding: var(--spacing-1-5) var(--spacing-2);
|
|
156
|
+
font-family: "Satoshi", var(--font-family-sans);
|
|
157
|
+
font-size: var(--text-sm);
|
|
158
|
+
font-weight: var(--font-semibold);
|
|
159
|
+
text-align: left;
|
|
160
|
+
}
|