'use client'; import { useState } from 'react'; import { useLayerEffectsStore } from '@/store/layer-effects-store'; import { useToastStore } from '@/store/toast-store'; import type { EffectType, LayerEffect } from '@/types/layer-effects'; import { Sparkles, Eye, EyeOff, Trash2, Copy, Plus, Settings, ChevronDown, ChevronRight, } from 'lucide-react'; import { cn } from '@/lib/utils'; interface LayerEffectsPanelProps { layerId: string; } const EFFECT_NAMES: Record = { dropShadow: 'Drop Shadow', innerShadow: 'Inner Shadow', outerGlow: 'Outer Glow', innerGlow: 'Inner Glow', stroke: 'Stroke', bevel: 'Bevel & Emboss', colorOverlay: 'Color Overlay', gradientOverlay: 'Gradient Overlay', patternOverlay: 'Pattern Overlay', satin: 'Satin', }; const EFFECT_ICONS: Record = { dropShadow: , innerShadow: , outerGlow: , innerGlow: , stroke: , bevel: , colorOverlay: , gradientOverlay: , patternOverlay: , satin: , }; export function LayerEffectsPanel({ layerId }: LayerEffectsPanelProps) { const { getLayerEffects, addEffect, removeEffect, toggleEffect, duplicateEffect, setLayerEffectsEnabled, } = useLayerEffectsStore(); const { addToast } = useToastStore(); const [isExpanded, setIsExpanded] = useState(true); const [showAddMenu, setShowAddMenu] = useState(false); const effectsConfig = getLayerEffects(layerId); const hasEffects = effectsConfig && effectsConfig.effects.length > 0; const handleAddEffect = (effectType: EffectType) => { addEffect(layerId, effectType); setShowAddMenu(false); addToast(`Added ${EFFECT_NAMES[effectType]}`, 'success'); }; const handleRemoveEffect = (effectId: string, effectType: EffectType) => { removeEffect(layerId, effectId); addToast(`Removed ${EFFECT_NAMES[effectType]}`, 'success'); }; const handleToggleEffect = (effectId: string) => { toggleEffect(layerId, effectId); }; const handleDuplicateEffect = (effectId: string, effectType: EffectType) => { duplicateEffect(layerId, effectId); addToast(`Duplicated ${EFFECT_NAMES[effectType]}`, 'success'); }; const handleToggleAll = () => { if (effectsConfig) { setLayerEffectsEnabled(layerId, !effectsConfig.enabled); } }; if (!hasEffects && !isExpanded) { return (
); } return (
{/* Header */}
{hasEffects && ( )}
{isExpanded && (
{/* Effects List */} {hasEffects && (
{effectsConfig.effects.map((effect) => (
{/* Effect Icon & Name */}
{EFFECT_ICONS[effect.type]} {EFFECT_NAMES[effect.type]}
{/* Actions */}
))}
)} {/* Add Effect Button */}
{/* Add Effect Menu */} {showAddMenu && ( <>
setShowAddMenu(false)} />
)}
)}
); }