"use client"; import { useState, useEffect } from "react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; import { Palette, Type, Square, ChevronDown } from "lucide-react"; import { ComponentStyle } from "@/types/screen"; import { ColorPickerWithTransparent } from "./common/ColorPickerWithTransparent"; interface StyleEditorProps { style: ComponentStyle; onStyleChange: (style: ComponentStyle) => void; className?: string; } export default function StyleEditor({ style, onStyleChange, className }: StyleEditorProps) { const [localStyle, setLocalStyle] = useState(style || {}); const [openSections, setOpenSections] = useState>({ border: false, background: false, text: false, }); useEffect(() => { setLocalStyle(style || {}); }, [style]); const handleStyleChange = (property: keyof ComponentStyle, value: any) => { const newStyle = { ...localStyle, [property]: value }; setLocalStyle(newStyle); onStyleChange(newStyle); }; const toggleSection = (section: string) => { setOpenSections((prev) => ({ ...prev, [section]: !prev[section], })); }; return (
{/* 테두리 섹션 */} toggleSection("border")}>
테두리
handleStyleChange("borderWidth", e.target.value)} className="h-6 w-full px-2 py-0 text-xs" />
handleStyleChange("borderColor", value)} defaultColor="#e5e7eb" placeholder="#e5e7eb" />
handleStyleChange("borderRadius", e.target.value)} className="h-6 w-full px-2 py-0 text-xs" />
{/* 배경 섹션 */} toggleSection("background")}>
배경
handleStyleChange("backgroundColor", value)} defaultColor="#ffffff" placeholder="#ffffff" />
handleStyleChange("backgroundImage", e.target.value)} className="h-6 w-full px-2 py-0 text-xs" />

위젯 배경 꾸미기용 (고급 사용자 전용)

{/* 텍스트 섹션 */} toggleSection("text")}>
텍스트
handleStyleChange("color", value)} defaultColor="#000000" placeholder="#000000" />
handleStyleChange("fontSize", e.target.value)} className="h-6 w-full px-2 py-0 text-xs" />
); }