UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
fix: update aurora text (#580)
Dillion Verma8eb75d9b5c4f
diff --git a/content/docs/components/aurora-text.mdx b/content/docs/components/aurora-text.mdxindex 3075ced9..7180c0e1 100644--- a/content/docs/components/aurora-text.mdx+++ b/content/docs/components/aurora-text.mdx@@ -34,69 +34,6 @@ npx shadcn@latest add "https://magicui.design/r/aurora-text"<Step>Update the import paths to match your project setup.</Step>-<Step>Update `globals.css`</Step>--Add the following to your `globals.css` file:--```css-:root {- --color-1: 0 100% 63%;- --color-2: 270 100% 63%;- --color-3: 210 100% 63%;- --color-4: 195 100% 63%;- --color-5: 90 100% 63%;-}-```--<Step>Update `tailwind.config.js`</Step>--Add the following animations to your `tailwind.config.js` file:--```js title="tailwind.config.js" {5-39}-/** @type {import('tailwindcss').Config} */-module.exports = {- theme: {- extend: {- colors: {- "color-1": "hsl(var(--color-1))",- "color-2": "hsl(var(--color-2))",- "color-3": "hsl(var(--color-3))",- "color-4": "hsl(var(--color-4))",- "color-5": "hsl(var(--color-5))",- },- keyframes: {- "aurora-border": {- "0%, 100%": { borderRadius: "37% 29% 27% 27% / 28% 25% 41% 37%" },- "25%": { borderRadius: "47% 29% 39% 49% / 61% 19% 66% 26%" },- "50%": { borderRadius: "57% 23% 47% 72% / 63% 17% 66% 33%" },- "75%": { borderRadius: "28% 49% 29% 100% / 93% 20% 64% 25%" },- },- "aurora-1": {- "0%, 100%": { top: "0", right: "0" },- "50%": { top: "50%", right: "25%" },- "75%": { top: "25%", right: "50%" },- },- "aurora-2": {- "0%, 100%": { top: "0", left: "0" },- "60%": { top: "75%", left: "25%" },- "85%": { top: "50%", left: "50%" },- },- "aurora-3": {- "0%, 100%": { bottom: "0", left: "0" },- "40%": { bottom: "50%", left: "25%" },- "65%": { bottom: "25%", left: "50%" },- },- "aurora-4": {- "0%, 100%": { bottom: "0", right: "0" },- "50%": { bottom: "25%", right: "40%" },- "90%": { bottom: "50%", right: "25%" },- },- },- },- },-};-```-</Steps></TabsContent>@@ -105,8 +42,9 @@ module.exports = {## Props-| Prop | Type | Default | Description |-| ----------- | ------------------- | -------- | --------------------------------------------- |-| `className` | `string` | `-` | The class name to be applied to the component |-| `children` | `ReactNode` | `-` | Children elements |-| `as` | `React.ElementType` | `"span"` | The element type to render as |+| Prop | Type | Default | Description |+| ----------- | ----------- | -------------------------------------------------------------------- | ------------------------------------------------------------- |+| `className` | `string` | `""` | The class name to be applied to the component |+| `children` | `ReactNode` | `-` | Children elements |+| `colors` | `string[]` | `["#FF0080", "#7928CA", "#0070F3", "#38bdf8", "#a855f7", "#2dd4bf"]` | Array of colors used for the aurora effect |+| `speed` | `number` | `1` | Animation speed multiplier (1 is default, 2 is twice as fast) |diff --git a/public/r/aurora-text.json b/public/r/aurora-text.jsonindex 58035e98..0844d392 100644--- a/public/r/aurora-text.json+++ b/public/r/aurora-text.json@@ -4,118 +4,12 @@"type": "registry:ui","title": "Aurora Text","description": "A beautiful aurora text effect",- "dependencies": [- "motion"- ],"files": [{"path": "registry/magicui/aurora-text.tsx",- "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion, MotionProps } from \"motion/react\";\nimport React from \"react\";\n\ninterface AuroraTextProps\n extends Omit<React.HTMLAttributes<HTMLElement>, keyof MotionProps> {\n className?: string;\n children: React.ReactNode;\n as?: React.ElementType;\n}\n\nexport function AuroraText({\n className,\n children,\n as: Component = \"span\",\n ...props\n}: AuroraTextProps) {\n const MotionComponent = motion.create(Component);\n\n return (\n <MotionComponent\n className={cn(\"relative inline-flex overflow-hidden\", className)}\n {...props}\n >\n {children}\n <span className=\"pointer-events-none absolute inset-0 mix-blend-lighten dark:mix-blend-darken\">\n <span className=\"pointer-events-none absolute -top-1/2 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-1_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-1))] mix-blend-overlay blur-[1rem]\"></span>\n <span className=\"pointer-events-none absolute right-0 top-0 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-2_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-2))] mix-blend-overlay blur-[1rem]\"></span>\n <span className=\"pointer-events-none absolute bottom-0 left-0 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-3_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-3))] mix-blend-overlay blur-[1rem]\"></span>\n <span className=\"pointer-events-none absolute -bottom-1/2 right-0 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-4_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-4))] mix-blend-overlay blur-[1rem]\"></span>\n </span>\n </MotionComponent>\n );\n}\n",+ "content": "\"use client\";\n\nimport type { CSSProperties } from \"react\";\nimport React, { useEffect, useRef } from \"react\";\n\ninterface AuroraTextProps {\n children: React.ReactNode;\n className?: string;\n colors?: string[];\n speed?: number; // 1 is default speed, 2 is twice as fast, 0.5 is half speed\n}\n\nexport function AuroraText({\n children,\n className = \"\",\n colors = [\"#FF0080\", \"#7928CA\", \"#0070F3\", \"#38bdf8\", \"#a855f7\", \"#2dd4bf\"],\n speed = 1,\n}: AuroraTextProps) {\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const textRef = useRef<SVGTextElement>(null);\n const containerRef = useRef<HTMLSpanElement>(null);\n const [fontSize, setFontSize] = React.useState(0);\n const [dimensions, setDimensions] = React.useState({ width: 0, height: 0 });\n const [isReady, setIsReady] = React.useState(false);\n const [textStyle, setTextStyle] = React.useState<\n Partial<CSSStyleDeclaration>\n >({});\n\n // Updated effect to compute all text styles from parent\n useEffect(() => {\n if (containerRef.current) {\n const computedStyle = window.getComputedStyle(containerRef.current);\n\n // Extract text-related styles\n const relevantStyles = {\n fontSize: computedStyle.fontSize,\n fontFamily: computedStyle.fontFamily,\n fontWeight: computedStyle.fontWeight,\n fontStyle: computedStyle.fontStyle,\n letterSpacing: computedStyle.letterSpacing,\n lineHeight: computedStyle.lineHeight,\n textTransform: computedStyle.textTransform,\n fontVariant: computedStyle.fontVariant,\n fontStretch: computedStyle.fontStretch,\n fontFeatureSettings: computedStyle.fontFeatureSettings,\n };\n\n requestAnimationFrame(() => {\n setTextStyle(relevantStyles);\n });\n }\n }, [className]);\n\n // Updated effect to compute font size from both inline and class styles\n useEffect(() => {\n const updateFontSize = () => {\n if (containerRef.current) {\n const computedStyle = window.getComputedStyle(containerRef.current);\n const computedFontSize = parseFloat(computedStyle.fontSize);\n\n requestAnimationFrame(() => {\n setFontSize(computedFontSize);\n });\n }\n };\n\n updateFontSize();\n window.addEventListener(\"resize\", updateFontSize);\n\n return () => window.removeEventListener(\"resize\", updateFontSize);\n }, [className]);\n\n // Update effect to set ready state after dimensions are computed\n useEffect(() => {\n const updateDimensions = () => {\n if (textRef.current) {\n const bbox = textRef.current.getBBox();\n setDimensions({\n width: bbox.width,\n height: bbox.height,\n });\n setIsReady(true);\n }\n };\n\n updateDimensions();\n window.addEventListener(\"resize\", updateDimensions);\n\n return () => window.removeEventListener(\"resize\", updateDimensions);\n }, [children, fontSize]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return;\n\n // Set canvas size\n canvas.width = dimensions.width;\n canvas.height = dimensions.height;\n\n let time = 0;\n const baseSpeed = 0.008; // Original speed as base unit\n\n function animate() {\n if (!ctx || !canvas) return;\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n time += baseSpeed * speed;\n\n colors.forEach((color, i) => {\n const x =\n canvas.width *\n (0.5 +\n Math.cos(time * 0.8 + i * 1.3) * 0.4 +\n Math.sin(time * 0.5 + i * 0.7) * 0.2);\n const y =\n canvas.height *\n (0.5 +\n Math.sin(time * 0.7 + i * 1.5) * 0.4 +\n Math.cos(time * 0.6 + i * 0.8) * 0.2);\n\n const gradient = ctx.createRadialGradient(\n x,\n y,\n 0,\n x,\n y,\n canvas.width * 0.4,\n );\n\n gradient.addColorStop(0, `${color}99`);\n gradient.addColorStop(0.5, `${color}33`);\n gradient.addColorStop(1, \"#00000000\");\n\n ctx.fillStyle = gradient;\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n });\n\n requestAnimationFrame(animate);\n }\n animate();\n }, [dimensions, colors, speed]);\n\n return (\n <span\n ref={containerRef}\n className={`relative inline-block align-middle ${className}`}\n style={{\n width: dimensions.width || \"auto\",\n height: dimensions.height || \"auto\",\n }}\n >\n {/* Hidden text for SEO */}\n <span className=\"sr-only\">{children}</span>\n\n {/* Visual placeholder while canvas loads */}\n <span\n style={{\n opacity: isReady ? 0 : 1,\n transition: \"opacity 0.2s ease-in\",\n position: isReady ? \"absolute\" : \"relative\",\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n }}\n aria-hidden=\"true\"\n >\n {children}\n </span>\n\n <div\n className=\"absolute inset-0\"\n style={{\n opacity: isReady ? 1 : 0,\n transition: \"opacity 0.2s ease-in\",\n }}\n aria-hidden=\"true\"\n >\n <svg\n width={dimensions.width}\n height={dimensions.height}\n className=\"absolute inset-0\"\n >\n <defs>\n <mask id={`text-mask-${children}`}>\n <rect width=\"100%\" height=\"100%\" fill=\"black\" />\n <text\n ref={textRef}\n x=\"50%\"\n y=\"50%\"\n dominantBaseline=\"middle\"\n textAnchor=\"middle\"\n fill=\"white\"\n style={textStyle as CSSProperties}\n >\n {children}\n </text>\n </mask>\n </defs>\n </svg>\n\n <canvas\n ref={canvasRef}\n style={{\n maskImage: `url(#text-mask-${children})`,\n WebkitMaskImage: `url(#text-mask-${children})`,\n }}\n className=\"h-full w-full\"\n />\n </div>\n </span>\n );\n}\n","type": "registry:ui","target": "components/magicui/aurora-text.tsx"}- ],- "tailwind": {- "config": {- "theme": {- "extend": {- "colors": {- "color-1": "hsl(var(--color-1))",- "color-2": "hsl(var(--color-2))",- "color-3": "hsl(var(--color-3))",- "color-4": "hsl(var(--color-4))",- "color-5": "hsl(var(--color-5))"- },- "keyframes": {- "aurora-border": {- "0%, 100%": {- "borderRadius": "37% 29% 27% 27% / 28% 25% 41% 37%"- },- "25%": {- "borderRadius": "47% 29% 39% 49% / 61% 19% 66% 26%"- },- "50%": {- "borderRadius": "57% 23% 47% 72% / 63% 17% 66% 33%"- },- "75%": {- "borderRadius": "28% 49% 29% 100% / 93% 20% 64% 25%"- }- },- "aurora-1": {- "0%, 100%": {- "top": "0",- "right": "0"- },- "50%": {- "top": "50%",- "right": "25%"- },- "75%": {- "top": "25%",- "right": "50%"- }- },- "aurora-2": {- "0%, 100%": {- "top": "0",- "left": "0"- },- "60%": {- "top": "75%",- "left": "25%"- },- "85%": {- "top": "50%",- "left": "50%"- }- },- "aurora-3": {- "0%, 100%": {- "bottom": "0",- "left": "0"- },- "40%": {- "bottom": "50%",- "left": "25%"- },- "65%": {- "bottom": "25%",- "left": "50%"- }- },- "aurora-4": {- "0%, 100%": {- "bottom": "0",- "right": "0"- },- "50%": {- "bottom": "25%",- "right": "40%"- },- "90%": {- "bottom": "50%",- "right": "25%"- }- }- }- }- }- }- },- "cssVars": {- "light": {- "--color-1": "0 100% 63%",- "--color-2": "270 100% 63%",- "--color-3": "210 100% 63%",- "--color-4": "195 100% 63%",- "--color-5": "90 100% 63%"- },- "dark": {- "--color-1": "0 100% 63%",- "--color-2": "270 100% 63%",- "--color-3": "210 100% 63%",- "--color-4": "195 100% 63%",- "--color-5": "90 100% 63%"- }- }+ ]}\ No newline at end of filediff --git a/public/r/number-ticker-demo-2.json b/public/r/number-ticker-demo-2.jsonindex f83b7421..30ddaf9c 100644--- a/public/r/number-ticker-demo-2.json+++ b/public/r/number-ticker-demo-2.json@@ -10,7 +10,7 @@"files": [{"path": "registry/example/number-ticker-demo-2.tsx",- "content": "import { NumberTicker } from \"@/components/magicui/number-ticker\";\r\n\r\nexport default function NumberTickerDemo() {\r\n return (\r\n <NumberTicker\r\n value={100}\r\n startValue={80}\r\n className=\"whitespace-pre-wrap text-8xl font-medium tracking-tighter text-black dark:text-white\"\r\n />\r\n );\r\n}\r\n",+ "content": "import { NumberTicker } from \"@/components/magicui/number-ticker\";\n\nexport default function NumberTickerDemo() {\n return (\n <NumberTicker\n value={100}\n startValue={80}\n className=\"whitespace-pre-wrap text-8xl font-medium tracking-tighter text-black dark:text-white\"\n />\n );\n}\n","type": "registry:example","target": "components/number-ticker-demo-2.tsx"}diff --git a/public/r/number-ticker.json b/public/r/number-ticker.jsonindex 62c62e23..f5d1b85f 100644--- a/public/r/number-ticker.json+++ b/public/r/number-ticker.json@@ -10,7 +10,7 @@"files": [{"path": "registry/magicui/number-ticker.tsx",- "content": "\"use client\";\n\nimport { useInView, useMotionValue, useSpring } from \"motion/react\";\nimport { ComponentPropsWithoutRef, useEffect, useRef } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface NumberTickerProps extends ComponentPropsWithoutRef<\"span\"> {\n value: number;\n startValue?: number;\n direction?: \"up\" | \"down\";\n delay?: number;\n decimalPlaces?: number;\n}\n\nexport function NumberTicker({\n value,\n startValue = 0,\n direction = \"up\",\n delay = 0,\n className,\n decimalPlaces = 0,\n ...props\n}: NumberTickerProps) {\n const ref = useRef<HTMLSpanElement>(null);\n const motionValue = useMotionValue(direction === \"down\" ? value : startValue);\n const springValue = useSpring(motionValue, {\n damping: 60,\n stiffness: 100,\n });\n const isInView = useInView(ref, { once: true, margin: \"0px\" });\n\n useEffect(() => {\n if (isInView) {\n const timer = setTimeout(() => {\n motionValue.set(direction === \"down\" ? startValue : value);\n }, delay * 1000);\n return () => clearTimeout(timer);\n }\n }, [motionValue, isInView, delay, value, direction, startValue]);\n\n useEffect(\n () =>\n springValue.on(\"change\", (latest) => {\n if (ref.current) {\n ref.current.textContent = Intl.NumberFormat(\"en-US\", {\n minimumFractionDigits: decimalPlaces,\n maximumFractionDigits: decimalPlaces,\n }).format(Number(latest.toFixed(decimalPlaces)));\n }\n }),\n [springValue, decimalPlaces]\n );\n\n return (\n <span\n ref={ref}\n className={cn(\n \"inline-block tabular-nums tracking-wider text-black dark:text-white\",\n className\n )}\n {...props}\n >\n {startValue}\n </span>\n );\n}\n",+ "content": "\"use client\";\n\nimport { useInView, useMotionValue, useSpring } from \"motion/react\";\nimport { ComponentPropsWithoutRef, useEffect, useRef } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface NumberTickerProps extends ComponentPropsWithoutRef<\"span\"> {\n value: number;\n startValue?: number;\n direction?: \"up\" | \"down\";\n delay?: number;\n decimalPlaces?: number;\n}\n\nexport function NumberTicker({\n value,\n startValue = 0,\n direction = \"up\",\n delay = 0,\n className,\n decimalPlaces = 0,\n ...props\n}: NumberTickerProps) {\n const ref = useRef<HTMLSpanElement>(null);\n const motionValue = useMotionValue(direction === \"down\" ? value : startValue);\n const springValue = useSpring(motionValue, {\n damping: 60,\n stiffness: 100,\n });\n const isInView = useInView(ref, { once: true, margin: \"0px\" });\n\n useEffect(() => {\n if (isInView) {\n const timer = setTimeout(() => {\n motionValue.set(direction === \"down\" ? startValue : value);\n }, delay * 1000);\n return () => clearTimeout(timer);\n }\n }, [motionValue, isInView, delay, value, direction, startValue]);\n\n useEffect(\n () =>\n springValue.on(\"change\", (latest) => {\n if (ref.current) {\n ref.current.textContent = Intl.NumberFormat(\"en-US\", {\n minimumFractionDigits: decimalPlaces,\n maximumFractionDigits: decimalPlaces,\n }).format(Number(latest.toFixed(decimalPlaces)));\n }\n }),\n [springValue, decimalPlaces],\n );\n\n return (\n <span\n ref={ref}\n className={cn(\n \"inline-block tabular-nums tracking-wider text-black dark:text-white\",\n className,\n )}\n {...props}\n >\n {startValue}\n </span>\n );\n}\n","type": "registry:ui","target": "components/magicui/number-ticker.tsx"}diff --git a/registry.json b/registry.jsonindex 748640dc..0b993636 100644--- a/registry.json+++ b/registry.json@@ -89,119 +89,13 @@"type": "registry:ui","title": "Aurora Text","description": "A beautiful aurora text effect",- "dependencies": [- "motion"- ],"files": [{"path": "registry/magicui/aurora-text.tsx","type": "registry:ui","target": "components/magicui/aurora-text.tsx"}- ],- "tailwind": {- "config": {- "theme": {- "extend": {- "colors": {- "color-1": "hsl(var(--color-1))",- "color-2": "hsl(var(--color-2))",- "color-3": "hsl(var(--color-3))",- "color-4": "hsl(var(--color-4))",- "color-5": "hsl(var(--color-5))"- },- "keyframes": {- "aurora-border": {- "0%, 100%": {- "borderRadius": "37% 29% 27% 27% / 28% 25% 41% 37%"- },- "25%": {- "borderRadius": "47% 29% 39% 49% / 61% 19% 66% 26%"- },- "50%": {- "borderRadius": "57% 23% 47% 72% / 63% 17% 66% 33%"- },- "75%": {- "borderRadius": "28% 49% 29% 100% / 93% 20% 64% 25%"- }- },- "aurora-1": {- "0%, 100%": {- "top": "0",- "right": "0"- },- "50%": {- "top": "50%",- "right": "25%"- },- "75%": {- "top": "25%",- "right": "50%"- }- },- "aurora-2": {- "0%, 100%": {- "top": "0",- "left": "0"- },- "60%": {- "top": "75%",- "left": "25%"- },- "85%": {- "top": "50%",- "left": "50%"- }- },- "aurora-3": {- "0%, 100%": {- "bottom": "0",- "left": "0"- },- "40%": {- "bottom": "50%",- "left": "25%"- },- "65%": {- "bottom": "25%",- "left": "50%"- }- },- "aurora-4": {- "0%, 100%": {- "bottom": "0",- "right": "0"- },- "50%": {- "bottom": "25%",- "right": "40%"- },- "90%": {- "bottom": "50%",- "right": "25%"- }- }- }- }- }- }- },- "cssVars": {- "light": {- "--color-1": "0 100% 63%",- "--color-2": "270 100% 63%",- "--color-3": "210 100% 63%",- "--color-4": "195 100% 63%",- "--color-5": "90 100% 63%"- },- "dark": {- "--color-1": "0 100% 63%",- "--color-2": "270 100% 63%",- "--color-3": "210 100% 63%",- "--color-4": "195 100% 63%",- "--color-5": "90 100% 63%"- }- }+ ]},{"name": "morphing-text",diff --git a/registry/magicui/aurora-text.tsx b/registry/magicui/aurora-text.tsxindex 83fbdab2..b9d954f0 100644--- a/registry/magicui/aurora-text.tsx+++ b/registry/magicui/aurora-text.tsx@@ -1,36 +1,214 @@"use client";-import { cn } from "@/lib/utils";-import { motion, MotionProps } from "motion/react";-import React from "react";+import type { CSSProperties } from "react";+import React, { useEffect, useRef } from "react";-interface AuroraTextProps- extends Omit<React.HTMLAttributes<HTMLElement>, keyof MotionProps> {- className?: string;+interface AuroraTextProps {children: React.ReactNode;- as?: React.ElementType;+ className?: string;+ colors?: string[];+ speed?: number; // 1 is default speed, 2 is twice as fast, 0.5 is half speed}export function AuroraText({- className,children,- as: Component = "span",- ...props+ className = "",+ colors = ["#FF0080", "#7928CA", "#0070F3", "#38bdf8", "#a855f7", "#2dd4bf"],+ speed = 1,}: AuroraTextProps) {- const MotionComponent = motion.create(Component);+ const canvasRef = useRef<HTMLCanvasElement>(null);+ const textRef = useRef<SVGTextElement>(null);+ const containerRef = useRef<HTMLSpanElement>(null);+ const [fontSize, setFontSize] = React.useState(0);+ const [dimensions, setDimensions] = React.useState({ width: 0, height: 0 });+ const [isReady, setIsReady] = React.useState(false);+ const [textStyle, setTextStyle] = React.useState<+ Partial<CSSStyleDeclaration>+ >({});++ // Updated effect to compute all text styles from parent+ useEffect(() => {+ if (containerRef.current) {+ const computedStyle = window.getComputedStyle(containerRef.current);++ // Extract text-related styles+ const relevantStyles = {+ fontSize: computedStyle.fontSize,+ fontFamily: computedStyle.fontFamily,+ fontWeight: computedStyle.fontWeight,+ fontStyle: computedStyle.fontStyle,+ letterSpacing: computedStyle.letterSpacing,+ lineHeight: computedStyle.lineHeight,+ textTransform: computedStyle.textTransform,+ fontVariant: computedStyle.fontVariant,+ fontStretch: computedStyle.fontStretch,+ fontFeatureSettings: computedStyle.fontFeatureSettings,+ };++ requestAnimationFrame(() => {+ setTextStyle(relevantStyles);+ });+ }+ }, [className]);++ // Updated effect to compute font size from both inline and class styles+ useEffect(() => {+ const updateFontSize = () => {+ if (containerRef.current) {+ const computedStyle = window.getComputedStyle(containerRef.current);+ const computedFontSize = parseFloat(computedStyle.fontSize);++ requestAnimationFrame(() => {+ setFontSize(computedFontSize);+ });+ }+ };++ updateFontSize();+ window.addEventListener("resize", updateFontSize);++ return () => window.removeEventListener("resize", updateFontSize);+ }, [className]);++ // Update effect to set ready state after dimensions are computed+ useEffect(() => {+ const updateDimensions = () => {+ if (textRef.current) {+ const bbox = textRef.current.getBBox();+ setDimensions({+ width: bbox.width,+ height: bbox.height,+ });+ setIsReady(true);+ }+ };++ updateDimensions();+ window.addEventListener("resize", updateDimensions);++ return () => window.removeEventListener("resize", updateDimensions);+ }, [children, fontSize]);++ useEffect(() => {+ const canvas = canvasRef.current;+ if (!canvas) return;++ const ctx = canvas.getContext("2d");+ if (!ctx) return;++ // Set canvas size+ canvas.width = dimensions.width;+ canvas.height = dimensions.height;++ let time = 0;+ const baseSpeed = 0.008; // Original speed as base unit++ function animate() {+ if (!ctx || !canvas) return;+ ctx.clearRect(0, 0, canvas.width, canvas.height);++ time += baseSpeed * speed;++ colors.forEach((color, i) => {+ const x =+ canvas.width *+ (0.5 ++ Math.cos(time * 0.8 + i * 1.3) * 0.4 ++ Math.sin(time * 0.5 + i * 0.7) * 0.2);+ const y =+ canvas.height *+ (0.5 ++ Math.sin(time * 0.7 + i * 1.5) * 0.4 ++ Math.cos(time * 0.6 + i * 0.8) * 0.2);++ const gradient = ctx.createRadialGradient(+ x,+ y,+ 0,+ x,+ y,+ canvas.width * 0.4,+ );++ gradient.addColorStop(0, `${color}99`);+ gradient.addColorStop(0.5, `${color}33`);+ gradient.addColorStop(1, "#00000000");++ ctx.fillStyle = gradient;+ ctx.fillRect(0, 0, canvas.width, canvas.height);+ });++ requestAnimationFrame(animate);+ }+ animate();+ }, [dimensions, colors, speed]);return (- <MotionComponent- className={cn("relative inline-flex overflow-hidden", className)}- {...props}+ <span+ ref={containerRef}+ className={`relative inline-block align-middle ${className}`}+ style={{+ width: dimensions.width || "auto",+ height: dimensions.height || "auto",+ }}>- {children}- <span className="pointer-events-none absolute inset-0 mix-blend-lighten dark:mix-blend-darken">- <span className="pointer-events-none absolute -top-1/2 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-1_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-1))] mix-blend-overlay blur-[1rem]"></span>- <span className="pointer-events-none absolute right-0 top-0 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-2_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-2))] mix-blend-overlay blur-[1rem]"></span>- <span className="pointer-events-none absolute bottom-0 left-0 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-3_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-3))] mix-blend-overlay blur-[1rem]"></span>- <span className="pointer-events-none absolute -bottom-1/2 right-0 h-[30vw] w-[30vw] animate-[aurora-border_6s_ease-in-out_infinite,aurora-4_12s_ease-in-out_infinite_alternate] bg-[hsl(var(--color-4))] mix-blend-overlay blur-[1rem]"></span>+ {/* Hidden text for SEO */}+ <span className="sr-only">{children}</span>++ {/* Visual placeholder while canvas loads */}+ <span+ style={{+ opacity: isReady ? 0 : 1,+ transition: "opacity 0.2s ease-in",+ position: isReady ? "absolute" : "relative",+ display: "inline-block",+ whiteSpace: "nowrap",+ }}+ aria-hidden="true"+ >+ {children}</span>- </MotionComponent>++ <div+ className="absolute inset-0"+ style={{+ opacity: isReady ? 1 : 0,+ transition: "opacity 0.2s ease-in",+ }}+ aria-hidden="true"+ >+ <svg+ width={dimensions.width}+ height={dimensions.height}+ className="absolute inset-0"+ >+ <defs>+ <mask id={`text-mask-${children}`}>+ <rect width="100%" height="100%" fill="black" />+ <text+ ref={textRef}+ x="50%"+ y="50%"+ dominantBaseline="middle"+ textAnchor="middle"+ fill="white"+ style={textStyle as CSSProperties}+ >+ {children}+ </text>+ </mask>+ </defs>+ </svg>++ <canvas+ ref={canvasRef}+ style={{+ maskImage: `url(#text-mask-${children})`,+ WebkitMaskImage: `url(#text-mask-${children})`,+ }}+ className="h-full w-full"+ />+ </div>+ </span>);}diff --git a/registry/registry-ui.ts b/registry/registry-ui.tsindex e0b924ab..2ae2e724 100644--- a/registry/registry-ui.ts+++ b/registry/registry-ui.ts@@ -62,7 +62,6 @@ export const ui: Registry["items"] = [type: "registry:ui",title: "Aurora Text",description: "A beautiful aurora text effect",- dependencies: ["motion"],files: [{path: "registry/magicui/aurora-text.tsx",@@ -70,67 +69,6 @@ export const ui: Registry["items"] = [target: "components/magicui/aurora-text.tsx",},],- cssVars: {- light: {- "--color-1": "0 100% 63%",- "--color-2": "270 100% 63%",- "--color-3": "210 100% 63%",- "--color-4": "195 100% 63%",- "--color-5": "90 100% 63%",- },- dark: {- "--color-1": "0 100% 63%",- "--color-2": "270 100% 63%",- "--color-3": "210 100% 63%",- "--color-4": "195 100% 63%",- "--color-5": "90 100% 63%",- },- },- tailwind: {- config: {- theme: {- extend: {- colors: {- "color-1": "hsl(var(--color-1))",- "color-2": "hsl(var(--color-2))",- "color-3": "hsl(var(--color-3))",- "color-4": "hsl(var(--color-4))",- "color-5": "hsl(var(--color-5))",- },- keyframes: {- "aurora-border": {- "0%, 100%": {- borderRadius: "37% 29% 27% 27% / 28% 25% 41% 37%",- },- "25%": { borderRadius: "47% 29% 39% 49% / 61% 19% 66% 26%" },- "50%": { borderRadius: "57% 23% 47% 72% / 63% 17% 66% 33%" },- "75%": { borderRadius: "28% 49% 29% 100% / 93% 20% 64% 25%" },- },- "aurora-1": {- "0%, 100%": { top: "0", right: "0" },- "50%": { top: "50%", right: "25%" },- "75%": { top: "25%", right: "50%" },- },- "aurora-2": {- "0%, 100%": { top: "0", left: "0" },- "60%": { top: "75%", left: "25%" },- "85%": { top: "50%", left: "50%" },- },- "aurora-3": {- "0%, 100%": { bottom: "0", left: "0" },- "40%": { bottom: "50%", left: "25%" },- "65%": { bottom: "25%", left: "50%" },- },- "aurora-4": {- "0%, 100%": { bottom: "0", right: "0" },- "50%": { bottom: "25%", right: "40%" },- "90%": { bottom: "50%", right: "25%" },- },- },- },- },- },- },},{name: "morphing-text",diff --git a/tailwind.config.cjs b/tailwind.config.cjsindex 61ab7b13..d3b34203 100644--- a/tailwind.config.cjs+++ b/tailwind.config.cjs@@ -209,32 +209,6 @@ module.exports = {"0%": { "background-position": "0 0" },"100%": { "background-position": "100% -100%" },},- "aurora-border": {- "0%, 100%": { borderRadius: "37% 29% 27% 27% / 28% 25% 41% 37%" },- "25%": { borderRadius: "47% 29% 39% 49% / 61% 19% 66% 26%" },- "50%": { borderRadius: "57% 23% 47% 72% / 63% 17% 66% 33%" },- "75%": { borderRadius: "28% 49% 29% 100% / 93% 20% 64% 25%" },- },- "aurora-1": {- "0%, 100%": { top: "0", right: "0" },- "50%": { top: "50%", right: "25%" },- "75%": { top: "25%", right: "50%" },- },- "aurora-2": {- "0%, 100%": { top: "0", left: "0" },- "60%": { top: "75%", left: "25%" },- "85%": { top: "50%", left: "50%" },- },- "aurora-3": {- "0%, 100%": { bottom: "0", left: "0" },- "40%": { bottom: "50%", left: "25%" },- "65%": { bottom: "25%", left: "50%" },- },- "aurora-4": {- "0%, 100%": { bottom: "0", right: "0" },- "50%": { bottom: "25%", right: "40%" },- "90%": { bottom: "50%", right: "25%" },- },},},},