Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: update build

Dillion Vermadf1477a736a6
diff --git a/public/r/animated-circular-progress-bar-demo.json b/public/r/animated-circular-progress-bar-demo.json
index 50d59180..0e5f25b9 100644
--- a/public/r/animated-circular-progress-bar-demo.json
+++ b/public/r/animated-circular-progress-bar-demo.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/example/animated-circular-progress-bar-demo.tsx",
- "content": "\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport { AnimatedCircularProgressBar } from \"@/registry/magicui/animated-circular-progress-bar\";\n\nexport default function AnimatedCircularProgressBarDemo() {\n const [value, setValue] = useState(0);\n\n useEffect(() => {\n const handleIncrement = (prev: number) => {\n if (prev === 100) {\n return 0;\n }\n return prev + 10;\n };\n setValue(handleIncrement);\n const interval = setInterval(() => setValue(handleIncrement), 2000);\n return () => clearInterval(interval);\n }, []);\n\n return (\n <AnimatedCircularProgressBar\n max={100}\n min={0}\n value={value}\n gaugePrimaryColor=\"rgb(79 70 229)\"\n gaugeSecondaryColor=\"rgba(0, 0, 0, 0.1)\"\n />\n );\n}\n",
+ "content": "\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport { AnimatedCircularProgressBar } from \"@/registry/magicui/animated-circular-progress-bar\";\n\nexport default function AnimatedCircularProgressBarDemo() {\n const [value, setValue] = useState(0);\n\n useEffect(() => {\n const handleIncrement = (prev: number) => {\n if (prev === 100) {\n return 0;\n }\n return prev + 10;\n };\n setValue(handleIncrement);\n const interval = setInterval(() => setValue(handleIncrement), 2000);\n return () => clearInterval(interval);\n }, []);\n\n return (\n <AnimatedCircularProgressBar\n value={value}\n gaugePrimaryColor=\"rgb(79 70 229)\"\n gaugeSecondaryColor=\"rgba(0, 0, 0, 0.1)\"\n />\n );\n}\n",
"type": "registry:example",
"target": "components/animated-circular-progress-bar-demo.tsx"
}
diff --git a/public/r/animated-circular-progress-bar.json b/public/r/animated-circular-progress-bar.json
index 5c322599..beea05ae 100644
--- a/public/r/animated-circular-progress-bar.json
+++ b/public/r/animated-circular-progress-bar.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/animated-circular-progress-bar.tsx",
- "content": "import { cn } from \"@/lib/utils\";\n\ninterface AnimatedCircularProgressBarProps {\n max: number;\n value: number;\n min: number;\n gaugePrimaryColor: string;\n gaugeSecondaryColor: string;\n className?: string;\n}\n\nexport function AnimatedCircularProgressBar({\n max = 100,\n min = 0,\n value = 0,\n gaugePrimaryColor,\n gaugeSecondaryColor,\n className,\n}: AnimatedCircularProgressBarProps) {\n const circumference = 2 * Math.PI * 45;\n const percentPx = circumference / 100;\n const currentPercent = Math.round(((value - min) / (max - min)) * 100);\n\n return (\n <div\n className={cn(\"relative size-40 text-2xl font-semibold\", className)}\n style={\n {\n \"--circle-size\": \"100px\",\n \"--circumference\": circumference,\n \"--percent-to-px\": `${percentPx}px`,\n \"--gap-percent\": \"5\",\n \"--offset-factor\": \"0\",\n \"--transition-length\": \"1s\",\n \"--transition-step\": \"200ms\",\n \"--delay\": \"0s\",\n \"--percent-to-deg\": \"3.6deg\",\n transform: \"translateZ(0)\",\n } as React.CSSProperties\n }\n >\n <svg\n fill=\"none\"\n className=\"size-full\"\n strokeWidth=\"2\"\n viewBox=\"0 0 100 100\"\n >\n {currentPercent <= 90 && currentPercent >= 0 && (\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"45\"\n strokeWidth=\"10\"\n strokeDashoffset=\"0\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\" opacity-100\"\n style={\n {\n stroke: gaugeSecondaryColor,\n \"--stroke-percent\": 90 - currentPercent,\n \"--offset-factor-secondary\": \"calc(1 - var(--offset-factor))\",\n strokeDasharray:\n \"calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)\",\n transform:\n \"rotate(calc(1turn - 90deg - (var(--gap-percent) * var(--percent-to-deg) * var(--offset-factor-secondary)))) scaleY(-1)\",\n transition: \"all var(--transition-length) ease var(--delay)\",\n transformOrigin:\n \"calc(var(--circle-size) / 2) calc(var(--circle-size) / 2)\",\n } as React.CSSProperties\n }\n />\n )}\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"45\"\n strokeWidth=\"10\"\n strokeDashoffset=\"0\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"opacity-100\"\n style={\n {\n stroke: gaugePrimaryColor,\n \"--stroke-percent\": currentPercent,\n strokeDasharray:\n \"calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)\",\n transition:\n \"var(--transition-length) ease var(--delay),stroke var(--transition-length) ease var(--delay)\",\n transitionProperty: \"stroke-dasharray,transform\",\n transform:\n \"rotate(calc(-90deg + var(--gap-percent) * var(--offset-factor) * var(--percent-to-deg)))\",\n transformOrigin:\n \"calc(var(--circle-size) / 2) calc(var(--circle-size) / 2)\",\n } as React.CSSProperties\n }\n />\n </svg>\n <span\n data-current-value={currentPercent}\n className=\"duration-[var(--transition-length)] delay-[var(--delay)] absolute inset-0 m-auto size-fit ease-linear animate-in fade-in\"\n >\n {currentPercent}\n </span>\n </div>\n );\n}\n",
+ "content": "import { cn } from \"@/lib/utils\";\n\ninterface AnimatedCircularProgressBarProps {\n max?: number;\n min?: number;\n value: number;\n gaugePrimaryColor: string;\n gaugeSecondaryColor: string;\n className?: string;\n}\n\nexport function AnimatedCircularProgressBar({\n max = 100,\n min = 0,\n value = 0,\n gaugePrimaryColor,\n gaugeSecondaryColor,\n className,\n}: AnimatedCircularProgressBarProps) {\n const circumference = 2 * Math.PI * 45;\n const percentPx = circumference / 100;\n const currentPercent = Math.round(((value - min) / (max - min)) * 100);\n\n return (\n <div\n className={cn(\"relative size-40 text-2xl font-semibold\", className)}\n style={\n {\n \"--circle-size\": \"100px\",\n \"--circumference\": circumference,\n \"--percent-to-px\": `${percentPx}px`,\n \"--gap-percent\": \"5\",\n \"--offset-factor\": \"0\",\n \"--transition-length\": \"1s\",\n \"--transition-step\": \"200ms\",\n \"--delay\": \"0s\",\n \"--percent-to-deg\": \"3.6deg\",\n transform: \"translateZ(0)\",\n } as React.CSSProperties\n }\n >\n <svg\n fill=\"none\"\n className=\"size-full\"\n strokeWidth=\"2\"\n viewBox=\"0 0 100 100\"\n >\n {currentPercent <= 90 && currentPercent >= 0 && (\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"45\"\n strokeWidth=\"10\"\n strokeDashoffset=\"0\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\" opacity-100\"\n style={\n {\n stroke: gaugeSecondaryColor,\n \"--stroke-percent\": 90 - currentPercent,\n \"--offset-factor-secondary\": \"calc(1 - var(--offset-factor))\",\n strokeDasharray:\n \"calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)\",\n transform:\n \"rotate(calc(1turn - 90deg - (var(--gap-percent) * var(--percent-to-deg) * var(--offset-factor-secondary)))) scaleY(-1)\",\n transition: \"all var(--transition-length) ease var(--delay)\",\n transformOrigin:\n \"calc(var(--circle-size) / 2) calc(var(--circle-size) / 2)\",\n } as React.CSSProperties\n }\n />\n )}\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"45\"\n strokeWidth=\"10\"\n strokeDashoffset=\"0\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"opacity-100\"\n style={\n {\n stroke: gaugePrimaryColor,\n \"--stroke-percent\": currentPercent,\n strokeDasharray:\n \"calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)\",\n transition:\n \"var(--transition-length) ease var(--delay),stroke var(--transition-length) ease var(--delay)\",\n transitionProperty: \"stroke-dasharray,transform\",\n transform:\n \"rotate(calc(-90deg + var(--gap-percent) * var(--offset-factor) * var(--percent-to-deg)))\",\n transformOrigin:\n \"calc(var(--circle-size) / 2) calc(var(--circle-size) / 2)\",\n } as React.CSSProperties\n }\n />\n </svg>\n <span\n data-current-value={currentPercent}\n className=\"duration-[var(--transition-length)] delay-[var(--delay)] absolute inset-0 m-auto size-fit ease-linear animate-in fade-in\"\n >\n {currentPercent}\n </span>\n </div>\n );\n}\n",
"type": "registry:ui",
"target": "components/magicui/animated-circular-progress-bar.tsx"
}
diff --git a/public/r/cool-mode.json b/public/r/cool-mode.json
index 11232342..db91385e 100644
--- a/public/r/cool-mode.json
+++ b/public/r/cool-mode.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/cool-mode.tsx",
- "content": "\"use client\";\n\nimport React, { ReactNode, useEffect, useRef } from \"react\";\n\nexport interface BaseParticle {\n element: HTMLElement | SVGSVGElement;\n left: number;\n size: number;\n top: number;\n}\n\nexport interface BaseParticleOptions {\n particle?: string;\n size?: number;\n}\n\nexport interface CoolParticle extends BaseParticle {\n direction: number;\n speedHorz: number;\n speedUp: number;\n spinSpeed: number;\n spinVal: number;\n}\n\nexport interface CoolParticleOptions extends BaseParticleOptions {\n particleCount?: number;\n speedHorz?: number;\n speedUp?: number;\n}\n\nconst getContainer = () => {\n const id = \"_coolMode_effect\";\n let existingContainer = document.getElementById(id);\n\n if (existingContainer) {\n return existingContainer;\n }\n\n const container = document.createElement(\"div\");\n container.setAttribute(\"id\", id);\n container.setAttribute(\n \"style\",\n \"overflow:hidden; position:fixed; height:100%; top:0; left:0; right:0; bottom:0; pointer-events:none; z-index:2147483647\",\n );\n\n document.body.appendChild(container);\n\n return container;\n};\n\nlet instanceCounter = 0;\n\nconst applyParticleEffect = (\n element: HTMLElement,\n options?: CoolParticleOptions,\n): (() => void) => {\n instanceCounter++;\n\n const defaultParticle = \"circle\";\n const particleType = options?.particle || defaultParticle;\n const sizes = [15, 20, 25, 35, 45];\n const limit = 45;\n\n let particles: CoolParticle[] = [];\n let autoAddParticle = false;\n let mouseX = 0;\n let mouseY = 0;\n\n const container = getContainer();\n\n function generateParticle() {\n const size =\n options?.size || sizes[Math.floor(Math.random() * sizes.length)];\n const speedHorz = options?.speedHorz || Math.random() * 10;\n const speedUp = options?.speedUp || Math.random() * 25;\n const spinVal = Math.random() * 360;\n const spinSpeed = Math.random() * 35 * (Math.random() <= 0.5 ? -1 : 1);\n const top = mouseY - size / 2;\n const left = mouseX - size / 2;\n const direction = Math.random() <= 0.5 ? -1 : 1;\n\n const particle = document.createElement(\"div\");\n\n if (particleType === \"circle\") {\n const svgNS = \"http://www.w3.org/2000/svg\";\n const circleSVG = document.createElementNS(svgNS, \"svg\");\n const circle = document.createElementNS(svgNS, \"circle\");\n circle.setAttributeNS(null, \"cx\", (size / 2).toString());\n circle.setAttributeNS(null, \"cy\", (size / 2).toString());\n circle.setAttributeNS(null, \"r\", (size / 2).toString());\n circle.setAttributeNS(\n null,\n \"fill\",\n `hsl(${Math.random() * 360}, 70%, 50%)`,\n );\n\n circleSVG.appendChild(circle);\n circleSVG.setAttribute(\"width\", size.toString());\n circleSVG.setAttribute(\"height\", size.toString());\n\n particle.appendChild(circleSVG);\n } else {\n particle.innerHTML = `<img src=\"${particleType}\" width=\"${size}\" height=\"${size}\" style=\"border-radius: 50%\">`;\n }\n\n particle.style.position = \"absolute\";\n particle.style.transform = `translate3d(${left}px, ${top}px, 0px) rotate(${spinVal}deg)`;\n\n container.appendChild(particle);\n\n particles.push({\n direction,\n element: particle,\n left,\n size,\n speedHorz,\n speedUp,\n spinSpeed,\n spinVal,\n top,\n });\n }\n\n function refreshParticles() {\n particles.forEach((p) => {\n p.left = p.left - p.speedHorz * p.direction;\n p.top = p.top - p.speedUp;\n p.speedUp = Math.min(p.size, p.speedUp - 1);\n p.spinVal = p.spinVal + p.spinSpeed;\n\n if (\n p.top >=\n Math.max(window.innerHeight, document.body.clientHeight) + p.size\n ) {\n particles = particles.filter((o) => o !== p);\n p.element.remove();\n }\n\n p.element.setAttribute(\n \"style\",\n [\n \"position:absolute\",\n \"will-change:transform\",\n `top:${p.top}px`,\n `left:${p.left}px`,\n `transform:rotate(${p.spinVal}deg)`,\n ].join(\";\"),\n );\n });\n }\n\n let animationFrame: number | undefined;\n\n let lastParticleTimestamp = 0;\n const particleGenerationDelay = 30;\n\n function loop() {\n const currentTime = performance.now();\n if (\n autoAddParticle &&\n particles.length < limit &&\n currentTime - lastParticleTimestamp > particleGenerationDelay\n ) {\n generateParticle();\n lastParticleTimestamp = currentTime;\n }\n\n refreshParticles();\n animationFrame = requestAnimationFrame(loop);\n }\n\n loop();\n\n const isTouchInteraction = \"ontouchstart\" in window;\n\n const tap = isTouchInteraction ? \"touchstart\" : \"mousedown\";\n const tapEnd = isTouchInteraction ? \"touchend\" : \"mouseup\";\n const move = isTouchInteraction ? \"touchmove\" : \"mousemove\";\n\n const updateMousePosition = (e: MouseEvent | TouchEvent) => {\n if (\"touches\" in e) {\n mouseX = e.touches?.[0].clientX;\n mouseY = e.touches?.[0].clientY;\n } else {\n mouseX = e.clientX;\n mouseY = e.clientY;\n }\n };\n\n const tapHandler = (e: MouseEvent | TouchEvent) => {\n updateMousePosition(e);\n autoAddParticle = true;\n };\n\n const disableAutoAddParticle = () => {\n autoAddParticle = false;\n };\n\n element.addEventListener(move, updateMousePosition, { passive: true });\n element.addEventListener(tap, tapHandler, { passive: true });\n element.addEventListener(tapEnd, disableAutoAddParticle, { passive: true });\n element.addEventListener(\"mouseleave\", disableAutoAddParticle, {\n passive: true,\n });\n\n return () => {\n element.removeEventListener(move, updateMousePosition);\n element.removeEventListener(tap, tapHandler);\n element.removeEventListener(tapEnd, disableAutoAddParticle);\n element.removeEventListener(\"mouseleave\", disableAutoAddParticle);\n\n const interval = setInterval(() => {\n if (animationFrame && particles.length === 0) {\n cancelAnimationFrame(animationFrame);\n clearInterval(interval);\n\n if (--instanceCounter === 0) {\n container.remove();\n }\n }\n }, 500);\n };\n};\n\ninterface CoolModeProps {\n children: ReactNode;\n options?: CoolParticleOptions;\n}\n\nexport const CoolMode: React.FC<CoolModeProps> = ({ children, options }) => {\n const ref = useRef<HTMLElement>(null);\n\n useEffect(() => {\n if (ref.current) {\n return applyParticleEffect(ref.current, options);\n }\n }, [options]);\n\n return React.cloneElement(children as React.ReactElement, { ref });\n};\n",
+ "content": "\"use client\";\n\nimport React, { ReactNode, useEffect, useRef } from \"react\";\n\nexport interface BaseParticle {\n element: HTMLElement | SVGSVGElement;\n left: number;\n size: number;\n top: number;\n}\n\nexport interface BaseParticleOptions {\n particle?: string;\n size?: number;\n}\n\nexport interface CoolParticle extends BaseParticle {\n direction: number;\n speedHorz: number;\n speedUp: number;\n spinSpeed: number;\n spinVal: number;\n}\n\nexport interface CoolParticleOptions extends BaseParticleOptions {\n particleCount?: number;\n speedHorz?: number;\n speedUp?: number;\n}\n\nconst getContainer = () => {\n const id = \"_coolMode_effect\";\n let existingContainer = document.getElementById(id);\n\n if (existingContainer) {\n return existingContainer;\n }\n\n const container = document.createElement(\"div\");\n container.setAttribute(\"id\", id);\n container.setAttribute(\n \"style\",\n \"overflow:hidden; position:fixed; height:100%; top:0; left:0; right:0; bottom:0; pointer-events:none; z-index:2147483647\",\n );\n\n document.body.appendChild(container);\n\n return container;\n};\n\nlet instanceCounter = 0;\n\nconst applyParticleEffect = (\n element: HTMLElement,\n options?: CoolParticleOptions,\n): (() => void) => {\n instanceCounter++;\n\n const defaultParticle = \"circle\";\n const particleType = options?.particle || defaultParticle;\n const sizes = [15, 20, 25, 35, 45];\n const limit = 45;\n\n let particles: CoolParticle[] = [];\n let autoAddParticle = false;\n let mouseX = 0;\n let mouseY = 0;\n\n const container = getContainer();\n\n function generateParticle() {\n const size =\n options?.size || sizes[Math.floor(Math.random() * sizes.length)];\n const speedHorz = options?.speedHorz || Math.random() * 10;\n const speedUp = options?.speedUp || Math.random() * 25;\n const spinVal = Math.random() * 360;\n const spinSpeed = Math.random() * 35 * (Math.random() <= 0.5 ? -1 : 1);\n const top = mouseY - size / 2;\n const left = mouseX - size / 2;\n const direction = Math.random() <= 0.5 ? -1 : 1;\n\n const particle = document.createElement(\"div\");\n\n if (particleType === \"circle\") {\n const svgNS = \"http://www.w3.org/2000/svg\";\n const circleSVG = document.createElementNS(svgNS, \"svg\");\n const circle = document.createElementNS(svgNS, \"circle\");\n circle.setAttributeNS(null, \"cx\", (size / 2).toString());\n circle.setAttributeNS(null, \"cy\", (size / 2).toString());\n circle.setAttributeNS(null, \"r\", (size / 2).toString());\n circle.setAttributeNS(\n null,\n \"fill\",\n `hsl(${Math.random() * 360}, 70%, 50%)`,\n );\n\n circleSVG.appendChild(circle);\n circleSVG.setAttribute(\"width\", size.toString());\n circleSVG.setAttribute(\"height\", size.toString());\n\n particle.appendChild(circleSVG);\n } else if (\n particleType.startsWith(\"http\") ||\n particleType.startsWith(\"/\")\n ) {\n // Handle URL-based images\n particle.innerHTML = `<img src=\"${particleType}\" width=\"${size}\" height=\"${size}\" style=\"border-radius: 50%\">`;\n } else {\n // Handle emoji or text characters\n const fontSizeMultiplier = 3; // Make emojis 3x bigger\n const emojiSize = size * fontSizeMultiplier;\n particle.innerHTML = `<div style=\"font-size: ${emojiSize}px; line-height: 1; text-align: center; width: ${size}px; height: ${size}px; display: flex; align-items: center; justify-content: center; transform: scale(${fontSizeMultiplier}); transform-origin: center;\">${particleType}</div>`;\n }\n\n particle.style.position = \"absolute\";\n particle.style.transform = `translate3d(${left}px, ${top}px, 0px) rotate(${spinVal}deg)`;\n\n container.appendChild(particle);\n\n particles.push({\n direction,\n element: particle,\n left,\n size,\n speedHorz,\n speedUp,\n spinSpeed,\n spinVal,\n top,\n });\n }\n\n function refreshParticles() {\n particles.forEach((p) => {\n p.left = p.left - p.speedHorz * p.direction;\n p.top = p.top - p.speedUp;\n p.speedUp = Math.min(p.size, p.speedUp - 1);\n p.spinVal = p.spinVal + p.spinSpeed;\n\n if (\n p.top >=\n Math.max(window.innerHeight, document.body.clientHeight) + p.size\n ) {\n particles = particles.filter((o) => o !== p);\n p.element.remove();\n }\n\n p.element.setAttribute(\n \"style\",\n [\n \"position:absolute\",\n \"will-change:transform\",\n `top:${p.top}px`,\n `left:${p.left}px`,\n `transform:rotate(${p.spinVal}deg)`,\n ].join(\";\"),\n );\n });\n }\n\n let animationFrame: number | undefined;\n\n let lastParticleTimestamp = 0;\n const particleGenerationDelay = 30;\n\n function loop() {\n const currentTime = performance.now();\n if (\n autoAddParticle &&\n particles.length < limit &&\n currentTime - lastParticleTimestamp > particleGenerationDelay\n ) {\n generateParticle();\n lastParticleTimestamp = currentTime;\n }\n\n refreshParticles();\n animationFrame = requestAnimationFrame(loop);\n }\n\n loop();\n\n const isTouchInteraction = \"ontouchstart\" in window;\n\n const tap = isTouchInteraction ? \"touchstart\" : \"mousedown\";\n const tapEnd = isTouchInteraction ? \"touchend\" : \"mouseup\";\n const move = isTouchInteraction ? \"touchmove\" : \"mousemove\";\n\n const updateMousePosition = (e: MouseEvent | TouchEvent) => {\n if (\"touches\" in e) {\n mouseX = e.touches?.[0].clientX;\n mouseY = e.touches?.[0].clientY;\n } else {\n mouseX = e.clientX;\n mouseY = e.clientY;\n }\n };\n\n const tapHandler = (e: MouseEvent | TouchEvent) => {\n updateMousePosition(e);\n autoAddParticle = true;\n };\n\n const disableAutoAddParticle = () => {\n autoAddParticle = false;\n };\n\n element.addEventListener(move, updateMousePosition, { passive: true });\n element.addEventListener(tap, tapHandler, { passive: true });\n element.addEventListener(tapEnd, disableAutoAddParticle, { passive: true });\n element.addEventListener(\"mouseleave\", disableAutoAddParticle, {\n passive: true,\n });\n\n return () => {\n element.removeEventListener(move, updateMousePosition);\n element.removeEventListener(tap, tapHandler);\n element.removeEventListener(tapEnd, disableAutoAddParticle);\n element.removeEventListener(\"mouseleave\", disableAutoAddParticle);\n\n const interval = setInterval(() => {\n if (animationFrame && particles.length === 0) {\n cancelAnimationFrame(animationFrame);\n clearInterval(interval);\n\n if (--instanceCounter === 0) {\n container.remove();\n }\n }\n }, 500);\n };\n};\n\ninterface CoolModeProps {\n children: ReactNode;\n options?: CoolParticleOptions;\n}\n\nexport const CoolMode: React.FC<CoolModeProps> = ({ children, options }) => {\n const ref = useRef<HTMLElement>(null);\n\n useEffect(() => {\n if (ref.current) {\n return applyParticleEffect(ref.current, options);\n }\n }, [options]);\n\n return React.cloneElement(children as React.ReactElement, { ref });\n};\n",
"type": "registry:ui",
"target": "components/magicui/cool-mode.tsx"
}
diff --git a/public/r/typing-animation-demo.json b/public/r/typing-animation-demo.json
index b7cba420..7e93aee4 100644
--- a/public/r/typing-animation-demo.json
+++ b/public/r/typing-animation-demo.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/example/typing-animation-demo.tsx",
- "content": "import { TypingAnimation } from \"@/registry/magicui/typing-animation\";\n\nexport default function TypingAnimationDemo() {\n return <TypingAnimation>Typing Animation</TypingAnimation>;\n}\n",
+ "content": "import { TypingAnimation } from \"@/registry/magicui/typing-animation\";\n\nexport default function TypingAnimationDemo() {\n return <TypingAnimation>Typing Animation 👋</TypingAnimation>;\n}\n",
"type": "registry:example",
"target": "components/typing-animation-demo.tsx"
}
diff --git a/public/r/typing-animation.json b/public/r/typing-animation.json
index 5a41931c..04d65d81 100644
--- a/public/r/typing-animation.json
+++ b/public/r/typing-animation.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/typing-animation.tsx",
- "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion, MotionProps } from \"motion/react\";\nimport { useEffect, useRef, useState } from \"react\";\n\ninterface TypingAnimationProps extends MotionProps {\n children: string;\n className?: string;\n duration?: number;\n delay?: number;\n as?: React.ElementType;\n startOnView?: boolean;\n}\n\nexport function TypingAnimation({\n children,\n className,\n duration = 100,\n delay = 0,\n as: Component = \"div\",\n startOnView = false,\n ...props\n}: TypingAnimationProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n });\n\n const [displayedText, setDisplayedText] = useState<string>(\"\");\n const [started, setStarted] = useState(false);\n const elementRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!startOnView) {\n const startTimeout = setTimeout(() => {\n setStarted(true);\n }, delay);\n return () => clearTimeout(startTimeout);\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n setTimeout(() => {\n setStarted(true);\n }, delay);\n observer.disconnect();\n }\n },\n { threshold: 0.1 },\n );\n\n if (elementRef.current) {\n observer.observe(elementRef.current);\n }\n\n return () => observer.disconnect();\n }, [delay, startOnView]);\n\n useEffect(() => {\n if (!started) return;\n\n let i = 0;\n const typingEffect = setInterval(() => {\n if (i < children.length) {\n setDisplayedText(children.substring(0, i + 1));\n i++;\n } else {\n clearInterval(typingEffect);\n }\n }, duration);\n\n return () => {\n clearInterval(typingEffect);\n };\n }, [children, duration, started]);\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\n \"text-4xl font-bold leading-[5rem] tracking-[-0.02em]\",\n className,\n )}\n {...props}\n >\n {displayedText}\n </MotionComponent>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion, MotionProps } from \"motion/react\";\nimport { useEffect, useRef, useState } from \"react\";\n\ninterface TypingAnimationProps extends MotionProps {\n children: string;\n className?: string;\n duration?: number;\n delay?: number;\n as?: React.ElementType;\n startOnView?: boolean;\n}\n\nexport function TypingAnimation({\n children,\n className,\n duration = 100,\n delay = 0,\n as: Component = \"div\",\n startOnView = false,\n ...props\n}: TypingAnimationProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n });\n\n const [displayedText, setDisplayedText] = useState<string>(\"\");\n const [started, setStarted] = useState(false);\n const elementRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!startOnView) {\n const startTimeout = setTimeout(() => {\n setStarted(true);\n }, delay);\n return () => clearTimeout(startTimeout);\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n setTimeout(() => {\n setStarted(true);\n }, delay);\n observer.disconnect();\n }\n },\n { threshold: 0.1 },\n );\n\n if (elementRef.current) {\n observer.observe(elementRef.current);\n }\n\n return () => observer.disconnect();\n }, [delay, startOnView]);\n\n useEffect(() => {\n if (!started) return;\n\n const graphemes = Array.from(children);\n let i = 0;\n const typingEffect = setInterval(() => {\n if (i < graphemes.length) {\n setDisplayedText(graphemes.slice(0, i + 1).join(\"\"));\n i++;\n } else {\n clearInterval(typingEffect);\n }\n }, duration);\n\n return () => {\n clearInterval(typingEffect);\n };\n }, [children, duration, started]);\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\n \"text-4xl font-bold leading-[5rem] tracking-[-0.02em]\",\n className,\n )}\n {...props}\n >\n {displayedText}\n </MotionComponent>\n );\n}\n",
"type": "registry:ui",
"target": "components/magicui/typing-animation.tsx"
}