import React, { useState } from 'react'; import type { Drawing, FibTZSettings, FibTZLevel, FibTZBaseline, DrawingStyle } from '../types'; import { DEFAULT_FIB_TZ_SETTINGS } from '../types'; import { useDraggablePanel } from '../hooks/useDraggablePanel'; const LINE_STYLES: { value: DrawingStyle; label: string }[] = [ { value: 'solid', label: '━━' }, { value: 'dashed', label: '╌╌' }, { value: 'dotted', label: '···' }, ]; const LINE_WIDTHS = [1, 2, 3, 4] as const; // ─── Sub-components ────────────────────────────────────────────────────────── function ColorCell({ color, onChange, }: { color: string; onChange: (c: string) => void; }) { return ( ); } function StyleSelect({ value, onChange, }: { value: DrawingStyle; onChange: (s: DrawingStyle) => void; }) { return ( ); } function WidthSelect({ value, onChange, }: { value: number; onChange: (w: number) => void; }) { return ( ); } // ─── Main component ─────────────────────────────────────────────────────────── interface Props { drawing: Drawing; onSave: (updated: Drawing) => void; onCancel: () => void; } const FibTZSettingsModal: React.FC = ({ drawing, onSave, onCancel }) => { const init = drawing.fibtzSettings ?? DEFAULT_FIB_TZ_SETTINGS; const [baseline, setBaseline] = useState({ ...init.baseline }); const [levels, setLevels] = useState( init.levels.map(l => ({ ...l })) ); const updateBaseline = (patch: Partial) => setBaseline(prev => ({ ...prev, ...patch })); const updateLevel = (idx: number, patch: Partial) => setLevels(prev => prev.map((l, i) => i === idx ? { ...l, ...patch } : l)); const handleReset = () => { setBaseline({ ...DEFAULT_FIB_TZ_SETTINGS.baseline }); setLevels(DEFAULT_FIB_TZ_SETTINGS.levels.map(l => ({ ...l }))); }; const handleSave = () => { const settings: FibTZSettings = { baseline, levels }; onSave({ ...drawing, fibtzSettings: settings }); }; const cellStyle: React.CSSProperties = { display: 'flex', alignItems: 'center', justifyContent: 'center', }; const headerStyle: React.CSSProperties = { fontSize: 10, color: 'rgba(192,202,245,0.55)', textAlign: 'center', paddingBottom: 6, }; const { panelRef, dragging, onHeaderPointerDown, headerTouchStyle, panelStyle, headerCursor, } = useDraggablePanel({ centerOnMount: true }); return (
{ if (e.target === e.currentTarget) onCancel(); }} >
e.stopPropagation()} >
피보나치 타임존 설정
{/* ── 기준선 (0) ── */}
기준선 (항상 표시)
{/* 항상 활성화 표시 */}
updateBaseline({ color: c })} /> updateBaseline({ style: s })} /> updateBaseline({ lineWidth: w })} />
{/* ── 레벨 목록 ── */}
레벨
{/* 헤더 행 */}
표시
색상
스타일
두께
{/* 레벨 행들 */}
{levels.map((lv, idx) => (
{/* 표시 체크박스 */}
{/* 값 (편집 가능) */} updateLevel(idx, { value: Math.max(1, Number(e.target.value)) })} style={{ width: '100%', background: 'rgba(255,255,255,0.06)', border: '1px solid rgba(122,162,247,0.25)', borderRadius: 3, color: 'inherit', fontSize: 12, padding: '3px 5px', textAlign: 'center', }} /> {/* 색상 */} updateLevel(idx, { color: c })} /> {/* 스타일 */} updateLevel(idx, { style: s })} /> {/* 두께 */} updateLevel(idx, { lineWidth: w })} />
))}
{/* 버튼 영역 */}
); }; export default FibTZSettingsModal;