import React, { useState } from 'react'; import type { Drawing, DrawingStyle } from '../types'; import { useDraggablePanel } from '../hooks/useDraggablePanel'; const PRESET_COLORS = [ '#FF6D00','#FF5722','#EF5350','#E91E63','#9C27B0', '#673AB7','#3F51B5','#2196F3','#03A9F4','#00BCD4', '#009688','#4CAF50','#8BC34A','#CDDC39','#FFC107', '#FF9800','#795548','#9E9E9E','#607D8B','#FFFFFF', ]; const LINE_WIDTHS = [1, 2, 3, 4] as const; const LINE_STYLES: { value: DrawingStyle; label: string }[] = [ { value: 'solid', label: '실선' }, { value: 'dashed', label: '파선' }, { value: 'dotted', label: '점선' }, ]; interface Props { drawing: Drawing; onSave: (updated: Drawing) => void; onCancel: () => void; } const DrawingSettingsModal: React.FC = ({ drawing, onSave, onCancel }) => { const [color, setColor] = useState(drawing.color); const [lineWidth, setLineWidth] = useState(drawing.lineWidth); const [style, setStyle] = useState(drawing.style); const [text, setText] = useState(drawing.text ?? ''); const handleSave = () => { onSave({ ...drawing, color, lineWidth, style, ...(drawing.type === 'text' ? { text: text.trim() || drawing.text } : {}), }); }; const { panelRef, dragging, onHeaderPointerDown, headerTouchStyle, panelStyle, headerCursor, } = useDraggablePanel({ centerOnMount: true }); return (
{ if (e.target === e.currentTarget) onCancel(); }} >
e.stopPropagation()} >
드로잉 설정
{/* 색상 */}
색상
{PRESET_COLORS.map(c => (
{/* 선 굵기 (pencil·text·measure 제외) */} {drawing.type !== 'text' && drawing.type !== 'measure' && (
선 굵기
{LINE_WIDTHS.map(w => ( ))}
)} {/* 선 스타일 (hline, vline, trendline, ray, channel 계열) */} {!['text', 'measure', 'pencil', 'fib', 'rect'].includes(drawing.type) && (
선 스타일
{LINE_STYLES.map(({ value, label }) => ( ))}
)} {/* 텍스트 (text 타입만) */} {drawing.type === 'text' && (
텍스트
setText(e.target.value)} style={{ width: '100%', boxSizing: 'border-box', background: 'rgba(255,255,255,0.05)', border: '1px solid var(--border, rgba(122,162,247,0.25))', borderRadius: 4, padding: '6px 8px', color: 'inherit', fontSize: 13, }} />
)} {/* 버튼 */}
); }; export default DrawingSettingsModal;