'use client'; import { useToolStore } from '@/store'; import { useShapeStore } from '@/store/shape-store'; import { useSelectionStore } from '@/store/selection-store'; import { useTextStore } from '@/store/text-store'; import { WEB_SAFE_FONTS, GOOGLE_FONTS } from '@/lib/text-utils'; import { googleFontsLoader } from '@/lib/google-fonts-loader'; import { useCallback } from 'react'; export function ToolOptions() { const { activeTool, settings, setSize, setOpacity, setHardness, setColor, setFlow, setSecondaryColor, setGradientType } = useToolStore(); const { settings: shapeSettings, setShapeType } = useShapeStore(); const { selectionType, setSelectionType } = useSelectionStore(); const { settings: textSettings, setFontFamily, setFontSize, setFontStyle, setFontWeight, setAlign, setLineHeight, setLetterSpacing, setColor: setTextColor, } = useTextStore(); // Handle font change with Google Fonts loading const handleFontChange = useCallback( async (fontFamily: string) => { // Check if it's a Google Font if (GOOGLE_FONTS.includes(fontFamily as any)) { try { await googleFontsLoader.loadFont(fontFamily); } catch (error) { console.error('Failed to load Google Font:', error); } } setFontFamily(fontFamily); }, [setFontFamily] ); // 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'; // Gradient tool const isGradientTool = activeTool === 'gradient'; // Crop tool const isCropTool = activeTool === 'crop'; // Shape tool const isShapeTool = activeTool === 'shape'; // Selection tool const isSelectionTool = activeTool === 'select'; // Text tool const isTextTool = activeTool === 'text'; // Don't show options bar if no options available if (!isDrawingTool && !isFillTool && !isGradientTool && !isCropTool && !isShapeTool && !isSelectionTool && !isTextTool) { return null; } return (