"use client"; /** * V2SplitLine 설정 패널 * 토스식 UX: 리사이즈 Switch -> 두께 카드 선택 -> 색상 설정 */ import React, { useState } from "react"; import { Input } from "@/components/ui/input"; import { Switch } from "@/components/ui/switch"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { Settings, ChevronDown } from "lucide-react"; import { cn } from "@/lib/utils"; const WIDTH_CARDS = [ { value: 2, label: "얇게" }, { value: 4, label: "보통" }, { value: 6, label: "두껍게" }, { value: 8, label: "넓게" }, ] as const; const COLOR_CARDS = [ { value: "#e2e8f0", label: "기본", description: "연한 회색" }, { value: "#94a3b8", label: "진하게", description: "중간 회색" }, { value: "#3b82f6", label: "강조", description: "파란색" }, ] as const; interface V2SplitLineConfigPanelProps { config: Record; onConfigChange: (config: Record) => void; } export const V2SplitLineConfigPanel: React.FC = ({ config, onConfigChange, }) => { const [advancedOpen, setAdvancedOpen] = useState(false); const currentConfig = config || {}; const updateConfig = (field: string, value: any) => { const newConfig = { ...currentConfig, [field]: value }; onConfigChange(newConfig); if (typeof window !== "undefined") { window.dispatchEvent( new CustomEvent("componentConfigChanged", { detail: { config: newConfig }, }) ); } }; return (
{/* ─── 1단계: 드래그 리사이즈 ─── */}

드래그 리사이즈

런타임에서 드래그로 좌우 영역을 조절할 수 있어요

updateConfig("resizable", checked)} />
{/* ─── 2단계: 분할선 두께 카드 선택 ─── */}

분할선 두께

{WIDTH_CARDS.map((card) => { const isSelected = (currentConfig.lineWidth || 4) === card.value; return ( ); })}

현재: {currentConfig.lineWidth || 4}px

{/* ─── 3단계: 분할선 색상 카드 선택 ─── */}

분할선 색상

{COLOR_CARDS.map((card) => { const isSelected = (currentConfig.lineColor || "#e2e8f0") === card.value; return ( ); })}
{/* ─── 고급 설정: 커스텀 색상 입력 ─── */}
{/* 커스텀 색상 입력 */}
직접 입력
updateConfig("lineColor", e.target.value)} className="h-7 w-7 cursor-pointer rounded border" /> updateConfig("lineColor", e.target.value)} placeholder="#e2e8f0" className="h-7 w-[100px] text-xs" />
{/* 커스텀 두께 입력 */}
두께 직접 입력 (px) updateConfig("lineWidth", parseInt(e.target.value) || 4) } className="h-7 w-[80px] text-xs" min={1} max={12} />

캔버스에서 스플릿선의 X 위치가 초기 분할 지점이 돼요. 런타임에서 드래그하면 좌우 컴포넌트가 함께 이동해요.

); }; V2SplitLineConfigPanel.displayName = "V2SplitLineConfigPanel"; export default V2SplitLineConfigPanel;