/** * Preset Gallery - Browse and apply effect presets */ import { Paintbrush, Palette, Plus, Search, Sparkles, Star, Wrench } from "lucide-react" import { useRef, useState } from "react" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import type { EffectPreset } from "../services/effect-pipeline-manager" import { EffectPipelineManager } from "../services/effect-pipeline-manager" interface PresetGalleryProps { onPresetApplied?: (presetId: string) => void className?: string } export function PresetGallery({ onPresetApplied, className }: PresetGalleryProps) { const [searchQuery, setSearchQuery] = useState("") const [selectedCategory, setSelectedCategory] = useState("all") const pipelineManager = useRef( new EffectPipelineManager("medium", { resolution: 1.0, effects: "all", fps: 30, antialiasing: true, }), ) const categories = [ { id: "all", label: "All", icon: Sparkles }, { id: "color", label: "Color", icon: Palette }, { id: "style", label: "Style", icon: Paintbrush }, { id: "correction", label: "Correction", icon: Wrench }, { id: "artistic", label: "Artistic", icon: Star }, { id: "custom", label: "Custom", icon: Plus }, ] const getPresets = (): EffectPreset[] => { let presets = pipelineManager.current.getPresetsByCategory( selectedCategory === "all" ? undefined : selectedCategory, ) if (searchQuery) { const query = searchQuery.toLowerCase() presets = presets.filter( (preset) => preset.name.toLowerCase().includes(query) || preset.description?.toLowerCase().includes(query), ) } return presets } const applyPreset = (presetId: string) => { const chain = pipelineManager.current.createChainFromPreset(presetId) if (chain && onPresetApplied) { onPresetApplied(presetId) } } const getPresetThumbnail = (preset: EffectPreset): string => { // Generate CSS gradient based on preset effects if (preset.effects.length === 0) return "linear-gradient(45deg, #666, #999)" const effect = preset.effects[0] if (effect.type === "color_correction") { const params = effect.parameters || {} const temp = params.temperature || 0 const tint = params.tint || 0 if (temp > 10) return "linear-gradient(45deg, #ff8c42, #ff6b35)" // Warm if (temp < -10) return "linear-gradient(45deg, #4285f4, #34a853)" // Cool if (params.saturation === 0) return "linear-gradient(45deg, #333, #777)" // B&W } if (effect.type === "vignette") { return "radial-gradient(circle, transparent 30%, #000 100%)" } if (effect.type === "blur") { return "linear-gradient(45deg, rgba(255,255,255,0.3), rgba(0,0,0,0.3))" } // Default gradient const colors = ["#667eea", "#764ba2", "#f093fb", "#f5576c", "#4facfe"] const color1 = colors[preset.id.charCodeAt(0) % colors.length] const color2 = colors[preset.id.charCodeAt(1) % colors.length] return `linear-gradient(135deg, ${color1}, ${color2})` } const presets = getPresets() return (
No presets found
{searchQuery ? "Try a different search term" : "No presets in this category"}
{preset.description}
)}