'use client'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { Button } from '@/components/ui/button'; import { Infinity } from 'lucide-react'; import type { AnimationConfig } from '@/types/animate'; interface Props { config: AnimationConfig; onChange: (config: AnimationConfig) => void; } const EASINGS = [ { value: 'linear', label: 'Linear' }, { value: 'ease', label: 'Ease' }, { value: 'ease-in', label: 'Ease In' }, { value: 'ease-out', label: 'Ease Out' }, { value: 'ease-in-out', label: 'Ease In Out' }, { value: 'cubic-bezier', label: 'Cubic Bézier' }, { value: 'steps(4, end)', label: 'Steps (4)' }, { value: 'steps(8, end)', label: 'Steps (8)' }, ]; export function AnimationSettings({ config, onChange }: Props) { const set = (key: K, value: AnimationConfig[K]) => onChange({ ...config, [key]: value }); const isInfinite = config.iterationCount === 'infinite'; const isCubic = config.easing === 'cubic-bezier'; // Parse cubic-bezier values from string like "cubic-bezier(x1,y1,x2,y2)" const cubicValues = (() => { const m = config.easing.match(/cubic-bezier\(([^)]+)\)/); if (!m) return [0.25, 0.1, 0.25, 1.0]; return m[1].split(',').map(Number); })(); const setCubic = (index: number, val: number) => { const v = [...cubicValues]; v[index] = val; set('easing', `cubic-bezier(${v.join(',')})`); }; return ( Settings {/* Name */}
{ const val = e.target.value.replace(/\s+/g, '-').replace(/[^a-zA-Z0-9-_]/g, ''); set('name', val || 'myAnimation'); }} className="font-mono text-xs" />
{/* Duration + Delay */}
set('duration', Math.max(50, Number(e.target.value)))} /> ms
set('delay', Math.max(0, Number(e.target.value)))} /> ms
{/* Easing */}
{/* Cubic-bezier inputs */} {isCubic && (
{(['P1x', 'P1y', 'P2x', 'P2y'] as const).map((label, i) => (
setCubic(i, Number(e.target.value))} className="text-xs px-1.5" />
))}
)} {/* Iteration */}
set('iterationCount', Math.max(1, Number(e.target.value)))} className="text-xs flex-1" placeholder="1" />
{/* Direction */}
{/* Fill Mode */}
); }