'use client'; import { Plus, Eye, EyeOff, Trash2 } from 'lucide-react'; import { useCalculateStore } from '@/lib/calculate/store'; import { cn } from '@/lib/utils'; import GraphCanvas from './GraphCanvas'; export function GraphPanel() { const { graphFunctions, variables, addGraphFunction, updateGraphFunction, removeGraphFunction, } = useCalculateStore(); return (
{/* ── Function list ────────────────────────────────────── */}
Functions — use x as variable
{graphFunctions.map((fn, i) => (
{/* Color swatch / color picker */}
updateGraphFunction(fn.id, { color: e.target.value })} className="absolute inset-0 opacity-0 cursor-pointer w-full h-full" title="Change color" />
{/* Index label */} f{i + 1} {/* Expression input */} updateGraphFunction(fn.id, { expression: e.target.value })} placeholder={i === 0 ? 'sin(x)' : i === 1 ? 'x^2 / 4' : 'f(x)…'} className={cn( 'flex-1 min-w-0 bg-transparent border border-border/35 rounded px-2 py-1', 'text-sm font-mono outline-none transition-colors', 'placeholder:text-muted-foreground/30', 'focus:border-primary/50', !fn.visible && 'opacity-40' )} /> {/* Visibility toggle */} {/* Delete */} {graphFunctions.length > 1 && ( )}
))}
{/* ── Canvas ───────────────────────────────────────────── */}
); }