"use client"; import { useState, useEffect } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Button } from "@/components/ui/button"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Separator } from "@/components/ui/separator"; import { Palette, Layout, Type, Square, Box, Eye, RotateCcw } from "lucide-react"; import { ComponentStyle } from "@/types/screen"; interface StyleEditorProps { style: ComponentStyle; onStyleChange: (style: ComponentStyle) => void; className?: string; } export default function StyleEditor({ style, onStyleChange, className }: StyleEditorProps) { const [localStyle, setLocalStyle] = useState(style); useEffect(() => { setLocalStyle(style); }, [style]); const handleStyleChange = (property: keyof ComponentStyle, value: any) => { const newStyle = { ...localStyle, [property]: value }; setLocalStyle(newStyle); onStyleChange(newStyle); }; const resetStyle = () => { const resetStyle: ComponentStyle = {}; setLocalStyle(resetStyle); onStyleChange(resetStyle); }; const applyStyle = () => { onStyleChange(localStyle); }; return (
스타일 편집
레이아웃 여백 테두리 배경 텍스트 {/* 레이아웃 탭 */}
handleStyleChange("width", e.target.value)} />
handleStyleChange("height", e.target.value)} />
{localStyle.display === "flex" && ( <>
)}
{/* 여백 탭 */}
handleStyleChange("margin", e.target.value)} />
handleStyleChange("padding", e.target.value)} />
handleStyleChange("gap", e.target.value)} />
{/* 테두리 탭 */}
handleStyleChange("borderWidth", e.target.value)} />
handleStyleChange("borderColor", e.target.value)} />
handleStyleChange("borderRadius", e.target.value)} />
{/* 배경 탭 */}
handleStyleChange("backgroundColor", e.target.value)} />
handleStyleChange("backgroundImage", e.target.value)} />
{/* 텍스트 탭 */}
handleStyleChange("color", e.target.value)} />
handleStyleChange("fontSize", e.target.value)} />
); }