{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "bg-animated-gradient-demo", "registryDependencies": [ "bg-animated-gradient" ], "files": [ { "path": "registry/default/example/bg-animated-gradient-demo.tsx", "content": "\"use client\"\n\nimport React, { useState } from \"react\"\nimport { Check, Copy, Minus, Plus, Trash2 } from \"lucide-react\"\n\nimport {\n Accordion,\n AccordionContent,\n AccordionItem,\n AccordionTrigger,\n} from \"@/components/ui/accordion\"\nimport { Button } from \"@/components/ui/button\"\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\"\nimport { Input } from \"@/components/ui/input\"\nimport { Label } from \"@/components/ui/label\"\nimport { Slider } from \"@/components/ui/slider\"\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from \"@/components/ui/tabs\"\nimport { useToast } from \"@/components/ui/use-toast\"\n\nimport { GradientAnimation } from \"../ui/bg-animated-gradient\"\n\ntype GradientStop = {\n color: string\n position: number\n}\n\ntype Gradient = {\n stops: GradientStop[]\n centerX: number\n centerY: number\n}\n\nconst initialConfig = {\n animationDuration: 5,\n gradients: [\n {\n stops: [\n { color: \"#3498DB\", position: 0 },\n { color: \"#2980B9\", position: 25 },\n { color: \"#1ABC9C\", position: 50 },\n { color: \"transparent\", position: 75 },\n ],\n centerX: 30,\n centerY: 70,\n },\n {\n stops: [\n { color: \"#16A085\", position: 0 },\n { color: \"#2980B9\", position: 25 },\n { color: \"#3498DB\", position: 50 },\n { color: \"transparent\", position: 75 },\n ],\n centerX: 70,\n centerY: 30,\n },\n ],\n}\n\nexport function ConfigurableGradientAnimation() {\n const [config, setConfig] = useState(initialConfig)\n const [isCopied, setIsCopied] = useState(false)\n const { toast } = useToast()\n\n const updateConfig = (key: string, value: any) => {\n setConfig((prev) => ({ ...prev, [key]: value }))\n }\n\n const updateGradient = (index: number, updatedGradient: Gradient) => {\n const newGradients = [...config.gradients]\n newGradients[index] = updatedGradient\n updateConfig(\"gradients\", newGradients)\n }\n\n const addGradient = () => {\n const newGradient: Gradient = {\n stops: [\n { color: \"#000000\", position: 0 },\n { color: \"#FFFFFF\", position: 100 },\n ],\n centerX: 50,\n centerY: 50,\n }\n updateConfig(\"gradients\", [...config.gradients, newGradient])\n }\n\n const removeGradient = (index: number) => {\n const newGradients = config.gradients.filter((_, i) => i !== index)\n updateConfig(\"gradients\", newGradients)\n }\n\n const copyConfigToClipboard = () => {\n const configString = `\n\"use client\"\n\nimport { GradientAnimation } from \"./gradient-animation\"\n\nexport function GradientAnimationExample() {\n return (\n
\n \n
\n )\n}\n`\n\n navigator.clipboard.writeText(configString).then(() => {\n setIsCopied(true)\n toast({\n title: \"Configuration Copied\",\n description:\n \"The current configuration has been copied to your clipboard.\",\n })\n setTimeout(() => setIsCopied(false), 2000)\n })\n }\n\n return (\n
\n

\n Configurable GradientAnimation\n

\n
\n \n {isCopied ? (\n \n ) : (\n \n )}\n {isCopied ? \"Copied!\" : \"Copy Config\"}\n \n
\n
\n \n
\n
\n \n \n Configuration\n \n \n \n \n General\n Gradients\n \n \n \n \n Animation\n \n
\n
\n \n \n updateConfig(\"animationDuration\", value)\n }\n />\n
\n
\n
\n
\n
\n
\n \n
\n {config.gradients.map((gradient, index) => (\n \n \n \n Gradient {index + 1}\n \n \n \n
\n
\n
\n \n \n updateGradient(index, {\n ...gradient,\n centerX: value,\n })\n }\n />\n
\n
\n \n \n updateGradient(index, {\n ...gradient,\n centerY: value,\n })\n }\n />\n
\n
\n {gradient.stops.map((stop, stopIndex) => (\n \n {\n const newStops = [...gradient.stops]\n newStops[stopIndex] = {\n ...stop,\n color: e.target.value,\n }\n updateGradient(index, {\n ...gradient,\n stops: newStops,\n })\n }}\n className=\"w-16 h-10\"\n />\n {\n const newStops = [...gradient.stops]\n newStops[stopIndex] = {\n ...stop,\n position: value,\n }\n updateGradient(index, {\n ...gradient,\n stops: newStops,\n })\n }}\n className=\"flex-grow\"\n />\n {\n const newStops = gradient.stops.filter(\n (_, i) => i !== stopIndex\n )\n updateGradient(index, {\n ...gradient,\n stops: newStops,\n })\n }}\n >\n \n \n
\n ))}\n
\n {\n const newStops = [\n ...gradient.stops,\n { color: \"#000000\", position: 100 },\n ]\n updateGradient(index, {\n ...gradient,\n stops: newStops,\n })\n }}\n >\n \n Add Stop\n \n removeGradient(index)}\n >\n \n Remove Gradient\n \n
\n
\n
\n
\n ))}\n \n
\n \n \n \n \n
\n \n )\n}\n\nexport default ConfigurableGradientAnimation\n", "type": "registry:component" } ], "type": "registry:component" }