'use client'; import { useToolStore } from '@/store'; import { useShapeStore } from '@/store/shape-store'; import { useSelectionStore } from '@/store/selection-store'; export function ToolOptions() { const { activeTool, settings, setSize, setOpacity, setHardness, setColor, setFlow } = useToolStore(); const { settings: shapeSettings, setShapeType } = useShapeStore(); const { selectionType, setSelectionType } = useSelectionStore(); // Drawing tools: brush, pencil, eraser const isDrawingTool = ['brush', 'eraser', 'pencil'].includes(activeTool); const showHardness = ['brush'].includes(activeTool); const showColor = ['brush', 'pencil'].includes(activeTool); const showFlow = ['brush'].includes(activeTool); // Fill tool const isFillTool = activeTool === 'fill'; // Shape tool const isShapeTool = activeTool === 'shape'; // Selection tool const isSelectionTool = activeTool === 'select'; // Don't show options bar if no options available if (!isDrawingTool && !isFillTool && !isShapeTool && !isSelectionTool) { return null; } return (
{/* Drawing Tools Options */} {isDrawingTool && ( <> {showColor && (
setColor(e.target.value)} className="h-8 w-16 rounded border border-border cursor-pointer" /> setColor(e.target.value)} className="w-24 px-2 py-1 text-xs rounded border border-border bg-background text-foreground" />
)}
setSize(Number(e.target.value))} className="w-32" /> {settings.size}px
setOpacity(Number(e.target.value) / 100)} className="w-32" /> {Math.round(settings.opacity * 100)}%
{showHardness && (
setHardness(Number(e.target.value) / 100)} className="w-32" /> {Math.round(settings.hardness * 100)}%
)} {showFlow && (
setFlow(Number(e.target.value) / 100)} className="w-32" /> {Math.round(settings.flow * 100)}%
)} )} {/* Fill Tool Options */} {isFillTool && ( <>
setColor(e.target.value)} className="h-8 w-16 rounded border border-border cursor-pointer" /> setColor(e.target.value)} className="w-24 px-2 py-1 text-xs rounded border border-border bg-background text-foreground" />
setOpacity(Number(e.target.value) / 100)} className="w-32" /> {Math.round(settings.opacity * 100)}%
)} {/* Shape Tool Options */} {isShapeTool && (
)} {/* Selection Tool Options */} {isSelectionTool && (
)}
); }