{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "canvas-fractal-grid-demo", "registryDependencies": [ "canvas-fractal-grid" ], "files": [ { "path": "registry/default/example/canvas-fractal-grid-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 {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/ui/select\"\nimport { Slider } from \"@/components/ui/slider\"\nimport { Switch } from \"@/components/ui/switch\"\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from \"@/components/ui/tabs\"\nimport { useToast } from \"@/components/ui/use-toast\"\n\nimport { CanvasFractalGrid } from \"../ui/canvas-fractal-grid\"\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 dotSize: 5,\n dotSpacing: 25,\n dotOpacity: 0.8,\n gradientAnimationDuration: 5,\n waveIntensity: 40,\n waveRadius: 250,\n dotColor: \"rgba(100, 200, 255, 0.2)\",\n glowColor: \"rgba(100, 200, 255, 1)\",\n enableNoise: true,\n noiseOpacity: 0.05,\n enableMouseGlow: false,\n initialPerformance: \"high\" as const,\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 ConfigurableCanvasFractalGrid() {\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 { CanvasFractalGrid } from \"../ui/canvas-fractal-grid\"\n\nexport function CanvasFractalGridExample() {\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 CanvasFractalGrid\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 Dots\n \n
\n
\n \n \n updateConfig(\"dotSize\", value)\n }\n />\n
\n
\n \n \n updateConfig(\"dotSpacing\", value)\n }\n />\n
\n
\n \n \n updateConfig(\"dotOpacity\", value)\n }\n />\n
\n
\n \n \n updateConfig(\"dotColor\", e.target.value)\n }\n className=\"h-10 px-3 py-2\"\n />\n
\n
\n
\n
\n \n Waves\n \n
\n
\n \n \n updateConfig(\"waveIntensity\", value)\n }\n />\n
\n
\n \n \n updateConfig(\"waveRadius\", value)\n }\n />\n
\n
\n
\n
\n \n Effects\n \n
\n
\n \n \n updateConfig(\"gradientAnimationDuration\", value)\n }\n />\n
\n
\n \n \n updateConfig(\"glowColor\", e.target.value)\n }\n className=\"h-10 px-3 py-2\"\n />\n
\n
\n \n updateConfig(\"enableNoise\", checked)\n }\n />\n \n
\n
\n \n updateConfig(\"enableMouseGlow\", checked)\n }\n />\n \n
\n
\n
\n
\n \n Performance\n \n
\n \n \n updateConfig(\n \"initialPerformance\",\n value as \"low\" | \"medium\" | \"high\"\n )\n }\n >\n \n \n \n \n Low\n Medium\n High\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 ConfigurableCanvasFractalGrid\n", "type": "registry:component" } ], "type": "registry:component" }