Skip to content

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

chore(www): resolve ESLint warnings in registry components (#915)

Yeom-JinHo45d8bc20d20e
diff --git a/apps/www/eslint.config.mjs b/apps/www/eslint.config.mjs
index 91e28de6..7d094aa2 100644
--- a/apps/www/eslint.config.mjs
+++ b/apps/www/eslint.config.mjs
@@ -26,6 +26,12 @@ const eslintConfig = [
"@next/next/no-duplicate-head": "off",
},
}),
+ {
+ files: ["registry/**/*.tsx"],
+ rules: {
+ "@next/next/no-img-element": "off",
+ },
+ },
]
export default eslintConfig
diff --git a/apps/www/public/llms-full.txt b/apps/www/public/llms-full.txt
index bec3945b..6592df8b 100644
--- a/apps/www/public/llms-full.txt
+++ b/apps/www/public/llms-full.txt
@@ -3003,7 +3003,6 @@ Title: Avatar Circles
Description: Overlapping circles of avatars.
--- file: magicui/avatar-circles.tsx ---
-/* eslint-disable @next/next/no-img-element */
"use client"
import { cn } from "@/lib/utils"
@@ -3354,7 +3353,9 @@ const features = [
description: "We automatically save your files as you type.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:row-start-1 lg:row-end-4 lg:col-start-2 lg:col-end-3",
},
{
@@ -3363,7 +3364,9 @@ const features = [
description: "Search through all your files in one place.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-1 lg:col-end-2 lg:row-start-1 lg:row-end-3",
},
{
@@ -3372,7 +3375,9 @@ const features = [
description: "Supports 100+ languages and counting.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-1 lg:col-end-2 lg:row-start-3 lg:row-end-4",
},
{
@@ -3381,7 +3386,9 @@ const features = [
description: "Use the calendar to filter your files by date.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-3 lg:col-end-3 lg:row-start-1 lg:row-end-2",
},
{
@@ -3391,7 +3398,9 @@ const features = [
"Get notified when someone shares a file or mentions you in a comment.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-3 lg:col-end-3 lg:row-start-2 lg:row-end-4",
},
]
@@ -3513,7 +3522,6 @@ export function BlurFade({
Title: Blur Fade Demo
--- file: example/blur-fade-demo.tsx ---
-/* eslint-disable @next/next/no-img-element */
import { BlurFade } from "@/registry/magicui/blur-fade"
const images = Array.from({ length: 9 }, (_, i) => {
@@ -5768,8 +5776,8 @@ export function DotPattern({
const col = i % Math.ceil(dimensions.width / width)
const row = Math.floor(i / Math.ceil(dimensions.width / width))
return {
- x: col * width + cx,
- y: row * height + cy,
+ x: col * width + cx + x,
+ y: row * height + cy + y,
delay: Math.random() * 5,
duration: Math.random() * 3 + 2,
}
@@ -5792,7 +5800,7 @@ export function DotPattern({
<stop offset="100%" stopColor="currentColor" stopOpacity="0" />
</radialGradient>
</defs>
- {dots.map((dot, index) => (
+ {dots.map((dot) => (
<motion.circle
key={`${dot.x}-${dot.y}`}
cx={dot.x}
@@ -6256,7 +6264,7 @@ const Tree = forwardRef<HTMLDivElement, TreeViewProps>(
if (initialSelectedId) {
expandSpecificTargetedElements(elements, initialSelectedId)
}
- }, [initialSelectedId, elements])
+ }, [initialSelectedId, elements, expandSpecificTargetedElements])
const direction = dir === "rtl" ? "rtl" : "ltr"
@@ -6358,6 +6366,7 @@ const Folder = forwardRef<
return (
<AccordionPrimitive.Item
+ ref={ref}
{...props}
value={value}
className="relative h-full overflow-hidden"
@@ -6417,6 +6426,7 @@ const File = forwardRef<
value,
className,
handleSelect,
+ onClick,
isSelectable = true,
isSelect,
fileIcon,
@@ -6441,7 +6451,11 @@ const File = forwardRef<
direction === "rtl" ? "rtl" : "ltr",
className
)}
- onClick={() => selectItem(value)}
+ onClick={(event) => {
+ selectItem(value)
+ handleSelect?.(value)
+ onClick?.(event)
+ }}
{...props}
>
{fileIcon ?? <FileIcon className="size-4" />}
@@ -6463,36 +6477,43 @@ const CollapseButton = forwardRef<
const { expandedItems, setExpandedItems } = useTree()
const expendAllTree = useCallback((elements: TreeViewElement[]) => {
+ const expandedElementIds: string[] = []
+
const expandTree = (element: TreeViewElement) => {
const isSelectable = element.isSelectable ?? true
if (isSelectable && element.children && element.children.length > 0) {
- setExpandedItems?.((prev) => [...(prev ?? []), element.id])
- element.children.forEach(expandTree)
+ expandedElementIds.push(element.id)
+ for (const child of element.children) {
+ expandTree(child)
+ }
}
}
- elements.forEach(expandTree)
+ for (const element of elements) {
+ expandTree(element)
+ }
+
+ return [...new Set(expandedElementIds)]
}, [])
const closeAll = useCallback(() => {
setExpandedItems?.([])
- }, [])
+ }, [setExpandedItems])
useEffect(() => {
- console.log(expandAll)
if (expandAll) {
- expendAllTree(elements)
+ setExpandedItems?.(expendAllTree(elements))
}
- }, [expandAll])
+ }, [expandAll, elements, expendAllTree, setExpandedItems])
return (
<Button
variant={"ghost"}
- className="absolute right-2 bottom-1 h-8 w-fit p-1"
+ className={cn("absolute right-2 bottom-1 h-8 w-fit p-1", className)}
onClick={
expandedItems && expandedItems.length > 0
? closeAll
- : () => expendAllTree(elements)
+ : () => setExpandedItems?.(expendAllTree(elements))
}
ref={ref}
{...props}
@@ -6930,9 +6951,9 @@ export function Globe({
className?: string
config?: COBEOptions
}) {
- let phi = 0
- let width = 0
const canvasRef = useRef<HTMLCanvasElement>(null)
+ const phiRef = useRef(0)
+ const widthRef = useRef(0)
const pointerInteracting = useRef<number | null>(null)
const pointerInteractionMovement = useRef(0)
@@ -6961,7 +6982,7 @@ export function Globe({
useEffect(() => {
const onResize = () => {
if (canvasRef.current) {
- width = canvasRef.current.offsetWidth
+ widthRef.current = canvasRef.current.offsetWidth
}
}
@@ -6970,13 +6991,13 @@ export function Globe({
const globe = createGlobe(canvasRef.current!, {
...config,
- width: width * 2,
- height: width * 2,
+ width: widthRef.current * 2,
+ height: widthRef.current * 2,
onRender: (state) => {
- if (!pointerInteracting.current) phi += 0.005
- state.phi = phi + rs.get()
- state.width = width * 2
- state.height = width * 2
+ if (!pointerInteracting.current) phiRef.current += 0.005
+ state.phi = phiRef.current + rs.get()
+ state.width = widthRef.current * 2
+ state.height = widthRef.current * 2
},
})
@@ -7208,7 +7229,6 @@ Title: Hero Video Dialog
Description: A hero video dialog component.
--- file: magicui/hero-video-dialog.tsx ---
-/* eslint-disable @next/next/no-img-element */
"use client"
import { useState } from "react"
@@ -7900,7 +7920,6 @@ function easeOutCubic(t: number): number {
export function IconCloud({ icons, images }: IconCloudProps) {
const canvasRef = useRef<HTMLCanvasElement>(null)
const [iconPositions, setIconPositions] = useState<Icon[]>([])
- const [rotation, setRotation] = useState({ x: 0, y: 0 })
const [isDragging, setIsDragging] = useState(false)
const [lastMousePos, setLastMousePos] = useState({ x: 0, y: 0 })
const [mousePos, setMousePos] = useState({ x: 0, y: 0 })
@@ -7914,7 +7933,7 @@ export function IconCloud({ icons, images }: IconCloudProps) {
duration: number
} | null>(null)
const animationFrameRef = useRef<number>(0)
- const rotationRef = useRef(rotation)
+ const rotationRef = useRef({ x: 0, y: 0 })
const iconCanvasesRef = useRef<HTMLCanvasElement[]>([])
const imagesLoadedRef = useRef<boolean[]>([])
@@ -8978,7 +8997,7 @@ export function Lens({
</div>
</motion.div>
)
- }, [currentPosition, lensSize, lensColor, zoomFactor, children, duration])
+ }, [currentPosition, maskImage, zoomFactor, children, duration])
return (
<div
@@ -9009,8 +9028,6 @@ export function Lens({
Title: Lens Demo
--- file: example/lens-demo.tsx ---
-/* eslint-disable @next/next/no-img-element */
-
"use client"
import { Button } from "@/components/ui/button"
@@ -9062,8 +9079,6 @@ export default function LensDemo() {
Title: Lens Demo 2
--- file: example/lens-demo-2.tsx ---
-/* eslint-disable @next/next/no-img-element */
-
import { Button } from "@/components/ui/button"
import {
Card,
@@ -9108,8 +9123,6 @@ export default function LensDemo() {
Title: Lens Demo 3
--- file: example/lens-demo-3.tsx ---
-/* eslint-disable @next/next/no-img-element */
-
import { Button } from "@/components/ui/button"
import {
Card,
@@ -9828,7 +9841,6 @@ export default function MarqueeDemo() {
Title: Marquee Vertical Demo
--- file: example/marquee-demo-vertical.tsx ---
-/* eslint-disable @next/next/no-img-element */
import { cn } from "@/lib/utils"
import { Marquee } from "@/registry/magicui/marquee"
@@ -9972,7 +9984,6 @@ export default function MarqueeLogos() {
Title: Marquee 3D
--- file: example/marquee-3d.tsx ---
-/* eslint-disable @next/next/no-img-element */
import { cn } from "@/lib/utils"
import { Marquee } from "@/registry/magicui/marquee"
@@ -11115,20 +11126,23 @@ export const Particles: React.FC<ParticlesProps> = ({
const dpr = typeof window !== "undefined" ? window.devicePixelRatio : 1
const rafID = useRef<number | null>(null)
const resizeTimeout = useRef<NodeJS.Timeout | null>(null)
+ const initCanvasRef = useRef<() => void>(() => {})
+ const onMouseMoveRef = useRef<() => void>(() => {})
+ const animateRef = useRef<() => void>(() => {})
useEffect(() => {
if (canvasRef.current) {
context.current = canvasRef.current.getContext("2d")
}
- initCanvas()
- animate()
+ initCanvasRef.current()
+ animateRef.current()
const handleResize = () => {
if (resizeTimeout.current) {
clearTimeout(resizeTimeout.current)
}
resizeTimeout.current = setTimeout(() => {
- initCanvas()
+ initCanvasRef.current()
}, 200)
}
@@ -11146,11 +11160,11 @@ export const Particles: React.FC<ParticlesProps> = ({
}, [color])
useEffect(() => {
- onMouseMove()
+ onMouseMoveRef.current()
}, [mousePosition.x, mousePosition.y])
useEffect(() => {
- initCanvas()
+ initCanvasRef.current()
}, [refresh])
const initCanvas = () => {
@@ -11314,9 +11328,13 @@ export const Particles: React.FC<ParticlesProps> = ({
drawCircle(newCircle)
}
})
- rafID.current = window.requestAnimationFrame(animate)
+ rafID.current = window.requestAnimationFrame(animateRef.current)
}
+ initCanvasRef.current = initCanvas
+ onMouseMoveRef.current = onMouseMove
+ animateRef.current = animate
+
return (
<div
className={cn("pointer-events-none", className)}
@@ -13436,7 +13454,7 @@ Description: A customizable, physics-based smooth cursor animation component wit
--- file: magicui/smooth-cursor.tsx ---
"use client"
-import { FC, useEffect, useRef, useState } from "react"
+import { FC, useEffect, useRef } from "react"
import { motion, useSpring } from "motion/react"
interface Position {
@@ -13525,7 +13543,6 @@ export function SmoothCursor({
restDelta: 0.001,
},
}: SmoothCursorProps) {
- const [isMoving, setIsMoving] = useState(false)
const lastMousePos = useRef<Position>({ x: 0, y: 0 })
const velocity = useRef<Position>({ x: 0, y: 0 })
const lastUpdateTime = useRef(Date.now())
@@ -13587,7 +13604,6 @@ export function SmoothCursor({
previousAngle.current = currentAngle
scale.set(0.95)
- setIsMoving(true)
if (timeout !== null) {
clearTimeout(timeout)
@@ -13595,7 +13611,6 @@ export function SmoothCursor({
timeout = setTimeout(() => {
scale.set(1)
- setIsMoving(false)
}, 150)
}
}
@@ -14181,7 +14196,7 @@ export const AnimatedSpan = ({
if (sequence.activeIndex === itemIndex) {
setHasStarted(true)
}
- }, [sequence?.activeIndex, sequence?.sequenceStarted, hasStarted, itemIndex])
+ }, [sequence, hasStarted, itemIndex])
const shouldAnimate = sequence ? hasStarted : startOnView ? isInView : true
@@ -14240,16 +14255,24 @@ export const TypingAnimation = ({
const sequence = useSequence()
const itemIndex = useItemIndex()
+ const hasSequence = sequence !== null
+ const sequenceStarted = sequence?.sequenceStarted ?? false
+ const sequenceActiveIndex = sequence?.activeIndex ?? null
+ const sequenceCompleteItemRef = useRef<
+ SequenceContextValue["completeItem"] | null
+ >(null)
+ const sequenceItemIndexRef = useRef<number | null>(null)
+
+ useEffect(() => {
+ sequenceCompleteItemRef.current = sequence?.completeItem ?? null
+ sequenceItemIndexRef.current = itemIndex
+ }, [sequence?.completeItem, itemIndex])
useEffect(() => {
let startTimeout: ReturnType<typeof setTimeout> | null = null
- if (sequence && itemIndex !== null) {
- if (
- sequence.sequenceStarted &&
- !started &&
- sequence.activeIndex === itemIndex
- ) {
+ if (hasSequence && itemIndex !== null) {
+ if (sequenceStarted && !started && sequenceActiveIndex === itemIndex) {
setStarted(true)
}
} else if (!startOnView || isInView) {
@@ -14266,8 +14289,9 @@ export const TypingAnimation = ({
startOnView,
isInView,
started,
- sequence?.activeIndex,
- sequence?.sequenceStarted,
+ hasSequence,
+ sequenceActiveIndex,
+ sequenceStarted,
itemIndex,
])
@@ -14284,8 +14308,10 @@ export const TypingAnimation = ({
if (typingEffect !== null) {
clearInterval(typingEffect)
}
- if (sequence && itemIndex !== null) {
- sequence.completeItem(itemIndex)
+ const completeItem = sequenceCompleteItemRef.current
+ const currentItemIndex = sequenceItemIndexRef.current
+ if (completeItem && currentItemIndex !== null) {
+ completeItem(currentItemIndex)
}
}
}, duration)
@@ -15219,7 +15245,6 @@ Title: Tweet Card
Description: A card that displays a tweet with the author's name, handle, and profile picture.
--- file: magicui/tweet-card.tsx ---
-/* eslint-disable @next/next/no-img-element */
import { Suspense } from "react"
import { enrichTweet, type EnrichedTweet, type TweetProps } from "react-tweet"
import { getTweet, type Tweet } from "react-tweet/api"
diff --git a/apps/www/public/r/avatar-circles.json b/apps/www/public/r/avatar-circles.json
index 54e6ada4..bae5972b 100644
--- a/apps/www/public/r/avatar-circles.json
+++ b/apps/www/public/r/avatar-circles.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/avatar-circles.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\n\"use client\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface Avatar {\n imageUrl: string\n profileUrl: string\n}\ninterface AvatarCirclesProps {\n className?: string\n numPeople?: number\n avatarUrls: Avatar[]\n}\n\nexport const AvatarCircles = ({\n numPeople,\n className,\n avatarUrls,\n}: AvatarCirclesProps) => {\n return (\n <div className={cn(\"z-10 flex -space-x-4 rtl:space-x-reverse\", className)}>\n {avatarUrls.map((url, index) => (\n <a\n key={index}\n href={url.profileUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <img\n key={index}\n className=\"h-10 w-10 rounded-full border-2 border-white dark:border-gray-800\"\n src={url.imageUrl}\n width={40}\n height={40}\n alt={`Avatar ${index + 1}`}\n />\n </a>\n ))}\n {(numPeople ?? 0) > 0 && (\n <a\n className=\"flex h-10 w-10 items-center justify-center rounded-full border-2 border-white bg-black text-center text-xs font-medium text-white hover:bg-gray-600 dark:border-gray-800 dark:bg-white dark:text-black\"\n href=\"\"\n >\n +{numPeople}\n </a>\n )}\n </div>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface Avatar {\n imageUrl: string\n profileUrl: string\n}\ninterface AvatarCirclesProps {\n className?: string\n numPeople?: number\n avatarUrls: Avatar[]\n}\n\nexport const AvatarCircles = ({\n numPeople,\n className,\n avatarUrls,\n}: AvatarCirclesProps) => {\n return (\n <div className={cn(\"z-10 flex -space-x-4 rtl:space-x-reverse\", className)}>\n {avatarUrls.map((url, index) => (\n <a\n key={index}\n href={url.profileUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <img\n key={index}\n className=\"h-10 w-10 rounded-full border-2 border-white dark:border-gray-800\"\n src={url.imageUrl}\n width={40}\n height={40}\n alt={`Avatar ${index + 1}`}\n />\n </a>\n ))}\n {(numPeople ?? 0) > 0 && (\n <a\n className=\"flex h-10 w-10 items-center justify-center rounded-full border-2 border-white bg-black text-center text-xs font-medium text-white hover:bg-gray-600 dark:border-gray-800 dark:bg-white dark:text-black\"\n href=\"\"\n >\n +{numPeople}\n </a>\n )}\n </div>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/bento-demo-vertical.json b/apps/www/public/r/bento-demo-vertical.json
index 2adf50ab..3aff2e3a 100644
--- a/apps/www/public/r/bento-demo-vertical.json
+++ b/apps/www/public/r/bento-demo-vertical.json
@@ -13,7 +13,7 @@
"files": [
{
"path": "registry/example/bento-demo-vertical.tsx",
- "content": "import {\n BellIcon,\n CalendarIcon,\n FileTextIcon,\n GlobeIcon,\n InputIcon,\n} from \"@radix-ui/react-icons\"\n\nimport { BentoCard, BentoGrid } from \"@/registry/magicui/bento-grid\"\n\nconst features = [\n {\n Icon: FileTextIcon,\n name: \"Save your files\",\n description: \"We automatically save your files as you type.\",\n href: \"/\",\n cta: \"Learn more\",\n background: <img className=\"absolute -top-20 -right-20 opacity-60\" />,\n className: \"lg:row-start-1 lg:row-end-4 lg:col-start-2 lg:col-end-3\",\n },\n {\n Icon: InputIcon,\n name: \"Full text search\",\n description: \"Search through all your files in one place.\",\n href: \"/\",\n cta: \"Learn more\",\n background: <img className=\"absolute -top-20 -right-20 opacity-60\" />,\n className: \"lg:col-start-1 lg:col-end-2 lg:row-start-1 lg:row-end-3\",\n },\n {\n Icon: GlobeIcon,\n name: \"Multilingual\",\n description: \"Supports 100+ languages and counting.\",\n href: \"/\",\n cta: \"Learn more\",\n background: <img className=\"absolute -top-20 -right-20 opacity-60\" />,\n className: \"lg:col-start-1 lg:col-end-2 lg:row-start-3 lg:row-end-4\",\n },\n {\n Icon: CalendarIcon,\n name: \"Calendar\",\n description: \"Use the calendar to filter your files by date.\",\n href: \"/\",\n cta: \"Learn more\",\n background: <img className=\"absolute -top-20 -right-20 opacity-60\" />,\n className: \"lg:col-start-3 lg:col-end-3 lg:row-start-1 lg:row-end-2\",\n },\n {\n Icon: BellIcon,\n name: \"Notifications\",\n description:\n \"Get notified when someone shares a file or mentions you in a comment.\",\n href: \"/\",\n cta: \"Learn more\",\n background: <img className=\"absolute -top-20 -right-20 opacity-60\" />,\n className: \"lg:col-start-3 lg:col-end-3 lg:row-start-2 lg:row-end-4\",\n },\n]\n\nexport default function BentoDemo() {\n return (\n <BentoGrid className=\"lg:grid-rows-3\">\n {features.map((feature) => (\n <BentoCard key={feature.name} {...feature} />\n ))}\n </BentoGrid>\n )\n}\n",
+ "content": "import {\n BellIcon,\n CalendarIcon,\n FileTextIcon,\n GlobeIcon,\n InputIcon,\n} from \"@radix-ui/react-icons\"\n\nimport { BentoCard, BentoGrid } from \"@/registry/magicui/bento-grid\"\n\nconst features = [\n {\n Icon: FileTextIcon,\n name: \"Save your files\",\n description: \"We automatically save your files as you type.\",\n href: \"/\",\n cta: \"Learn more\",\n background: (\n <img alt=\"\" className=\"absolute -top-20 -right-20 opacity-60\" />\n ),\n className: \"lg:row-start-1 lg:row-end-4 lg:col-start-2 lg:col-end-3\",\n },\n {\n Icon: InputIcon,\n name: \"Full text search\",\n description: \"Search through all your files in one place.\",\n href: \"/\",\n cta: \"Learn more\",\n background: (\n <img alt=\"\" className=\"absolute -top-20 -right-20 opacity-60\" />\n ),\n className: \"lg:col-start-1 lg:col-end-2 lg:row-start-1 lg:row-end-3\",\n },\n {\n Icon: GlobeIcon,\n name: \"Multilingual\",\n description: \"Supports 100+ languages and counting.\",\n href: \"/\",\n cta: \"Learn more\",\n background: (\n <img alt=\"\" className=\"absolute -top-20 -right-20 opacity-60\" />\n ),\n className: \"lg:col-start-1 lg:col-end-2 lg:row-start-3 lg:row-end-4\",\n },\n {\n Icon: CalendarIcon,\n name: \"Calendar\",\n description: \"Use the calendar to filter your files by date.\",\n href: \"/\",\n cta: \"Learn more\",\n background: (\n <img alt=\"\" className=\"absolute -top-20 -right-20 opacity-60\" />\n ),\n className: \"lg:col-start-3 lg:col-end-3 lg:row-start-1 lg:row-end-2\",\n },\n {\n Icon: BellIcon,\n name: \"Notifications\",\n description:\n \"Get notified when someone shares a file or mentions you in a comment.\",\n href: \"/\",\n cta: \"Learn more\",\n background: (\n <img alt=\"\" className=\"absolute -top-20 -right-20 opacity-60\" />\n ),\n className: \"lg:col-start-3 lg:col-end-3 lg:row-start-2 lg:row-end-4\",\n },\n]\n\nexport default function BentoDemo() {\n return (\n <BentoGrid className=\"lg:grid-rows-3\">\n {features.map((feature) => (\n <BentoCard key={feature.name} {...feature} />\n ))}\n </BentoGrid>\n )\n}\n",
"type": "registry:example"
}
]
diff --git a/apps/www/public/r/blur-fade-demo.json b/apps/www/public/r/blur-fade-demo.json
index b396f974..21106476 100644
--- a/apps/www/public/r/blur-fade-demo.json
+++ b/apps/www/public/r/blur-fade-demo.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/example/blur-fade-demo.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\nimport { BlurFade } from \"@/registry/magicui/blur-fade\"\n\nconst images = Array.from({ length: 9 }, (_, i) => {\n const isLandscape = i % 2 === 0\n const width = isLandscape ? 800 : 600\n const height = isLandscape ? 600 : 800\n return `https://picsum.photos/seed/${i + 1}/${width}/${height}`\n})\n\nexport default function BlurFadeDemo() {\n return (\n <section id=\"photos\">\n <div className=\"columns-2 gap-4 sm:columns-3\">\n {images.map((imageUrl, idx) => (\n <BlurFade key={imageUrl} delay={0.25 + idx * 0.05} inView>\n <img\n className=\"mb-4 size-full rounded-lg object-contain\"\n src={imageUrl}\n alt={`Random stock image ${idx + 1}`}\n />\n </BlurFade>\n ))}\n </div>\n </section>\n )\n}\n",
+ "content": "import { BlurFade } from \"@/registry/magicui/blur-fade\"\n\nconst images = Array.from({ length: 9 }, (_, i) => {\n const isLandscape = i % 2 === 0\n const width = isLandscape ? 800 : 600\n const height = isLandscape ? 600 : 800\n return `https://picsum.photos/seed/${i + 1}/${width}/${height}`\n})\n\nexport default function BlurFadeDemo() {\n return (\n <section id=\"photos\">\n <div className=\"columns-2 gap-4 sm:columns-3\">\n {images.map((imageUrl, idx) => (\n <BlurFade key={imageUrl} delay={0.25 + idx * 0.05} inView>\n <img\n className=\"mb-4 size-full rounded-lg object-contain\"\n src={imageUrl}\n alt={`Random stock image ${idx + 1}`}\n />\n </BlurFade>\n ))}\n </div>\n </section>\n )\n}\n",
"type": "registry:example"
}
]
diff --git a/apps/www/public/r/dot-pattern.json b/apps/www/public/r/dot-pattern.json
index 0ddd3782..6d8acf59 100644
--- a/apps/www/public/r/dot-pattern.json
+++ b/apps/www/public/r/dot-pattern.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/dot-pattern.tsx",
- "content": "\"use client\"\n\nimport React, { useEffect, useId, useRef, useState } from \"react\"\nimport { motion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/**\n * DotPattern Component Props\n *\n * @param {number} [width=16] - The horizontal spacing between dots\n * @param {number} [height=16] - The vertical spacing between dots\n * @param {number} [x=0] - The x-offset of the entire pattern\n * @param {number} [y=0] - The y-offset of the entire pattern\n * @param {number} [cx=1] - The x-offset of individual dots\n * @param {number} [cy=1] - The y-offset of individual dots\n * @param {number} [cr=1] - The radius of each dot\n * @param {string} [className] - Additional CSS classes to apply to the SVG container\n * @param {boolean} [glow=false] - Whether dots should have a glowing animation effect\n */\ninterface DotPatternProps extends React.SVGProps<SVGSVGElement> {\n width?: number\n height?: number\n x?: number\n y?: number\n cx?: number\n cy?: number\n cr?: number\n className?: string\n glow?: boolean\n [key: string]: unknown\n}\n\n/**\n * DotPattern Component\n *\n * A React component that creates an animated or static dot pattern background using SVG.\n * The pattern automatically adjusts to fill its container and can optionally display glowing dots.\n *\n * @component\n *\n * @see DotPatternProps for the props interface.\n *\n * @example\n * // Basic usage\n * <DotPattern />\n *\n * // With glowing effect and custom spacing\n * <DotPattern\n * width={20}\n * height={20}\n * glow={true}\n * className=\"opacity-50\"\n * />\n *\n * @notes\n * - The component is client-side only (\"use client\")\n * - Automatically responds to container size changes\n * - When glow is enabled, dots will animate with random delays and durations\n * - Uses Motion for animations\n * - Dots color can be controlled via the text color utility classes\n */\n\nexport function DotPattern({\n width = 16,\n height = 16,\n x = 0,\n y = 0,\n cx = 1,\n cy = 1,\n cr = 1,\n className,\n glow = false,\n ...props\n}: DotPatternProps) {\n const id = useId()\n const containerRef = useRef<SVGSVGElement>(null)\n const [dimensions, setDimensions] = useState({ width: 0, height: 0 })\n\n useEffect(() => {\n const updateDimensions = () => {\n if (containerRef.current) {\n const { width, height } = containerRef.current.getBoundingClientRect()\n setDimensions({ width, height })\n }\n }\n\n updateDimensions()\n window.addEventListener(\"resize\", updateDimensions)\n return () => window.removeEventListener(\"resize\", updateDimensions)\n }, [])\n\n const dots = Array.from(\n {\n length:\n Math.ceil(dimensions.width / width) *\n Math.ceil(dimensions.height / height),\n },\n (_, i) => {\n const col = i % Math.ceil(dimensions.width / width)\n const row = Math.floor(i / Math.ceil(dimensions.width / width))\n return {\n x: col * width + cx,\n y: row * height + cy,\n delay: Math.random() * 5,\n duration: Math.random() * 3 + 2,\n }\n }\n )\n\n return (\n <svg\n ref={containerRef}\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none absolute inset-0 h-full w-full text-neutral-400/80\",\n className\n )}\n {...props}\n >\n <defs>\n <radialGradient id={`${id}-gradient`}>\n <stop offset=\"0%\" stopColor=\"currentColor\" stopOpacity=\"1\" />\n <stop offset=\"100%\" stopColor=\"currentColor\" stopOpacity=\"0\" />\n </radialGradient>\n </defs>\n {dots.map((dot, index) => (\n <motion.circle\n key={`${dot.x}-${dot.y}`}\n cx={dot.x}\n cy={dot.y}\n r={cr}\n fill={glow ? `url(#${id}-gradient)` : \"currentColor\"}\n initial={glow ? { opacity: 0.4, scale: 1 } : {}}\n animate={\n glow\n ? {\n opacity: [0.4, 1, 0.4],\n scale: [1, 1.5, 1],\n }\n : {}\n }\n transition={\n glow\n ? {\n duration: dot.duration,\n repeat: Infinity,\n repeatType: \"reverse\",\n delay: dot.delay,\n ease: \"easeInOut\",\n }\n : {}\n }\n />\n ))}\n </svg>\n )\n}\n",
+ "content": "\"use client\"\n\nimport React, { useEffect, useId, useRef, useState } from \"react\"\nimport { motion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/**\n * DotPattern Component Props\n *\n * @param {number} [width=16] - The horizontal spacing between dots\n * @param {number} [height=16] - The vertical spacing between dots\n * @param {number} [x=0] - The x-offset of the entire pattern\n * @param {number} [y=0] - The y-offset of the entire pattern\n * @param {number} [cx=1] - The x-offset of individual dots\n * @param {number} [cy=1] - The y-offset of individual dots\n * @param {number} [cr=1] - The radius of each dot\n * @param {string} [className] - Additional CSS classes to apply to the SVG container\n * @param {boolean} [glow=false] - Whether dots should have a glowing animation effect\n */\ninterface DotPatternProps extends React.SVGProps<SVGSVGElement> {\n width?: number\n height?: number\n x?: number\n y?: number\n cx?: number\n cy?: number\n cr?: number\n className?: string\n glow?: boolean\n [key: string]: unknown\n}\n\n/**\n * DotPattern Component\n *\n * A React component that creates an animated or static dot pattern background using SVG.\n * The pattern automatically adjusts to fill its container and can optionally display glowing dots.\n *\n * @component\n *\n * @see DotPatternProps for the props interface.\n *\n * @example\n * // Basic usage\n * <DotPattern />\n *\n * // With glowing effect and custom spacing\n * <DotPattern\n * width={20}\n * height={20}\n * glow={true}\n * className=\"opacity-50\"\n * />\n *\n * @notes\n * - The component is client-side only (\"use client\")\n * - Automatically responds to container size changes\n * - When glow is enabled, dots will animate with random delays and durations\n * - Uses Motion for animations\n * - Dots color can be controlled via the text color utility classes\n */\n\nexport function DotPattern({\n width = 16,\n height = 16,\n x = 0,\n y = 0,\n cx = 1,\n cy = 1,\n cr = 1,\n className,\n glow = false,\n ...props\n}: DotPatternProps) {\n const id = useId()\n const containerRef = useRef<SVGSVGElement>(null)\n const [dimensions, setDimensions] = useState({ width: 0, height: 0 })\n\n useEffect(() => {\n const updateDimensions = () => {\n if (containerRef.current) {\n const { width, height } = containerRef.current.getBoundingClientRect()\n setDimensions({ width, height })\n }\n }\n\n updateDimensions()\n window.addEventListener(\"resize\", updateDimensions)\n return () => window.removeEventListener(\"resize\", updateDimensions)\n }, [])\n\n const dots = Array.from(\n {\n length:\n Math.ceil(dimensions.width / width) *\n Math.ceil(dimensions.height / height),\n },\n (_, i) => {\n const col = i % Math.ceil(dimensions.width / width)\n const row = Math.floor(i / Math.ceil(dimensions.width / width))\n return {\n x: col * width + cx + x,\n y: row * height + cy + y,\n delay: Math.random() * 5,\n duration: Math.random() * 3 + 2,\n }\n }\n )\n\n return (\n <svg\n ref={containerRef}\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none absolute inset-0 h-full w-full text-neutral-400/80\",\n className\n )}\n {...props}\n >\n <defs>\n <radialGradient id={`${id}-gradient`}>\n <stop offset=\"0%\" stopColor=\"currentColor\" stopOpacity=\"1\" />\n <stop offset=\"100%\" stopColor=\"currentColor\" stopOpacity=\"0\" />\n </radialGradient>\n </defs>\n {dots.map((dot) => (\n <motion.circle\n key={`${dot.x}-${dot.y}`}\n cx={dot.x}\n cy={dot.y}\n r={cr}\n fill={glow ? `url(#${id}-gradient)` : \"currentColor\"}\n initial={glow ? { opacity: 0.4, scale: 1 } : {}}\n animate={\n glow\n ? {\n opacity: [0.4, 1, 0.4],\n scale: [1, 1.5, 1],\n }\n : {}\n }\n transition={\n glow\n ? {\n duration: dot.duration,\n repeat: Infinity,\n repeatType: \"reverse\",\n delay: dot.delay,\n ease: \"easeInOut\",\n }\n : {}\n }\n />\n ))}\n </svg>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/file-tree.json b/apps/www/public/r/file-tree.json
index f984d47c..89a2802a 100644
--- a/apps/www/public/r/file-tree.json
+++ b/apps/www/public/r/file-tree.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/file-tree.tsx",
- "content": "\"use client\"\n\nimport React, {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { FileIcon, FolderIcon, FolderOpenIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\nimport { ScrollArea } from \"@/components/ui/scroll-area\"\n\ntype TreeViewElement = {\n id: string\n name: string\n isSelectable?: boolean\n children?: TreeViewElement[]\n}\n\ntype TreeContextProps = {\n selectedId: string | undefined\n expandedItems: string[] | undefined\n indicator: boolean\n handleExpand: (id: string) => void\n selectItem: (id: string) => void\n setExpandedItems?: React.Dispatch<React.SetStateAction<string[] | undefined>>\n openIcon?: React.ReactNode\n closeIcon?: React.ReactNode\n direction: \"rtl\" | \"ltr\"\n}\n\nconst TreeContext = createContext<TreeContextProps | null>(null)\n\nconst useTree = () => {\n const context = useContext(TreeContext)\n if (!context) {\n throw new Error(\"useTree must be used within a TreeProvider\")\n }\n return context\n}\n\ntype Direction = \"rtl\" | \"ltr\" | undefined\n\ntype TreeViewProps = {\n initialSelectedId?: string\n indicator?: boolean\n elements?: TreeViewElement[]\n initialExpandedItems?: string[]\n openIcon?: React.ReactNode\n closeIcon?: React.ReactNode\n} & React.HTMLAttributes<HTMLDivElement>\n\nconst Tree = forwardRef<HTMLDivElement, TreeViewProps>(\n (\n {\n className,\n elements,\n initialSelectedId,\n initialExpandedItems,\n children,\n indicator = true,\n openIcon,\n closeIcon,\n dir,\n ...props\n },\n ref\n ) => {\n const [selectedId, setSelectedId] = useState<string | undefined>(\n initialSelectedId\n )\n const [expandedItems, setExpandedItems] = useState<string[] | undefined>(\n initialExpandedItems\n )\n\n const selectItem = useCallback((id: string) => {\n setSelectedId(id)\n }, [])\n\n const handleExpand = useCallback((id: string) => {\n setExpandedItems((prev) => {\n if (prev?.includes(id)) {\n return prev.filter((item) => item !== id)\n }\n return [...(prev ?? []), id]\n })\n }, [])\n\n const expandSpecificTargetedElements = useCallback(\n (elements?: TreeViewElement[], selectId?: string) => {\n if (!elements || !selectId) return\n const findParent = (\n currentElement: TreeViewElement,\n currentPath: string[] = []\n ) => {\n const isSelectable = currentElement.isSelectable ?? true\n const newPath = [...currentPath, currentElement.id]\n if (currentElement.id === selectId) {\n if (isSelectable) {\n setExpandedItems((prev) => [...(prev ?? []), ...newPath])\n } else {\n if (newPath.includes(currentElement.id)) {\n newPath.pop()\n setExpandedItems((prev) => [...(prev ?? []), ...newPath])\n }\n }\n return\n }\n if (\n isSelectable &&\n currentElement.children &&\n currentElement.children.length > 0\n ) {\n currentElement.children.forEach((child) => {\n findParent(child, newPath)\n })\n }\n }\n elements.forEach((element) => {\n findParent(element)\n })\n },\n []\n )\n\n useEffect(() => {\n if (initialSelectedId) {\n expandSpecificTargetedElements(elements, initialSelectedId)\n }\n }, [initialSelectedId, elements])\n\n const direction = dir === \"rtl\" ? \"rtl\" : \"ltr\"\n\n return (\n <TreeContext.Provider\n value={{\n selectedId,\n expandedItems,\n handleExpand,\n selectItem,\n setExpandedItems,\n indicator,\n openIcon,\n closeIcon,\n direction,\n }}\n >\n <div className={cn(\"size-full\", className)}>\n <ScrollArea\n ref={ref}\n className=\"relative h-full px-2\"\n dir={dir as Direction}\n >\n <AccordionPrimitive.Root\n {...props}\n type=\"multiple\"\n defaultValue={expandedItems}\n value={expandedItems}\n className=\"flex flex-col gap-1\"\n onValueChange={(value) =>\n setExpandedItems((prev) => [...(prev ?? []), value[0]])\n }\n dir={dir as Direction}\n >\n {children}\n </AccordionPrimitive.Root>\n </ScrollArea>\n </div>\n </TreeContext.Provider>\n )\n }\n)\n\nTree.displayName = \"Tree\"\n\nconst TreeIndicator = forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const { direction } = useTree()\n\n return (\n <div\n dir={direction}\n ref={ref}\n className={cn(\n \"bg-muted absolute left-1.5 h-full w-px rounded-md py-3 duration-300 ease-in-out hover:bg-slate-300 rtl:right-1.5\",\n className\n )}\n {...props}\n />\n )\n})\n\nTreeIndicator.displayName = \"TreeIndicator\"\n\ntype FolderProps = {\n expandedItems?: string[]\n element: string\n isSelectable?: boolean\n isSelect?: boolean\n} & React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>\n\nconst Folder = forwardRef<\n HTMLDivElement,\n FolderProps & React.HTMLAttributes<HTMLDivElement>\n>(\n (\n {\n className,\n element,\n value,\n isSelectable = true,\n isSelect,\n children,\n ...props\n },\n ref\n ) => {\n const {\n direction,\n handleExpand,\n expandedItems,\n indicator,\n setExpandedItems,\n openIcon,\n closeIcon,\n } = useTree()\n\n return (\n <AccordionPrimitive.Item\n {...props}\n value={value}\n className=\"relative h-full overflow-hidden\"\n >\n <AccordionPrimitive.Trigger\n className={cn(\n `flex items-center gap-1 rounded-md text-sm`,\n className,\n {\n \"bg-muted rounded-md\": isSelect && isSelectable,\n \"cursor-pointer\": isSelectable,\n \"cursor-not-allowed opacity-50\": !isSelectable,\n }\n )}\n disabled={!isSelectable}\n onClick={() => handleExpand(value)}\n >\n {expandedItems?.includes(value)\n ? (openIcon ?? <FolderOpenIcon className=\"size-4\" />)\n : (closeIcon ?? <FolderIcon className=\"size-4\" />)}\n <span>{element}</span>\n </AccordionPrimitive.Trigger>\n <AccordionPrimitive.Content className=\"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down relative h-full overflow-hidden text-sm\">\n {element && indicator && <TreeIndicator aria-hidden=\"true\" />}\n <AccordionPrimitive.Root\n dir={direction}\n type=\"multiple\"\n className=\"ml-5 flex flex-col gap-1 py-1 rtl:mr-5\"\n defaultValue={expandedItems}\n value={expandedItems}\n onValueChange={(value) => {\n setExpandedItems?.((prev) => [...(prev ?? []), value[0]])\n }}\n >\n {children}\n </AccordionPrimitive.Root>\n </AccordionPrimitive.Content>\n </AccordionPrimitive.Item>\n )\n }\n)\n\nFolder.displayName = \"Folder\"\n\nconst File = forwardRef<\n HTMLButtonElement,\n {\n value: string\n handleSelect?: (id: string) => void\n isSelectable?: boolean\n isSelect?: boolean\n fileIcon?: React.ReactNode\n } & React.ButtonHTMLAttributes<HTMLButtonElement>\n>(\n (\n {\n value,\n className,\n handleSelect,\n isSelectable = true,\n isSelect,\n fileIcon,\n children,\n ...props\n },\n ref\n ) => {\n const { direction, selectedId, selectItem } = useTree()\n const isSelected = isSelect ?? selectedId === value\n return (\n <button\n ref={ref}\n type=\"button\"\n disabled={!isSelectable}\n className={cn(\n \"flex w-fit items-center gap-1 rounded-md pr-1 text-sm duration-200 ease-in-out rtl:pr-0 rtl:pl-1\",\n {\n \"bg-muted\": isSelected && isSelectable,\n },\n isSelectable ? \"cursor-pointer\" : \"cursor-not-allowed opacity-50\",\n direction === \"rtl\" ? \"rtl\" : \"ltr\",\n className\n )}\n onClick={() => selectItem(value)}\n {...props}\n >\n {fileIcon ?? <FileIcon className=\"size-4\" />}\n {children}\n </button>\n )\n }\n)\n\nFile.displayName = \"File\"\n\nconst CollapseButton = forwardRef<\n HTMLButtonElement,\n {\n elements: TreeViewElement[]\n expandAll?: boolean\n } & React.HTMLAttributes<HTMLButtonElement>\n>(({ className, elements, expandAll = false, children, ...props }, ref) => {\n const { expandedItems, setExpandedItems } = useTree()\n\n const expendAllTree = useCallback((elements: TreeViewElement[]) => {\n const expandTree = (element: TreeViewElement) => {\n const isSelectable = element.isSelectable ?? true\n if (isSelectable && element.children && element.children.length > 0) {\n setExpandedItems?.((prev) => [...(prev ?? []), element.id])\n element.children.forEach(expandTree)\n }\n }\n\n elements.forEach(expandTree)\n }, [])\n\n const closeAll = useCallback(() => {\n setExpandedItems?.([])\n }, [])\n\n useEffect(() => {\n console.log(expandAll)\n if (expandAll) {\n expendAllTree(elements)\n }\n }, [expandAll])\n\n return (\n <Button\n variant={\"ghost\"}\n className=\"absolute right-2 bottom-1 h-8 w-fit p-1\"\n onClick={\n expandedItems && expandedItems.length > 0\n ? closeAll\n : () => expendAllTree(elements)\n }\n ref={ref}\n {...props}\n >\n {children}\n <span className=\"sr-only\">Toggle</span>\n </Button>\n )\n})\n\nCollapseButton.displayName = \"CollapseButton\"\n\nexport { CollapseButton, File, Folder, Tree, type TreeViewElement }\n",
+ "content": "\"use client\"\n\nimport React, {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { FileIcon, FolderIcon, FolderOpenIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\nimport { ScrollArea } from \"@/components/ui/scroll-area\"\n\ntype TreeViewElement = {\n id: string\n name: string\n isSelectable?: boolean\n children?: TreeViewElement[]\n}\n\ntype TreeContextProps = {\n selectedId: string | undefined\n expandedItems: string[] | undefined\n indicator: boolean\n handleExpand: (id: string) => void\n selectItem: (id: string) => void\n setExpandedItems?: React.Dispatch<React.SetStateAction<string[] | undefined>>\n openIcon?: React.ReactNode\n closeIcon?: React.ReactNode\n direction: \"rtl\" | \"ltr\"\n}\n\nconst TreeContext = createContext<TreeContextProps | null>(null)\n\nconst useTree = () => {\n const context = useContext(TreeContext)\n if (!context) {\n throw new Error(\"useTree must be used within a TreeProvider\")\n }\n return context\n}\n\ntype Direction = \"rtl\" | \"ltr\" | undefined\n\ntype TreeViewProps = {\n initialSelectedId?: string\n indicator?: boolean\n elements?: TreeViewElement[]\n initialExpandedItems?: string[]\n openIcon?: React.ReactNode\n closeIcon?: React.ReactNode\n} & React.HTMLAttributes<HTMLDivElement>\n\nconst Tree = forwardRef<HTMLDivElement, TreeViewProps>(\n (\n {\n className,\n elements,\n initialSelectedId,\n initialExpandedItems,\n children,\n indicator = true,\n openIcon,\n closeIcon,\n dir,\n ...props\n },\n ref\n ) => {\n const [selectedId, setSelectedId] = useState<string | undefined>(\n initialSelectedId\n )\n const [expandedItems, setExpandedItems] = useState<string[] | undefined>(\n initialExpandedItems\n )\n\n const selectItem = useCallback((id: string) => {\n setSelectedId(id)\n }, [])\n\n const handleExpand = useCallback((id: string) => {\n setExpandedItems((prev) => {\n if (prev?.includes(id)) {\n return prev.filter((item) => item !== id)\n }\n return [...(prev ?? []), id]\n })\n }, [])\n\n const expandSpecificTargetedElements = useCallback(\n (elements?: TreeViewElement[], selectId?: string) => {\n if (!elements || !selectId) return\n const findParent = (\n currentElement: TreeViewElement,\n currentPath: string[] = []\n ) => {\n const isSelectable = currentElement.isSelectable ?? true\n const newPath = [...currentPath, currentElement.id]\n if (currentElement.id === selectId) {\n if (isSelectable) {\n setExpandedItems((prev) => [...(prev ?? []), ...newPath])\n } else {\n if (newPath.includes(currentElement.id)) {\n newPath.pop()\n setExpandedItems((prev) => [...(prev ?? []), ...newPath])\n }\n }\n return\n }\n if (\n isSelectable &&\n currentElement.children &&\n currentElement.children.length > 0\n ) {\n currentElement.children.forEach((child) => {\n findParent(child, newPath)\n })\n }\n }\n elements.forEach((element) => {\n findParent(element)\n })\n },\n []\n )\n\n useEffect(() => {\n if (initialSelectedId) {\n expandSpecificTargetedElements(elements, initialSelectedId)\n }\n }, [initialSelectedId, elements, expandSpecificTargetedElements])\n\n const direction = dir === \"rtl\" ? \"rtl\" : \"ltr\"\n\n return (\n <TreeContext.Provider\n value={{\n selectedId,\n expandedItems,\n handleExpand,\n selectItem,\n setExpandedItems,\n indicator,\n openIcon,\n closeIcon,\n direction,\n }}\n >\n <div className={cn(\"size-full\", className)}>\n <ScrollArea\n ref={ref}\n className=\"relative h-full px-2\"\n dir={dir as Direction}\n >\n <AccordionPrimitive.Root\n {...props}\n type=\"multiple\"\n defaultValue={expandedItems}\n value={expandedItems}\n className=\"flex flex-col gap-1\"\n onValueChange={(value) =>\n setExpandedItems((prev) => [...(prev ?? []), value[0]])\n }\n dir={dir as Direction}\n >\n {children}\n </AccordionPrimitive.Root>\n </ScrollArea>\n </div>\n </TreeContext.Provider>\n )\n }\n)\n\nTree.displayName = \"Tree\"\n\nconst TreeIndicator = forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const { direction } = useTree()\n\n return (\n <div\n dir={direction}\n ref={ref}\n className={cn(\n \"bg-muted absolute left-1.5 h-full w-px rounded-md py-3 duration-300 ease-in-out hover:bg-slate-300 rtl:right-1.5\",\n className\n )}\n {...props}\n />\n )\n})\n\nTreeIndicator.displayName = \"TreeIndicator\"\n\ntype FolderProps = {\n expandedItems?: string[]\n element: string\n isSelectable?: boolean\n isSelect?: boolean\n} & React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>\n\nconst Folder = forwardRef<\n HTMLDivElement,\n FolderProps & React.HTMLAttributes<HTMLDivElement>\n>(\n (\n {\n className,\n element,\n value,\n isSelectable = true,\n isSelect,\n children,\n ...props\n },\n ref\n ) => {\n const {\n direction,\n handleExpand,\n expandedItems,\n indicator,\n setExpandedItems,\n openIcon,\n closeIcon,\n } = useTree()\n\n return (\n <AccordionPrimitive.Item\n ref={ref}\n {...props}\n value={value}\n className=\"relative h-full overflow-hidden\"\n >\n <AccordionPrimitive.Trigger\n className={cn(\n `flex items-center gap-1 rounded-md text-sm`,\n className,\n {\n \"bg-muted rounded-md\": isSelect && isSelectable,\n \"cursor-pointer\": isSelectable,\n \"cursor-not-allowed opacity-50\": !isSelectable,\n }\n )}\n disabled={!isSelectable}\n onClick={() => handleExpand(value)}\n >\n {expandedItems?.includes(value)\n ? (openIcon ?? <FolderOpenIcon className=\"size-4\" />)\n : (closeIcon ?? <FolderIcon className=\"size-4\" />)}\n <span>{element}</span>\n </AccordionPrimitive.Trigger>\n <AccordionPrimitive.Content className=\"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down relative h-full overflow-hidden text-sm\">\n {element && indicator && <TreeIndicator aria-hidden=\"true\" />}\n <AccordionPrimitive.Root\n dir={direction}\n type=\"multiple\"\n className=\"ml-5 flex flex-col gap-1 py-1 rtl:mr-5\"\n defaultValue={expandedItems}\n value={expandedItems}\n onValueChange={(value) => {\n setExpandedItems?.((prev) => [...(prev ?? []), value[0]])\n }}\n >\n {children}\n </AccordionPrimitive.Root>\n </AccordionPrimitive.Content>\n </AccordionPrimitive.Item>\n )\n }\n)\n\nFolder.displayName = \"Folder\"\n\nconst File = forwardRef<\n HTMLButtonElement,\n {\n value: string\n handleSelect?: (id: string) => void\n isSelectable?: boolean\n isSelect?: boolean\n fileIcon?: React.ReactNode\n } & React.ButtonHTMLAttributes<HTMLButtonElement>\n>(\n (\n {\n value,\n className,\n handleSelect,\n onClick,\n isSelectable = true,\n isSelect,\n fileIcon,\n children,\n ...props\n },\n ref\n ) => {\n const { direction, selectedId, selectItem } = useTree()\n const isSelected = isSelect ?? selectedId === value\n return (\n <button\n ref={ref}\n type=\"button\"\n disabled={!isSelectable}\n className={cn(\n \"flex w-fit items-center gap-1 rounded-md pr-1 text-sm duration-200 ease-in-out rtl:pr-0 rtl:pl-1\",\n {\n \"bg-muted\": isSelected && isSelectable,\n },\n isSelectable ? \"cursor-pointer\" : \"cursor-not-allowed opacity-50\",\n direction === \"rtl\" ? \"rtl\" : \"ltr\",\n className\n )}\n onClick={(event) => {\n selectItem(value)\n handleSelect?.(value)\n onClick?.(event)\n }}\n {...props}\n >\n {fileIcon ?? <FileIcon className=\"size-4\" />}\n {children}\n </button>\n )\n }\n)\n\nFile.displayName = \"File\"\n\nconst CollapseButton = forwardRef<\n HTMLButtonElement,\n {\n elements: TreeViewElement[]\n expandAll?: boolean\n } & React.HTMLAttributes<HTMLButtonElement>\n>(({ className, elements, expandAll = false, children, ...props }, ref) => {\n const { expandedItems, setExpandedItems } = useTree()\n\n const expendAllTree = useCallback((elements: TreeViewElement[]) => {\n const expandedElementIds: string[] = []\n\n const expandTree = (element: TreeViewElement) => {\n const isSelectable = element.isSelectable ?? true\n if (isSelectable && element.children && element.children.length > 0) {\n expandedElementIds.push(element.id)\n for (const child of element.children) {\n expandTree(child)\n }\n }\n }\n\n for (const element of elements) {\n expandTree(element)\n }\n\n return [...new Set(expandedElementIds)]\n }, [])\n\n const closeAll = useCallback(() => {\n setExpandedItems?.([])\n }, [setExpandedItems])\n\n useEffect(() => {\n if (expandAll) {\n setExpandedItems?.(expendAllTree(elements))\n }\n }, [expandAll, elements, expendAllTree, setExpandedItems])\n\n return (\n <Button\n variant={\"ghost\"}\n className={cn(\"absolute right-2 bottom-1 h-8 w-fit p-1\", className)}\n onClick={\n expandedItems && expandedItems.length > 0\n ? closeAll\n : () => setExpandedItems?.(expendAllTree(elements))\n }\n ref={ref}\n {...props}\n >\n {children}\n <span className=\"sr-only\">Toggle</span>\n </Button>\n )\n})\n\nCollapseButton.displayName = \"CollapseButton\"\n\nexport { CollapseButton, File, Folder, Tree, type TreeViewElement }\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/globe.json b/apps/www/public/r/globe.json
index 8985f365..4c72d0a3 100644
--- a/apps/www/public/r/globe.json
+++ b/apps/www/public/r/globe.json
@@ -11,7 +11,7 @@
"files": [
{
"path": "registry/magicui/globe.tsx",
- "content": "\"use client\"\n\nimport { useEffect, useRef } from \"react\"\nimport createGlobe, { type COBEOptions } from \"cobe\"\nimport { useMotionValue, useSpring } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst MOVEMENT_DAMPING = 1400\n\nconst GLOBE_CONFIG: COBEOptions = {\n width: 800,\n height: 800,\n onRender: () => {},\n devicePixelRatio: 2,\n phi: 0,\n theta: 0.3,\n dark: 0,\n diffuse: 0.4,\n mapSamples: 16000,\n mapBrightness: 1.2,\n baseColor: [1, 1, 1],\n markerColor: [251 / 255, 100 / 255, 21 / 255],\n glowColor: [1, 1, 1],\n markers: [\n { location: [14.5995, 120.9842], size: 0.03 },\n { location: [19.076, 72.8777], size: 0.1 },\n { location: [23.8103, 90.4125], size: 0.05 },\n { location: [30.0444, 31.2357], size: 0.07 },\n { location: [39.9042, 116.4074], size: 0.08 },\n { location: [-23.5505, -46.6333], size: 0.1 },\n { location: [19.4326, -99.1332], size: 0.1 },\n { location: [40.7128, -74.006], size: 0.1 },\n { location: [34.6937, 135.5022], size: 0.05 },\n { location: [41.0082, 28.9784], size: 0.06 },\n ],\n}\n\nexport function Globe({\n className,\n config = GLOBE_CONFIG,\n}: {\n className?: string\n config?: COBEOptions\n}) {\n let phi = 0\n let width = 0\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const pointerInteracting = useRef<number | null>(null)\n const pointerInteractionMovement = useRef(0)\n\n const r = useMotionValue(0)\n const rs = useSpring(r, {\n mass: 1,\n damping: 30,\n stiffness: 100,\n })\n\n const updatePointerInteraction = (value: number | null) => {\n pointerInteracting.current = value\n if (canvasRef.current) {\n canvasRef.current.style.cursor = value !== null ? \"grabbing\" : \"grab\"\n }\n }\n\n const updateMovement = (clientX: number) => {\n if (pointerInteracting.current !== null) {\n const delta = clientX - pointerInteracting.current\n pointerInteractionMovement.current = delta\n r.set(r.get() + delta / MOVEMENT_DAMPING)\n }\n }\n\n useEffect(() => {\n const onResize = () => {\n if (canvasRef.current) {\n width = canvasRef.current.offsetWidth\n }\n }\n\n window.addEventListener(\"resize\", onResize)\n onResize()\n\n const globe = createGlobe(canvasRef.current!, {\n ...config,\n width: width * 2,\n height: width * 2,\n onRender: (state) => {\n if (!pointerInteracting.current) phi += 0.005\n state.phi = phi + rs.get()\n state.width = width * 2\n state.height = width * 2\n },\n })\n\n setTimeout(() => (canvasRef.current!.style.opacity = \"1\"), 0)\n return () => {\n globe.destroy()\n window.removeEventListener(\"resize\", onResize)\n }\n }, [rs, config])\n\n return (\n <div\n className={cn(\n \"absolute inset-0 mx-auto aspect-[1/1] w-full max-w-[600px]\",\n className\n )}\n >\n <canvas\n className={cn(\n \"size-full opacity-0 transition-opacity duration-500 [contain:layout_paint_size]\"\n )}\n ref={canvasRef}\n onPointerDown={(e) => {\n pointerInteracting.current = e.clientX\n updatePointerInteraction(e.clientX)\n }}\n onPointerUp={() => updatePointerInteraction(null)}\n onPointerOut={() => updatePointerInteraction(null)}\n onMouseMove={(e) => updateMovement(e.clientX)}\n onTouchMove={(e) =>\n e.touches[0] && updateMovement(e.touches[0].clientX)\n }\n />\n </div>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { useEffect, useRef } from \"react\"\nimport createGlobe, { type COBEOptions } from \"cobe\"\nimport { useMotionValue, useSpring } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst MOVEMENT_DAMPING = 1400\n\nconst GLOBE_CONFIG: COBEOptions = {\n width: 800,\n height: 800,\n onRender: () => {},\n devicePixelRatio: 2,\n phi: 0,\n theta: 0.3,\n dark: 0,\n diffuse: 0.4,\n mapSamples: 16000,\n mapBrightness: 1.2,\n baseColor: [1, 1, 1],\n markerColor: [251 / 255, 100 / 255, 21 / 255],\n glowColor: [1, 1, 1],\n markers: [\n { location: [14.5995, 120.9842], size: 0.03 },\n { location: [19.076, 72.8777], size: 0.1 },\n { location: [23.8103, 90.4125], size: 0.05 },\n { location: [30.0444, 31.2357], size: 0.07 },\n { location: [39.9042, 116.4074], size: 0.08 },\n { location: [-23.5505, -46.6333], size: 0.1 },\n { location: [19.4326, -99.1332], size: 0.1 },\n { location: [40.7128, -74.006], size: 0.1 },\n { location: [34.6937, 135.5022], size: 0.05 },\n { location: [41.0082, 28.9784], size: 0.06 },\n ],\n}\n\nexport function Globe({\n className,\n config = GLOBE_CONFIG,\n}: {\n className?: string\n config?: COBEOptions\n}) {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const phiRef = useRef(0)\n const widthRef = useRef(0)\n const pointerInteracting = useRef<number | null>(null)\n const pointerInteractionMovement = useRef(0)\n\n const r = useMotionValue(0)\n const rs = useSpring(r, {\n mass: 1,\n damping: 30,\n stiffness: 100,\n })\n\n const updatePointerInteraction = (value: number | null) => {\n pointerInteracting.current = value\n if (canvasRef.current) {\n canvasRef.current.style.cursor = value !== null ? \"grabbing\" : \"grab\"\n }\n }\n\n const updateMovement = (clientX: number) => {\n if (pointerInteracting.current !== null) {\n const delta = clientX - pointerInteracting.current\n pointerInteractionMovement.current = delta\n r.set(r.get() + delta / MOVEMENT_DAMPING)\n }\n }\n\n useEffect(() => {\n const onResize = () => {\n if (canvasRef.current) {\n widthRef.current = canvasRef.current.offsetWidth\n }\n }\n\n window.addEventListener(\"resize\", onResize)\n onResize()\n\n const globe = createGlobe(canvasRef.current!, {\n ...config,\n width: widthRef.current * 2,\n height: widthRef.current * 2,\n onRender: (state) => {\n if (!pointerInteracting.current) phiRef.current += 0.005\n state.phi = phiRef.current + rs.get()\n state.width = widthRef.current * 2\n state.height = widthRef.current * 2\n },\n })\n\n setTimeout(() => (canvasRef.current!.style.opacity = \"1\"), 0)\n return () => {\n globe.destroy()\n window.removeEventListener(\"resize\", onResize)\n }\n }, [rs, config])\n\n return (\n <div\n className={cn(\n \"absolute inset-0 mx-auto aspect-[1/1] w-full max-w-[600px]\",\n className\n )}\n >\n <canvas\n className={cn(\n \"size-full opacity-0 transition-opacity duration-500 [contain:layout_paint_size]\"\n )}\n ref={canvasRef}\n onPointerDown={(e) => {\n pointerInteracting.current = e.clientX\n updatePointerInteraction(e.clientX)\n }}\n onPointerUp={() => updatePointerInteraction(null)}\n onPointerOut={() => updatePointerInteraction(null)}\n onMouseMove={(e) => updateMovement(e.clientX)}\n onTouchMove={(e) =>\n e.touches[0] && updateMovement(e.touches[0].clientX)\n }\n />\n </div>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/hero-video-dialog.json b/apps/www/public/r/hero-video-dialog.json
index d1535acc..37bb6020 100644
--- a/apps/www/public/r/hero-video-dialog.json
+++ b/apps/www/public/r/hero-video-dialog.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/hero-video-dialog.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\n\"use client\"\n\nimport { useState } from \"react\"\nimport { Play, XIcon } from \"lucide-react\"\nimport { AnimatePresence, motion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype AnimationStyle =\n | \"from-bottom\"\n | \"from-center\"\n | \"from-top\"\n | \"from-left\"\n | \"from-right\"\n | \"fade\"\n | \"top-in-bottom-out\"\n | \"left-in-right-out\"\n\ninterface HeroVideoProps {\n animationStyle?: AnimationStyle\n videoSrc: string\n thumbnailSrc: string\n thumbnailAlt?: string\n className?: string\n}\n\nconst animationVariants = {\n \"from-bottom\": {\n initial: { y: \"100%\", opacity: 0 },\n animate: { y: 0, opacity: 1 },\n exit: { y: \"100%\", opacity: 0 },\n },\n \"from-center\": {\n initial: { scale: 0.5, opacity: 0 },\n animate: { scale: 1, opacity: 1 },\n exit: { scale: 0.5, opacity: 0 },\n },\n \"from-top\": {\n initial: { y: \"-100%\", opacity: 0 },\n animate: { y: 0, opacity: 1 },\n exit: { y: \"-100%\", opacity: 0 },\n },\n \"from-left\": {\n initial: { x: \"-100%\", opacity: 0 },\n animate: { x: 0, opacity: 1 },\n exit: { x: \"-100%\", opacity: 0 },\n },\n \"from-right\": {\n initial: { x: \"100%\", opacity: 0 },\n animate: { x: 0, opacity: 1 },\n exit: { x: \"100%\", opacity: 0 },\n },\n fade: {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n },\n \"top-in-bottom-out\": {\n initial: { y: \"-100%\", opacity: 0 },\n animate: { y: 0, opacity: 1 },\n exit: { y: \"100%\", opacity: 0 },\n },\n \"left-in-right-out\": {\n initial: { x: \"-100%\", opacity: 0 },\n animate: { x: 0, opacity: 1 },\n exit: { x: \"100%\", opacity: 0 },\n },\n}\n\nexport function HeroVideoDialog({\n animationStyle = \"from-center\",\n videoSrc,\n thumbnailSrc,\n thumbnailAlt = \"Video thumbnail\",\n className,\n}: HeroVideoProps) {\n const [isVideoOpen, setIsVideoOpen] = useState(false)\n const selectedAnimation = animationVariants[animationStyle]\n\n return (\n <div className={cn(\"relative\", className)}>\n <button\n type=\"button\"\n aria-label=\"Play video\"\n className=\"group relative cursor-pointer border-0 bg-transparent p-0\"\n onClick={() => setIsVideoOpen(true)}\n >\n <img\n src={thumbnailSrc}\n alt={thumbnailAlt}\n width={1920}\n height={1080}\n className=\"w-full rounded-md border shadow-lg transition-all duration-200 ease-out group-hover:brightness-[0.8]\"\n />\n <div className=\"absolute inset-0 flex scale-[0.9] items-center justify-center rounded-2xl transition-all duration-200 ease-out group-hover:scale-100\">\n <div className=\"bg-primary/10 flex size-28 items-center justify-center rounded-full backdrop-blur-md\">\n <div\n className={`from-primary/30 to-primary relative flex size-20 scale-100 items-center justify-center rounded-full bg-gradient-to-b shadow-md transition-all duration-200 ease-out group-hover:scale-[1.2]`}\n >\n <Play\n className=\"size-8 scale-100 fill-white text-white transition-transform duration-200 ease-out group-hover:scale-105\"\n style={{\n filter:\n \"drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06))\",\n }}\n />\n </div>\n </div>\n </div>\n </button>\n <AnimatePresence>\n {isVideoOpen && (\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === \"Escape\" || e.key === \"Enter\" || e.key === \" \") {\n setIsVideoOpen(false)\n }\n }}\n onClick={() => setIsVideoOpen(false)}\n exit={{ opacity: 0 }}\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-md\"\n >\n <motion.div\n {...selectedAnimation}\n transition={{ type: \"spring\", damping: 30, stiffness: 300 }}\n className=\"relative mx-4 aspect-video w-full max-w-4xl md:mx-0\"\n >\n <motion.button className=\"absolute -top-16 right-0 rounded-full bg-neutral-900/50 p-2 text-xl text-white ring-1 backdrop-blur-md dark:bg-neutral-100/50 dark:text-black\">\n <XIcon className=\"size-5\" />\n </motion.button>\n <div className=\"relative isolate z-[1] size-full overflow-hidden rounded-2xl border-2 border-white\">\n <iframe\n src={videoSrc}\n title=\"Hero Video player\"\n className=\"mt-0 size-full rounded-2xl\"\n allowFullScreen\n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\"\n ></iframe>\n </div>\n </motion.div>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport { Play, XIcon } from \"lucide-react\"\nimport { AnimatePresence, motion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype AnimationStyle =\n | \"from-bottom\"\n | \"from-center\"\n | \"from-top\"\n | \"from-left\"\n | \"from-right\"\n | \"fade\"\n | \"top-in-bottom-out\"\n | \"left-in-right-out\"\n\ninterface HeroVideoProps {\n animationStyle?: AnimationStyle\n videoSrc: string\n thumbnailSrc: string\n thumbnailAlt?: string\n className?: string\n}\n\nconst animationVariants = {\n \"from-bottom\": {\n initial: { y: \"100%\", opacity: 0 },\n animate: { y: 0, opacity: 1 },\n exit: { y: \"100%\", opacity: 0 },\n },\n \"from-center\": {\n initial: { scale: 0.5, opacity: 0 },\n animate: { scale: 1, opacity: 1 },\n exit: { scale: 0.5, opacity: 0 },\n },\n \"from-top\": {\n initial: { y: \"-100%\", opacity: 0 },\n animate: { y: 0, opacity: 1 },\n exit: { y: \"-100%\", opacity: 0 },\n },\n \"from-left\": {\n initial: { x: \"-100%\", opacity: 0 },\n animate: { x: 0, opacity: 1 },\n exit: { x: \"-100%\", opacity: 0 },\n },\n \"from-right\": {\n initial: { x: \"100%\", opacity: 0 },\n animate: { x: 0, opacity: 1 },\n exit: { x: \"100%\", opacity: 0 },\n },\n fade: {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n },\n \"top-in-bottom-out\": {\n initial: { y: \"-100%\", opacity: 0 },\n animate: { y: 0, opacity: 1 },\n exit: { y: \"100%\", opacity: 0 },\n },\n \"left-in-right-out\": {\n initial: { x: \"-100%\", opacity: 0 },\n animate: { x: 0, opacity: 1 },\n exit: { x: \"100%\", opacity: 0 },\n },\n}\n\nexport function HeroVideoDialog({\n animationStyle = \"from-center\",\n videoSrc,\n thumbnailSrc,\n thumbnailAlt = \"Video thumbnail\",\n className,\n}: HeroVideoProps) {\n const [isVideoOpen, setIsVideoOpen] = useState(false)\n const selectedAnimation = animationVariants[animationStyle]\n\n return (\n <div className={cn(\"relative\", className)}>\n <button\n type=\"button\"\n aria-label=\"Play video\"\n className=\"group relative cursor-pointer border-0 bg-transparent p-0\"\n onClick={() => setIsVideoOpen(true)}\n >\n <img\n src={thumbnailSrc}\n alt={thumbnailAlt}\n width={1920}\n height={1080}\n className=\"w-full rounded-md border shadow-lg transition-all duration-200 ease-out group-hover:brightness-[0.8]\"\n />\n <div className=\"absolute inset-0 flex scale-[0.9] items-center justify-center rounded-2xl transition-all duration-200 ease-out group-hover:scale-100\">\n <div className=\"bg-primary/10 flex size-28 items-center justify-center rounded-full backdrop-blur-md\">\n <div\n className={`from-primary/30 to-primary relative flex size-20 scale-100 items-center justify-center rounded-full bg-gradient-to-b shadow-md transition-all duration-200 ease-out group-hover:scale-[1.2]`}\n >\n <Play\n className=\"size-8 scale-100 fill-white text-white transition-transform duration-200 ease-out group-hover:scale-105\"\n style={{\n filter:\n \"drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06))\",\n }}\n />\n </div>\n </div>\n </div>\n </button>\n <AnimatePresence>\n {isVideoOpen && (\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === \"Escape\" || e.key === \"Enter\" || e.key === \" \") {\n setIsVideoOpen(false)\n }\n }}\n onClick={() => setIsVideoOpen(false)}\n exit={{ opacity: 0 }}\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-md\"\n >\n <motion.div\n {...selectedAnimation}\n transition={{ type: \"spring\", damping: 30, stiffness: 300 }}\n className=\"relative mx-4 aspect-video w-full max-w-4xl md:mx-0\"\n >\n <motion.button className=\"absolute -top-16 right-0 rounded-full bg-neutral-900/50 p-2 text-xl text-white ring-1 backdrop-blur-md dark:bg-neutral-100/50 dark:text-black\">\n <XIcon className=\"size-5\" />\n </motion.button>\n <div className=\"relative isolate z-[1] size-full overflow-hidden rounded-2xl border-2 border-white\">\n <iframe\n src={videoSrc}\n title=\"Hero Video player\"\n className=\"mt-0 size-full rounded-2xl\"\n allowFullScreen\n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\"\n ></iframe>\n </div>\n </motion.div>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/icon-cloud.json b/apps/www/public/r/icon-cloud.json
index ee894ac5..15587db8 100644
--- a/apps/www/public/r/icon-cloud.json
+++ b/apps/www/public/r/icon-cloud.json
@@ -8,7 +8,7 @@
"files": [
{
"path": "registry/magicui/icon-cloud.tsx",
- "content": "\"use client\"\n\nimport React, { useEffect, useRef, useState } from \"react\"\nimport { renderToString } from \"react-dom/server\"\n\ninterface Icon {\n x: number\n y: number\n z: number\n scale: number\n opacity: number\n id: number\n}\n\ninterface IconCloudProps {\n icons?: React.ReactNode[]\n images?: string[]\n}\n\nfunction easeOutCubic(t: number): number {\n return 1 - Math.pow(1 - t, 3)\n}\n\nexport function IconCloud({ icons, images }: IconCloudProps) {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const [iconPositions, setIconPositions] = useState<Icon[]>([])\n const [rotation, setRotation] = useState({ x: 0, y: 0 })\n const [isDragging, setIsDragging] = useState(false)\n const [lastMousePos, setLastMousePos] = useState({ x: 0, y: 0 })\n const [mousePos, setMousePos] = useState({ x: 0, y: 0 })\n const [targetRotation, setTargetRotation] = useState<{\n x: number\n y: number\n startX: number\n startY: number\n distance: number\n startTime: number\n duration: number\n } | null>(null)\n const animationFrameRef = useRef<number>(0)\n const rotationRef = useRef(rotation)\n const iconCanvasesRef = useRef<HTMLCanvasElement[]>([])\n const imagesLoadedRef = useRef<boolean[]>([])\n\n // Create icon canvases once when icons/images change\n useEffect(() => {\n if (!icons && !images) return\n\n const items = icons ?? images ?? []\n imagesLoadedRef.current = new Array(items.length).fill(false)\n\n const newIconCanvases = items.map((item, index) => {\n const offscreen = document.createElement(\"canvas\")\n offscreen.width = 40\n offscreen.height = 40\n const offCtx = offscreen.getContext(\"2d\")\n\n if (offCtx) {\n if (images) {\n // Handle image URLs directly\n const img = new Image()\n img.crossOrigin = \"anonymous\"\n img.src = items[index] as string\n img.onload = () => {\n offCtx.clearRect(0, 0, offscreen.width, offscreen.height)\n\n // Create circular clipping path\n offCtx.beginPath()\n offCtx.arc(20, 20, 20, 0, Math.PI * 2)\n offCtx.closePath()\n offCtx.clip()\n\n // Draw the image\n offCtx.drawImage(img, 0, 0, 40, 40)\n\n imagesLoadedRef.current[index] = true\n }\n } else {\n // Handle SVG icons\n offCtx.scale(0.4, 0.4)\n const svgString = renderToString(item as React.ReactElement)\n const img = new Image()\n img.src = \"data:image/svg+xml;base64,\" + btoa(svgString)\n img.onload = () => {\n offCtx.clearRect(0, 0, offscreen.width, offscreen.height)\n offCtx.drawImage(img, 0, 0)\n imagesLoadedRef.current[index] = true\n }\n }\n }\n return offscreen\n })\n\n iconCanvasesRef.current = newIconCanvases\n }, [icons, images])\n\n // Generate initial icon positions on a sphere\n useEffect(() => {\n const items = icons ?? images ?? []\n const newIcons: Icon[] = []\n const numIcons = items.length || 20\n\n // Fibonacci sphere parameters\n const offset = 2 / numIcons\n const increment = Math.PI * (3 - Math.sqrt(5))\n\n for (let i = 0; i < numIcons; i++) {\n const y = i * offset - 1 + offset / 2\n const r = Math.sqrt(1 - y * y)\n const phi = i * increment\n\n const x = Math.cos(phi) * r\n const z = Math.sin(phi) * r\n\n newIcons.push({\n x: x * 100,\n y: y * 100,\n z: z * 100,\n scale: 1,\n opacity: 1,\n id: i,\n })\n }\n setIconPositions(newIcons)\n }, [icons, images])\n\n // Handle mouse events\n const handleMouseDown = (e: React.MouseEvent<HTMLCanvasElement>) => {\n const rect = canvasRef.current?.getBoundingClientRect()\n if (!rect || !canvasRef.current) return\n\n const x = e.clientX - rect.left\n const y = e.clientY - rect.top\n\n const ctx = canvasRef.current.getContext(\"2d\")\n if (!ctx) return\n\n iconPositions.forEach((icon) => {\n const cosX = Math.cos(rotationRef.current.x)\n const sinX = Math.sin(rotationRef.current.x)\n const cosY = Math.cos(rotationRef.current.y)\n const sinY = Math.sin(rotationRef.current.y)\n\n const rotatedX = icon.x * cosY - icon.z * sinY\n const rotatedZ = icon.x * sinY + icon.z * cosY\n const rotatedY = icon.y * cosX + rotatedZ * sinX\n\n const screenX = canvasRef.current!.width / 2 + rotatedX\n const screenY = canvasRef.current!.height / 2 + rotatedY\n\n const scale = (rotatedZ + 200) / 300\n const radius = 20 * scale\n const dx = x - screenX\n const dy = y - screenY\n\n if (dx * dx + dy * dy < radius * radius) {\n const targetX = -Math.atan2(\n icon.y,\n Math.sqrt(icon.x * icon.x + icon.z * icon.z)\n )\n const targetY = Math.atan2(icon.x, icon.z)\n\n const currentX = rotationRef.current.x\n const currentY = rotationRef.current.y\n const distance = Math.sqrt(\n Math.pow(targetX - currentX, 2) + Math.pow(targetY - currentY, 2)\n )\n\n const duration = Math.min(2000, Math.max(800, distance * 1000))\n\n setTargetRotation({\n x: targetX,\n y: targetY,\n startX: currentX,\n startY: currentY,\n distance,\n startTime: performance.now(),\n duration,\n })\n return\n }\n })\n\n setIsDragging(true)\n setLastMousePos({ x: e.clientX, y: e.clientY })\n }\n\n const handleMouseMove = (e: React.MouseEvent<HTMLCanvasElement>) => {\n const rect = canvasRef.current?.getBoundingClientRect()\n if (rect) {\n const x = e.clientX - rect.left\n const y = e.clientY - rect.top\n setMousePos({ x, y })\n }\n\n if (isDragging) {\n const deltaX = e.clientX - lastMousePos.x\n const deltaY = e.clientY - lastMousePos.y\n\n rotationRef.current = {\n x: rotationRef.current.x + deltaY * 0.002,\n y: rotationRef.current.y + deltaX * 0.002,\n }\n\n setLastMousePos({ x: e.clientX, y: e.clientY })\n }\n }\n\n const handleMouseUp = () => {\n setIsDragging(false)\n }\n\n // Animation and rendering\n useEffect(() => {\n const canvas = canvasRef.current\n const ctx = canvas?.getContext(\"2d\")\n if (canvas && ctx) {\n const animate = () => {\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n\n const centerX = canvas.width / 2\n const centerY = canvas.height / 2\n const maxDistance = Math.sqrt(centerX * centerX + centerY * centerY)\n const dx = mousePos.x - centerX\n const dy = mousePos.y - centerY\n const distance = Math.sqrt(dx * dx + dy * dy)\n const speed = 0.003 + (distance / maxDistance) * 0.01\n\n if (targetRotation) {\n const elapsed = performance.now() - targetRotation.startTime\n const progress = Math.min(1, elapsed / targetRotation.duration)\n const easedProgress = easeOutCubic(progress)\n\n rotationRef.current = {\n x:\n targetRotation.startX +\n (targetRotation.x - targetRotation.startX) * easedProgress,\n y:\n targetRotation.startY +\n (targetRotation.y - targetRotation.startY) * easedProgress,\n }\n\n if (progress >= 1) {\n setTargetRotation(null)\n }\n } else if (!isDragging) {\n rotationRef.current = {\n x: rotationRef.current.x + (dy / canvas.height) * speed,\n y: rotationRef.current.y + (dx / canvas.width) * speed,\n }\n }\n\n iconPositions.forEach((icon, index) => {\n const cosX = Math.cos(rotationRef.current.x)\n const sinX = Math.sin(rotationRef.current.x)\n const cosY = Math.cos(rotationRef.current.y)\n const sinY = Math.sin(rotationRef.current.y)\n\n const rotatedX = icon.x * cosY - icon.z * sinY\n const rotatedZ = icon.x * sinY + icon.z * cosY\n const rotatedY = icon.y * cosX + rotatedZ * sinX\n\n const scale = (rotatedZ + 200) / 300\n const opacity = Math.max(0.2, Math.min(1, (rotatedZ + 150) / 200))\n\n ctx.save()\n ctx.translate(\n canvas.width / 2 + rotatedX,\n canvas.height / 2 + rotatedY\n )\n ctx.scale(scale, scale)\n ctx.globalAlpha = opacity\n\n if (icons || images) {\n // Only try to render icons/images if they exist\n if (\n iconCanvasesRef.current[index] &&\n imagesLoadedRef.current[index]\n ) {\n ctx.drawImage(iconCanvasesRef.current[index], -20, -20, 40, 40)\n }\n } else {\n // Show numbered circles if no icons/images are provided\n ctx.beginPath()\n ctx.arc(0, 0, 20, 0, Math.PI * 2)\n ctx.fillStyle = \"#4444ff\"\n ctx.fill()\n ctx.fillStyle = \"white\"\n ctx.textAlign = \"center\"\n ctx.textBaseline = \"middle\"\n ctx.font = \"16px Arial\"\n ctx.fillText(`${icon.id + 1}`, 0, 0)\n }\n\n ctx.restore()\n })\n animationFrameRef.current = requestAnimationFrame(animate)\n }\n\n animate()\n }\n\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current)\n }\n }\n }, [icons, images, iconPositions, isDragging, mousePos, targetRotation])\n\n return (\n <canvas\n ref={canvasRef}\n width={400}\n height={400}\n onMouseDown={handleMouseDown}\n onMouseMove={handleMouseMove}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n className=\"rounded-lg\"\n aria-label=\"Interactive 3D Icon Cloud\"\n role=\"img\"\n />\n )\n}\n",
+ "content": "\"use client\"\n\nimport React, { useEffect, useRef, useState } from \"react\"\nimport { renderToString } from \"react-dom/server\"\n\ninterface Icon {\n x: number\n y: number\n z: number\n scale: number\n opacity: number\n id: number\n}\n\ninterface IconCloudProps {\n icons?: React.ReactNode[]\n images?: string[]\n}\n\nfunction easeOutCubic(t: number): number {\n return 1 - Math.pow(1 - t, 3)\n}\n\nexport function IconCloud({ icons, images }: IconCloudProps) {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const [iconPositions, setIconPositions] = useState<Icon[]>([])\n const [isDragging, setIsDragging] = useState(false)\n const [lastMousePos, setLastMousePos] = useState({ x: 0, y: 0 })\n const [mousePos, setMousePos] = useState({ x: 0, y: 0 })\n const [targetRotation, setTargetRotation] = useState<{\n x: number\n y: number\n startX: number\n startY: number\n distance: number\n startTime: number\n duration: number\n } | null>(null)\n const animationFrameRef = useRef<number>(0)\n const rotationRef = useRef({ x: 0, y: 0 })\n const iconCanvasesRef = useRef<HTMLCanvasElement[]>([])\n const imagesLoadedRef = useRef<boolean[]>([])\n\n // Create icon canvases once when icons/images change\n useEffect(() => {\n if (!icons && !images) return\n\n const items = icons ?? images ?? []\n imagesLoadedRef.current = new Array(items.length).fill(false)\n\n const newIconCanvases = items.map((item, index) => {\n const offscreen = document.createElement(\"canvas\")\n offscreen.width = 40\n offscreen.height = 40\n const offCtx = offscreen.getContext(\"2d\")\n\n if (offCtx) {\n if (images) {\n // Handle image URLs directly\n const img = new Image()\n img.crossOrigin = \"anonymous\"\n img.src = items[index] as string\n img.onload = () => {\n offCtx.clearRect(0, 0, offscreen.width, offscreen.height)\n\n // Create circular clipping path\n offCtx.beginPath()\n offCtx.arc(20, 20, 20, 0, Math.PI * 2)\n offCtx.closePath()\n offCtx.clip()\n\n // Draw the image\n offCtx.drawImage(img, 0, 0, 40, 40)\n\n imagesLoadedRef.current[index] = true\n }\n } else {\n // Handle SVG icons\n offCtx.scale(0.4, 0.4)\n const svgString = renderToString(item as React.ReactElement)\n const img = new Image()\n img.src = \"data:image/svg+xml;base64,\" + btoa(svgString)\n img.onload = () => {\n offCtx.clearRect(0, 0, offscreen.width, offscreen.height)\n offCtx.drawImage(img, 0, 0)\n imagesLoadedRef.current[index] = true\n }\n }\n }\n return offscreen\n })\n\n iconCanvasesRef.current = newIconCanvases\n }, [icons, images])\n\n // Generate initial icon positions on a sphere\n useEffect(() => {\n const items = icons ?? images ?? []\n const newIcons: Icon[] = []\n const numIcons = items.length || 20\n\n // Fibonacci sphere parameters\n const offset = 2 / numIcons\n const increment = Math.PI * (3 - Math.sqrt(5))\n\n for (let i = 0; i < numIcons; i++) {\n const y = i * offset - 1 + offset / 2\n const r = Math.sqrt(1 - y * y)\n const phi = i * increment\n\n const x = Math.cos(phi) * r\n const z = Math.sin(phi) * r\n\n newIcons.push({\n x: x * 100,\n y: y * 100,\n z: z * 100,\n scale: 1,\n opacity: 1,\n id: i,\n })\n }\n setIconPositions(newIcons)\n }, [icons, images])\n\n // Handle mouse events\n const handleMouseDown = (e: React.MouseEvent<HTMLCanvasElement>) => {\n const rect = canvasRef.current?.getBoundingClientRect()\n if (!rect || !canvasRef.current) return\n\n const x = e.clientX - rect.left\n const y = e.clientY - rect.top\n\n const ctx = canvasRef.current.getContext(\"2d\")\n if (!ctx) return\n\n iconPositions.forEach((icon) => {\n const cosX = Math.cos(rotationRef.current.x)\n const sinX = Math.sin(rotationRef.current.x)\n const cosY = Math.cos(rotationRef.current.y)\n const sinY = Math.sin(rotationRef.current.y)\n\n const rotatedX = icon.x * cosY - icon.z * sinY\n const rotatedZ = icon.x * sinY + icon.z * cosY\n const rotatedY = icon.y * cosX + rotatedZ * sinX\n\n const screenX = canvasRef.current!.width / 2 + rotatedX\n const screenY = canvasRef.current!.height / 2 + rotatedY\n\n const scale = (rotatedZ + 200) / 300\n const radius = 20 * scale\n const dx = x - screenX\n const dy = y - screenY\n\n if (dx * dx + dy * dy < radius * radius) {\n const targetX = -Math.atan2(\n icon.y,\n Math.sqrt(icon.x * icon.x + icon.z * icon.z)\n )\n const targetY = Math.atan2(icon.x, icon.z)\n\n const currentX = rotationRef.current.x\n const currentY = rotationRef.current.y\n const distance = Math.sqrt(\n Math.pow(targetX - currentX, 2) + Math.pow(targetY - currentY, 2)\n )\n\n const duration = Math.min(2000, Math.max(800, distance * 1000))\n\n setTargetRotation({\n x: targetX,\n y: targetY,\n startX: currentX,\n startY: currentY,\n distance,\n startTime: performance.now(),\n duration,\n })\n return\n }\n })\n\n setIsDragging(true)\n setLastMousePos({ x: e.clientX, y: e.clientY })\n }\n\n const handleMouseMove = (e: React.MouseEvent<HTMLCanvasElement>) => {\n const rect = canvasRef.current?.getBoundingClientRect()\n if (rect) {\n const x = e.clientX - rect.left\n const y = e.clientY - rect.top\n setMousePos({ x, y })\n }\n\n if (isDragging) {\n const deltaX = e.clientX - lastMousePos.x\n const deltaY = e.clientY - lastMousePos.y\n\n rotationRef.current = {\n x: rotationRef.current.x + deltaY * 0.002,\n y: rotationRef.current.y + deltaX * 0.002,\n }\n\n setLastMousePos({ x: e.clientX, y: e.clientY })\n }\n }\n\n const handleMouseUp = () => {\n setIsDragging(false)\n }\n\n // Animation and rendering\n useEffect(() => {\n const canvas = canvasRef.current\n const ctx = canvas?.getContext(\"2d\")\n if (canvas && ctx) {\n const animate = () => {\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n\n const centerX = canvas.width / 2\n const centerY = canvas.height / 2\n const maxDistance = Math.sqrt(centerX * centerX + centerY * centerY)\n const dx = mousePos.x - centerX\n const dy = mousePos.y - centerY\n const distance = Math.sqrt(dx * dx + dy * dy)\n const speed = 0.003 + (distance / maxDistance) * 0.01\n\n if (targetRotation) {\n const elapsed = performance.now() - targetRotation.startTime\n const progress = Math.min(1, elapsed / targetRotation.duration)\n const easedProgress = easeOutCubic(progress)\n\n rotationRef.current = {\n x:\n targetRotation.startX +\n (targetRotation.x - targetRotation.startX) * easedProgress,\n y:\n targetRotation.startY +\n (targetRotation.y - targetRotation.startY) * easedProgress,\n }\n\n if (progress >= 1) {\n setTargetRotation(null)\n }\n } else if (!isDragging) {\n rotationRef.current = {\n x: rotationRef.current.x + (dy / canvas.height) * speed,\n y: rotationRef.current.y + (dx / canvas.width) * speed,\n }\n }\n\n iconPositions.forEach((icon, index) => {\n const cosX = Math.cos(rotationRef.current.x)\n const sinX = Math.sin(rotationRef.current.x)\n const cosY = Math.cos(rotationRef.current.y)\n const sinY = Math.sin(rotationRef.current.y)\n\n const rotatedX = icon.x * cosY - icon.z * sinY\n const rotatedZ = icon.x * sinY + icon.z * cosY\n const rotatedY = icon.y * cosX + rotatedZ * sinX\n\n const scale = (rotatedZ + 200) / 300\n const opacity = Math.max(0.2, Math.min(1, (rotatedZ + 150) / 200))\n\n ctx.save()\n ctx.translate(\n canvas.width / 2 + rotatedX,\n canvas.height / 2 + rotatedY\n )\n ctx.scale(scale, scale)\n ctx.globalAlpha = opacity\n\n if (icons || images) {\n // Only try to render icons/images if they exist\n if (\n iconCanvasesRef.current[index] &&\n imagesLoadedRef.current[index]\n ) {\n ctx.drawImage(iconCanvasesRef.current[index], -20, -20, 40, 40)\n }\n } else {\n // Show numbered circles if no icons/images are provided\n ctx.beginPath()\n ctx.arc(0, 0, 20, 0, Math.PI * 2)\n ctx.fillStyle = \"#4444ff\"\n ctx.fill()\n ctx.fillStyle = \"white\"\n ctx.textAlign = \"center\"\n ctx.textBaseline = \"middle\"\n ctx.font = \"16px Arial\"\n ctx.fillText(`${icon.id + 1}`, 0, 0)\n }\n\n ctx.restore()\n })\n animationFrameRef.current = requestAnimationFrame(animate)\n }\n\n animate()\n }\n\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current)\n }\n }\n }, [icons, images, iconPositions, isDragging, mousePos, targetRotation])\n\n return (\n <canvas\n ref={canvasRef}\n width={400}\n height={400}\n onMouseDown={handleMouseDown}\n onMouseMove={handleMouseMove}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n className=\"rounded-lg\"\n aria-label=\"Interactive 3D Icon Cloud\"\n role=\"img\"\n />\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/lens-demo-2.json b/apps/www/public/r/lens-demo-2.json
index 5b16b1e2..6a56c262 100644
--- a/apps/www/public/r/lens-demo-2.json
+++ b/apps/www/public/r/lens-demo-2.json
@@ -12,7 +12,7 @@
"files": [
{
"path": "registry/example/lens-demo-2.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Lens } from \"@/registry/magicui/lens\"\n\nexport default function LensDemo() {\n return (\n <Card className=\"relative max-w-md shadow-none\">\n <CardHeader>\n <Lens isStatic position={{ x: 260, y: 150 }}>\n <img\n src=\"https://images.unsplash.com/photo-1736606355698-5efdb410fe93?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n alt=\"image placeholder\"\n width={500}\n height={500}\n />\n </Lens>\n </CardHeader>\n <CardContent>\n <CardTitle className=\"text-2xl\">Your next camp</CardTitle>\n <CardDescription>\n See our latest and best camp destinations all across the five\n continents of the globe.\n </CardDescription>\n </CardContent>\n <CardFooter className=\"space-x-4\">\n <Button>Let&apos;s go</Button>\n <Button variant=\"secondary\">Another time</Button>\n </CardFooter>\n </Card>\n )\n}\n",
+ "content": "import { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Lens } from \"@/registry/magicui/lens\"\n\nexport default function LensDemo() {\n return (\n <Card className=\"relative max-w-md shadow-none\">\n <CardHeader>\n <Lens isStatic position={{ x: 260, y: 150 }}>\n <img\n src=\"https://images.unsplash.com/photo-1736606355698-5efdb410fe93?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n alt=\"image placeholder\"\n width={500}\n height={500}\n />\n </Lens>\n </CardHeader>\n <CardContent>\n <CardTitle className=\"text-2xl\">Your next camp</CardTitle>\n <CardDescription>\n See our latest and best camp destinations all across the five\n continents of the globe.\n </CardDescription>\n </CardContent>\n <CardFooter className=\"space-x-4\">\n <Button>Let&apos;s go</Button>\n <Button variant=\"secondary\">Another time</Button>\n </CardFooter>\n </Card>\n )\n}\n",
"type": "registry:example"
}
]
diff --git a/apps/www/public/r/lens-demo-3.json b/apps/www/public/r/lens-demo-3.json
index b2619af2..6fef3caf 100644
--- a/apps/www/public/r/lens-demo-3.json
+++ b/apps/www/public/r/lens-demo-3.json
@@ -12,7 +12,7 @@
"files": [
{
"path": "registry/example/lens-demo-3.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Lens } from \"@/registry/magicui/lens\"\n\nexport default function LensDemo() {\n return (\n <Card className=\"relative max-w-md shadow-none\">\n <CardHeader>\n <Lens defaultPosition={{ x: 260, y: 150 }}>\n <img\n src=\"https://images.unsplash.com/photo-1736606355698-5efdb410fe93?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n alt=\"image placeholder\"\n width={500}\n height={500}\n />\n </Lens>\n </CardHeader>\n <CardContent>\n <CardTitle className=\"text-2xl\">Your next camp</CardTitle>\n <CardDescription>\n See our latest and best camp destinations all across the five\n continents of the globe.\n </CardDescription>\n </CardContent>\n <CardFooter className=\"space-x-4\">\n <Button>Let&apos;s go</Button>\n <Button variant=\"secondary\">Another time</Button>\n </CardFooter>\n </Card>\n )\n}\n",
+ "content": "import { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Lens } from \"@/registry/magicui/lens\"\n\nexport default function LensDemo() {\n return (\n <Card className=\"relative max-w-md shadow-none\">\n <CardHeader>\n <Lens defaultPosition={{ x: 260, y: 150 }}>\n <img\n src=\"https://images.unsplash.com/photo-1736606355698-5efdb410fe93?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n alt=\"image placeholder\"\n width={500}\n height={500}\n />\n </Lens>\n </CardHeader>\n <CardContent>\n <CardTitle className=\"text-2xl\">Your next camp</CardTitle>\n <CardDescription>\n See our latest and best camp destinations all across the five\n continents of the globe.\n </CardDescription>\n </CardContent>\n <CardFooter className=\"space-x-4\">\n <Button>Let&apos;s go</Button>\n <Button variant=\"secondary\">Another time</Button>\n </CardFooter>\n </Card>\n )\n}\n",
"type": "registry:example"
}
]
diff --git a/apps/www/public/r/lens-demo.json b/apps/www/public/r/lens-demo.json
index ecf96918..5e64e5c1 100644
--- a/apps/www/public/r/lens-demo.json
+++ b/apps/www/public/r/lens-demo.json
@@ -12,7 +12,7 @@
"files": [
{
"path": "registry/example/lens-demo.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\n\n\"use client\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Lens } from \"@/registry/magicui/lens\"\n\nexport default function LensDemo() {\n return (\n <Card className=\"relative max-w-md shadow-none\">\n <CardHeader>\n <Lens\n zoomFactor={2}\n lensSize={150}\n isStatic={false}\n ariaLabel=\"Zoom Area\"\n >\n <img\n src=\"https://images.unsplash.com/photo-1736606355698-5efdb410fe93?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n alt=\"image placeholder\"\n width={500}\n height={500}\n />\n </Lens>\n </CardHeader>\n <CardContent>\n <CardTitle className=\"text-2xl\">Your next camp</CardTitle>\n <CardDescription>\n See our latest and best camp destinations all across the five\n continents of the globe.\n </CardDescription>\n </CardContent>\n <CardFooter className=\"space-x-4\">\n <Button>Let&apos;s go</Button>\n <Button variant=\"secondary\">Another time</Button>\n </CardFooter>\n </Card>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\"\nimport { Lens } from \"@/registry/magicui/lens\"\n\nexport default function LensDemo() {\n return (\n <Card className=\"relative max-w-md shadow-none\">\n <CardHeader>\n <Lens\n zoomFactor={2}\n lensSize={150}\n isStatic={false}\n ariaLabel=\"Zoom Area\"\n >\n <img\n src=\"https://images.unsplash.com/photo-1736606355698-5efdb410fe93?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n alt=\"image placeholder\"\n width={500}\n height={500}\n />\n </Lens>\n </CardHeader>\n <CardContent>\n <CardTitle className=\"text-2xl\">Your next camp</CardTitle>\n <CardDescription>\n See our latest and best camp destinations all across the five\n continents of the globe.\n </CardDescription>\n </CardContent>\n <CardFooter className=\"space-x-4\">\n <Button>Let&apos;s go</Button>\n <Button variant=\"secondary\">Another time</Button>\n </CardFooter>\n </Card>\n )\n}\n",
"type": "registry:example"
}
]
diff --git a/apps/www/public/r/lens.json b/apps/www/public/r/lens.json
index 3f55ecd7..eb171dcd 100644
--- a/apps/www/public/r/lens.json
+++ b/apps/www/public/r/lens.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/lens.tsx",
- "content": "\"use client\"\n\nimport React, { useCallback, useMemo, useRef, useState } from \"react\"\nimport { AnimatePresence, motion, useMotionTemplate } from \"motion/react\"\n\ninterface Position {\n /** The x coordinate of the lens */\n x: number\n /** The y coordinate of the lens */\n y: number\n}\n\ninterface LensProps {\n /** The children of the lens */\n children: React.ReactNode\n /** The zoom factor of the lens */\n zoomFactor?: number\n /** The size of the lens */\n lensSize?: number\n /** The position of the lens */\n position?: Position\n /** The default position of the lens */\n defaultPosition?: Position\n /** Whether the lens is static */\n isStatic?: boolean\n /** The duration of the animation */\n duration?: number\n /** The color of the lens */\n lensColor?: string\n /** The aria label of the lens */\n ariaLabel?: string\n}\n\nexport function Lens({\n children,\n zoomFactor = 1.3,\n lensSize = 170,\n isStatic = false,\n position = { x: 0, y: 0 },\n defaultPosition,\n duration = 0.1,\n lensColor = \"black\",\n ariaLabel = \"Zoom Area\",\n}: LensProps) {\n if (zoomFactor < 1) {\n throw new Error(\"zoomFactor must be greater than 1\")\n }\n if (lensSize < 0) {\n throw new Error(\"lensSize must be greater than 0\")\n }\n\n const [isHovering, setIsHovering] = useState(false)\n const [mousePosition, setMousePosition] = useState<Position>(position)\n const containerRef = useRef<HTMLDivElement>(null)\n\n const currentPosition = useMemo(() => {\n if (isStatic) return position\n if (defaultPosition && !isHovering) return defaultPosition\n return mousePosition\n }, [isStatic, position, defaultPosition, isHovering, mousePosition])\n\n const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {\n const rect = e.currentTarget.getBoundingClientRect()\n setMousePosition({\n x: e.clientX - rect.left,\n y: e.clientY - rect.top,\n })\n }, [])\n\n const handleKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === \"Escape\") setIsHovering(false)\n }, [])\n\n const maskImage = useMotionTemplate`radial-gradient(circle ${\n lensSize / 2\n }px at ${currentPosition.x}px ${\n currentPosition.y\n }px, ${lensColor} 100%, transparent 100%)`\n\n const LensContent = useMemo(() => {\n const { x, y } = currentPosition\n\n return (\n <motion.div\n initial={{ opacity: 0, scale: 0.58 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.8 }}\n transition={{ duration }}\n className=\"absolute inset-0 overflow-hidden\"\n style={{\n maskImage,\n WebkitMaskImage: maskImage,\n transformOrigin: `${x}px ${y}px`,\n zIndex: 50,\n }}\n >\n <div\n className=\"absolute inset-0\"\n style={{\n transform: `scale(${zoomFactor})`,\n transformOrigin: `${x}px ${y}px`,\n }}\n >\n {children}\n </div>\n </motion.div>\n )\n }, [currentPosition, lensSize, lensColor, zoomFactor, children, duration])\n\n return (\n <div\n ref={containerRef}\n className=\"relative z-20 overflow-hidden rounded-xl\"\n onMouseEnter={() => setIsHovering(true)}\n onMouseLeave={() => setIsHovering(false)}\n onMouseMove={handleMouseMove}\n onKeyDown={handleKeyDown}\n role=\"region\"\n aria-label={ariaLabel}\n tabIndex={0}\n >\n {children}\n {isStatic || defaultPosition ? (\n LensContent\n ) : (\n <AnimatePresence mode=\"popLayout\">\n {isHovering && LensContent}\n </AnimatePresence>\n )}\n </div>\n )\n}\n",
+ "content": "\"use client\"\n\nimport React, { useCallback, useMemo, useRef, useState } from \"react\"\nimport { AnimatePresence, motion, useMotionTemplate } from \"motion/react\"\n\ninterface Position {\n /** The x coordinate of the lens */\n x: number\n /** The y coordinate of the lens */\n y: number\n}\n\ninterface LensProps {\n /** The children of the lens */\n children: React.ReactNode\n /** The zoom factor of the lens */\n zoomFactor?: number\n /** The size of the lens */\n lensSize?: number\n /** The position of the lens */\n position?: Position\n /** The default position of the lens */\n defaultPosition?: Position\n /** Whether the lens is static */\n isStatic?: boolean\n /** The duration of the animation */\n duration?: number\n /** The color of the lens */\n lensColor?: string\n /** The aria label of the lens */\n ariaLabel?: string\n}\n\nexport function Lens({\n children,\n zoomFactor = 1.3,\n lensSize = 170,\n isStatic = false,\n position = { x: 0, y: 0 },\n defaultPosition,\n duration = 0.1,\n lensColor = \"black\",\n ariaLabel = \"Zoom Area\",\n}: LensProps) {\n if (zoomFactor < 1) {\n throw new Error(\"zoomFactor must be greater than 1\")\n }\n if (lensSize < 0) {\n throw new Error(\"lensSize must be greater than 0\")\n }\n\n const [isHovering, setIsHovering] = useState(false)\n const [mousePosition, setMousePosition] = useState<Position>(position)\n const containerRef = useRef<HTMLDivElement>(null)\n\n const currentPosition = useMemo(() => {\n if (isStatic) return position\n if (defaultPosition && !isHovering) return defaultPosition\n return mousePosition\n }, [isStatic, position, defaultPosition, isHovering, mousePosition])\n\n const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {\n const rect = e.currentTarget.getBoundingClientRect()\n setMousePosition({\n x: e.clientX - rect.left,\n y: e.clientY - rect.top,\n })\n }, [])\n\n const handleKeyDown = useCallback((e: React.KeyboardEvent) => {\n if (e.key === \"Escape\") setIsHovering(false)\n }, [])\n\n const maskImage = useMotionTemplate`radial-gradient(circle ${\n lensSize / 2\n }px at ${currentPosition.x}px ${\n currentPosition.y\n }px, ${lensColor} 100%, transparent 100%)`\n\n const LensContent = useMemo(() => {\n const { x, y } = currentPosition\n\n return (\n <motion.div\n initial={{ opacity: 0, scale: 0.58 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.8 }}\n transition={{ duration }}\n className=\"absolute inset-0 overflow-hidden\"\n style={{\n maskImage,\n WebkitMaskImage: maskImage,\n transformOrigin: `${x}px ${y}px`,\n zIndex: 50,\n }}\n >\n <div\n className=\"absolute inset-0\"\n style={{\n transform: `scale(${zoomFactor})`,\n transformOrigin: `${x}px ${y}px`,\n }}\n >\n {children}\n </div>\n </motion.div>\n )\n }, [currentPosition, maskImage, zoomFactor, children, duration])\n\n return (\n <div\n ref={containerRef}\n className=\"relative z-20 overflow-hidden rounded-xl\"\n onMouseEnter={() => setIsHovering(true)}\n onMouseLeave={() => setIsHovering(false)}\n onMouseMove={handleMouseMove}\n onKeyDown={handleKeyDown}\n role=\"region\"\n aria-label={ariaLabel}\n tabIndex={0}\n >\n {children}\n {isStatic || defaultPosition ? (\n LensContent\n ) : (\n <AnimatePresence mode=\"popLayout\">\n {isHovering && LensContent}\n </AnimatePresence>\n )}\n </div>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/marquee-3d.json b/apps/www/public/r/marquee-3d.json
index df49ad5b..cefd273b 100644
--- a/apps/www/public/r/marquee-3d.json
+++ b/apps/www/public/r/marquee-3d.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/example/marquee-3d.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\nimport { cn } from \"@/lib/utils\"\nimport { Marquee } from \"@/registry/magicui/marquee\"\n\nconst reviews = [\n {\n name: \"Jack\",\n username: \"@jack\",\n body: \"I've never seen anything like this before. It's amazing. I love it.\",\n img: \"https://avatar.vercel.sh/jack\",\n },\n {\n name: \"Jill\",\n username: \"@jill\",\n body: \"I don't know what to say. I'm speechless. This is amazing.\",\n img: \"https://avatar.vercel.sh/jill\",\n },\n {\n name: \"John\",\n username: \"@john\",\n body: \"I'm at a loss for words. This is amazing. I love it.\",\n img: \"https://avatar.vercel.sh/john\",\n },\n]\n\nconst firstRow = reviews.slice(0, reviews.length / 2)\nconst secondRow = reviews.slice(reviews.length / 2)\nconst thirdRow = reviews.slice(0, reviews.length / 2)\nconst fourthRow = reviews.slice(reviews.length / 2)\n\nconst ReviewCard = ({\n img,\n name,\n username,\n body,\n}: {\n img: string\n name: string\n username: string\n body: string\n}) => {\n return (\n <figure\n className={cn(\n \"relative h-full w-fit cursor-pointer overflow-hidden rounded-xl border p-4 sm:w-36\",\n // light styles\n \"border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05]\",\n // dark styles\n \"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]\"\n )}\n >\n <div className=\"flex flex-row items-center gap-2\">\n <img className=\"rounded-full\" width=\"32\" height=\"32\" alt=\"\" src={img} />\n <div className=\"flex flex-col\">\n <figcaption className=\"text-sm font-medium dark:text-white\">\n {name}\n </figcaption>\n <p className=\"text-xs font-medium dark:text-white/40\">{username}</p>\n </div>\n </div>\n <blockquote className=\"mt-2 text-sm\">{body}</blockquote>\n </figure>\n )\n}\n\nexport default function Marquee3D() {\n return (\n <div className=\"relative flex h-96 w-full flex-row items-center justify-center gap-4 overflow-hidden [perspective:300px]\">\n <div\n className=\"flex flex-row items-center gap-4\"\n style={{\n transform:\n \"translateX(-100px) translateY(0px) translateZ(-100px) rotateX(20deg) rotateY(-10deg) rotateZ(20deg)\",\n }}\n >\n <Marquee pauseOnHover vertical className=\"[--duration:20s]\">\n {firstRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee reverse pauseOnHover className=\"[--duration:20s]\" vertical>\n {secondRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee reverse pauseOnHover className=\"[--duration:20s]\" vertical>\n {thirdRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee pauseOnHover className=\"[--duration:20s]\" vertical>\n {fourthRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n </div>\n\n <div className=\"from-background pointer-events-none absolute inset-x-0 top-0 h-1/4 bg-gradient-to-b\"></div>\n <div className=\"from-background pointer-events-none absolute inset-x-0 bottom-0 h-1/4 bg-gradient-to-t\"></div>\n <div className=\"from-background pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-gradient-to-r\"></div>\n <div className=\"from-background pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-gradient-to-l\"></div>\n </div>\n )\n}\n",
+ "content": "import { cn } from \"@/lib/utils\"\nimport { Marquee } from \"@/registry/magicui/marquee\"\n\nconst reviews = [\n {\n name: \"Jack\",\n username: \"@jack\",\n body: \"I've never seen anything like this before. It's amazing. I love it.\",\n img: \"https://avatar.vercel.sh/jack\",\n },\n {\n name: \"Jill\",\n username: \"@jill\",\n body: \"I don't know what to say. I'm speechless. This is amazing.\",\n img: \"https://avatar.vercel.sh/jill\",\n },\n {\n name: \"John\",\n username: \"@john\",\n body: \"I'm at a loss for words. This is amazing. I love it.\",\n img: \"https://avatar.vercel.sh/john\",\n },\n]\n\nconst firstRow = reviews.slice(0, reviews.length / 2)\nconst secondRow = reviews.slice(reviews.length / 2)\nconst thirdRow = reviews.slice(0, reviews.length / 2)\nconst fourthRow = reviews.slice(reviews.length / 2)\n\nconst ReviewCard = ({\n img,\n name,\n username,\n body,\n}: {\n img: string\n name: string\n username: string\n body: string\n}) => {\n return (\n <figure\n className={cn(\n \"relative h-full w-fit cursor-pointer overflow-hidden rounded-xl border p-4 sm:w-36\",\n // light styles\n \"border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05]\",\n // dark styles\n \"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]\"\n )}\n >\n <div className=\"flex flex-row items-center gap-2\">\n <img className=\"rounded-full\" width=\"32\" height=\"32\" alt=\"\" src={img} />\n <div className=\"flex flex-col\">\n <figcaption className=\"text-sm font-medium dark:text-white\">\n {name}\n </figcaption>\n <p className=\"text-xs font-medium dark:text-white/40\">{username}</p>\n </div>\n </div>\n <blockquote className=\"mt-2 text-sm\">{body}</blockquote>\n </figure>\n )\n}\n\nexport default function Marquee3D() {\n return (\n <div className=\"relative flex h-96 w-full flex-row items-center justify-center gap-4 overflow-hidden [perspective:300px]\">\n <div\n className=\"flex flex-row items-center gap-4\"\n style={{\n transform:\n \"translateX(-100px) translateY(0px) translateZ(-100px) rotateX(20deg) rotateY(-10deg) rotateZ(20deg)\",\n }}\n >\n <Marquee pauseOnHover vertical className=\"[--duration:20s]\">\n {firstRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee reverse pauseOnHover className=\"[--duration:20s]\" vertical>\n {secondRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee reverse pauseOnHover className=\"[--duration:20s]\" vertical>\n {thirdRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee pauseOnHover className=\"[--duration:20s]\" vertical>\n {fourthRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n </div>\n\n <div className=\"from-background pointer-events-none absolute inset-x-0 top-0 h-1/4 bg-gradient-to-b\"></div>\n <div className=\"from-background pointer-events-none absolute inset-x-0 bottom-0 h-1/4 bg-gradient-to-t\"></div>\n <div className=\"from-background pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-gradient-to-r\"></div>\n <div className=\"from-background pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-gradient-to-l\"></div>\n </div>\n )\n}\n",
"type": "registry:example"
}
]
diff --git a/apps/www/public/r/marquee-demo-vertical.json b/apps/www/public/r/marquee-demo-vertical.json
index 888680dc..07636ab0 100644
--- a/apps/www/public/r/marquee-demo-vertical.json
+++ b/apps/www/public/r/marquee-demo-vertical.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/example/marquee-demo-vertical.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\nimport { cn } from \"@/lib/utils\"\nimport { Marquee } from \"@/registry/magicui/marquee\"\n\nconst reviews = [\n {\n name: \"Jack\",\n username: \"@jack\",\n body: \"I've never seen anything like this before. It's amazing. I love it.\",\n img: \"https://avatar.vercel.sh/jack\",\n },\n {\n name: \"Jill\",\n username: \"@jill\",\n body: \"I don't know what to say. I'm speechless. This is amazing.\",\n img: \"https://avatar.vercel.sh/jill\",\n },\n {\n name: \"John\",\n username: \"@john\",\n body: \"I'm at a loss for words. This is amazing. I love it.\",\n img: \"https://avatar.vercel.sh/john\",\n },\n]\n\nconst firstRow = reviews.slice(0, reviews.length / 2)\nconst secondRow = reviews.slice(reviews.length / 2)\n\nconst ReviewCard = ({\n img,\n name,\n username,\n body,\n}: {\n img: string\n name: string\n username: string\n body: string\n}) => {\n return (\n <figure\n className={cn(\n \"relative h-full w-fit cursor-pointer overflow-hidden rounded-xl border p-4 sm:w-36\",\n // light styles\n \"border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05]\",\n // dark styles\n \"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]\"\n )}\n >\n <div className=\"flex flex-row items-center gap-2\">\n <img className=\"rounded-full\" width=\"32\" height=\"32\" alt=\"\" src={img} />\n <div className=\"flex flex-col\">\n <figcaption className=\"text-sm font-medium dark:text-white\">\n {name}\n </figcaption>\n <p className=\"text-xs font-medium dark:text-white/40\">{username}</p>\n </div>\n </div>\n <blockquote className=\"mt-2 text-sm\">{body}</blockquote>\n </figure>\n )\n}\n\nexport default function MarqueeDemoVertical() {\n return (\n <div className=\"relative flex h-[500px] w-full flex-row items-center justify-center overflow-hidden\">\n <Marquee pauseOnHover vertical className=\"[--duration:20s]\">\n {firstRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee reverse pauseOnHover vertical className=\"[--duration:20s]\">\n {secondRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <div className=\"from-background pointer-events-none absolute inset-x-0 top-0 h-1/4 bg-gradient-to-b\"></div>\n <div className=\"from-background pointer-events-none absolute inset-x-0 bottom-0 h-1/4 bg-gradient-to-t\"></div>\n </div>\n )\n}\n",
+ "content": "import { cn } from \"@/lib/utils\"\nimport { Marquee } from \"@/registry/magicui/marquee\"\n\nconst reviews = [\n {\n name: \"Jack\",\n username: \"@jack\",\n body: \"I've never seen anything like this before. It's amazing. I love it.\",\n img: \"https://avatar.vercel.sh/jack\",\n },\n {\n name: \"Jill\",\n username: \"@jill\",\n body: \"I don't know what to say. I'm speechless. This is amazing.\",\n img: \"https://avatar.vercel.sh/jill\",\n },\n {\n name: \"John\",\n username: \"@john\",\n body: \"I'm at a loss for words. This is amazing. I love it.\",\n img: \"https://avatar.vercel.sh/john\",\n },\n]\n\nconst firstRow = reviews.slice(0, reviews.length / 2)\nconst secondRow = reviews.slice(reviews.length / 2)\n\nconst ReviewCard = ({\n img,\n name,\n username,\n body,\n}: {\n img: string\n name: string\n username: string\n body: string\n}) => {\n return (\n <figure\n className={cn(\n \"relative h-full w-fit cursor-pointer overflow-hidden rounded-xl border p-4 sm:w-36\",\n // light styles\n \"border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05]\",\n // dark styles\n \"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]\"\n )}\n >\n <div className=\"flex flex-row items-center gap-2\">\n <img className=\"rounded-full\" width=\"32\" height=\"32\" alt=\"\" src={img} />\n <div className=\"flex flex-col\">\n <figcaption className=\"text-sm font-medium dark:text-white\">\n {name}\n </figcaption>\n <p className=\"text-xs font-medium dark:text-white/40\">{username}</p>\n </div>\n </div>\n <blockquote className=\"mt-2 text-sm\">{body}</blockquote>\n </figure>\n )\n}\n\nexport default function MarqueeDemoVertical() {\n return (\n <div className=\"relative flex h-[500px] w-full flex-row items-center justify-center overflow-hidden\">\n <Marquee pauseOnHover vertical className=\"[--duration:20s]\">\n {firstRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <Marquee reverse pauseOnHover vertical className=\"[--duration:20s]\">\n {secondRow.map((review) => (\n <ReviewCard key={review.username} {...review} />\n ))}\n </Marquee>\n <div className=\"from-background pointer-events-none absolute inset-x-0 top-0 h-1/4 bg-gradient-to-b\"></div>\n <div className=\"from-background pointer-events-none absolute inset-x-0 bottom-0 h-1/4 bg-gradient-to-t\"></div>\n </div>\n )\n}\n",
"type": "registry:example"
}
]
diff --git a/apps/www/public/r/particles.json b/apps/www/public/r/particles.json
index 0450f0c3..467e0190 100644
--- a/apps/www/public/r/particles.json
+++ b/apps/www/public/r/particles.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/particles.tsx",
- "content": "\"use client\"\n\nimport React, {\n useEffect,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n} from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface MousePosition {\n x: number\n y: number\n}\n\nfunction MousePosition(): MousePosition {\n const [mousePosition, setMousePosition] = useState<MousePosition>({\n x: 0,\n y: 0,\n })\n\n useEffect(() => {\n const handleMouseMove = (event: MouseEvent) => {\n setMousePosition({ x: event.clientX, y: event.clientY })\n }\n\n window.addEventListener(\"mousemove\", handleMouseMove)\n\n return () => {\n window.removeEventListener(\"mousemove\", handleMouseMove)\n }\n }, [])\n\n return mousePosition\n}\n\ninterface ParticlesProps extends ComponentPropsWithoutRef<\"div\"> {\n className?: string\n quantity?: number\n staticity?: number\n ease?: number\n size?: number\n refresh?: boolean\n color?: string\n vx?: number\n vy?: number\n}\n\nfunction hexToRgb(hex: string): number[] {\n hex = hex.replace(\"#\", \"\")\n\n if (hex.length === 3) {\n hex = hex\n .split(\"\")\n .map((char) => char + char)\n .join(\"\")\n }\n\n const hexInt = parseInt(hex, 16)\n const red = (hexInt >> 16) & 255\n const green = (hexInt >> 8) & 255\n const blue = hexInt & 255\n return [red, green, blue]\n}\n\ntype Circle = {\n x: number\n y: number\n translateX: number\n translateY: number\n size: number\n alpha: number\n targetAlpha: number\n dx: number\n dy: number\n magnetism: number\n}\n\nexport const Particles: React.FC<ParticlesProps> = ({\n className = \"\",\n quantity = 100,\n staticity = 50,\n ease = 50,\n size = 0.4,\n refresh = false,\n color = \"#ffffff\",\n vx = 0,\n vy = 0,\n ...props\n}) => {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const canvasContainerRef = useRef<HTMLDivElement>(null)\n const context = useRef<CanvasRenderingContext2D | null>(null)\n const circles = useRef<Circle[]>([])\n const mousePosition = MousePosition()\n const mouse = useRef<{ x: number; y: number }>({ x: 0, y: 0 })\n const canvasSize = useRef<{ w: number; h: number }>({ w: 0, h: 0 })\n const dpr = typeof window !== \"undefined\" ? window.devicePixelRatio : 1\n const rafID = useRef<number | null>(null)\n const resizeTimeout = useRef<NodeJS.Timeout | null>(null)\n\n useEffect(() => {\n if (canvasRef.current) {\n context.current = canvasRef.current.getContext(\"2d\")\n }\n initCanvas()\n animate()\n\n const handleResize = () => {\n if (resizeTimeout.current) {\n clearTimeout(resizeTimeout.current)\n }\n resizeTimeout.current = setTimeout(() => {\n initCanvas()\n }, 200)\n }\n\n window.addEventListener(\"resize\", handleResize)\n\n return () => {\n if (rafID.current != null) {\n window.cancelAnimationFrame(rafID.current)\n }\n if (resizeTimeout.current) {\n clearTimeout(resizeTimeout.current)\n }\n window.removeEventListener(\"resize\", handleResize)\n }\n }, [color])\n\n useEffect(() => {\n onMouseMove()\n }, [mousePosition.x, mousePosition.y])\n\n useEffect(() => {\n initCanvas()\n }, [refresh])\n\n const initCanvas = () => {\n resizeCanvas()\n drawParticles()\n }\n\n const onMouseMove = () => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect()\n const { w, h } = canvasSize.current\n const x = mousePosition.x - rect.left - w / 2\n const y = mousePosition.y - rect.top - h / 2\n const inside = x < w / 2 && x > -w / 2 && y < h / 2 && y > -h / 2\n if (inside) {\n mouse.current.x = x\n mouse.current.y = y\n }\n }\n }\n\n const resizeCanvas = () => {\n if (canvasContainerRef.current && canvasRef.current && context.current) {\n canvasSize.current.w = canvasContainerRef.current.offsetWidth\n canvasSize.current.h = canvasContainerRef.current.offsetHeight\n\n canvasRef.current.width = canvasSize.current.w * dpr\n canvasRef.current.height = canvasSize.current.h * dpr\n canvasRef.current.style.width = `${canvasSize.current.w}px`\n canvasRef.current.style.height = `${canvasSize.current.h}px`\n context.current.scale(dpr, dpr)\n\n // Clear existing particles and create new ones with exact quantity\n circles.current = []\n for (let i = 0; i < quantity; i++) {\n const circle = circleParams()\n drawCircle(circle)\n }\n }\n }\n\n const circleParams = (): Circle => {\n const x = Math.floor(Math.random() * canvasSize.current.w)\n const y = Math.floor(Math.random() * canvasSize.current.h)\n const translateX = 0\n const translateY = 0\n const pSize = Math.floor(Math.random() * 2) + size\n const alpha = 0\n const targetAlpha = parseFloat((Math.random() * 0.6 + 0.1).toFixed(1))\n const dx = (Math.random() - 0.5) * 0.1\n const dy = (Math.random() - 0.5) * 0.1\n const magnetism = 0.1 + Math.random() * 4\n return {\n x,\n y,\n translateX,\n translateY,\n size: pSize,\n alpha,\n targetAlpha,\n dx,\n dy,\n magnetism,\n }\n }\n\n const rgb = hexToRgb(color)\n\n const drawCircle = (circle: Circle, update = false) => {\n if (context.current) {\n const { x, y, translateX, translateY, size, alpha } = circle\n context.current.translate(translateX, translateY)\n context.current.beginPath()\n context.current.arc(x, y, size, 0, 2 * Math.PI)\n context.current.fillStyle = `rgba(${rgb.join(\", \")}, ${alpha})`\n context.current.fill()\n context.current.setTransform(dpr, 0, 0, dpr, 0, 0)\n\n if (!update) {\n circles.current.push(circle)\n }\n }\n }\n\n const clearContext = () => {\n if (context.current) {\n context.current.clearRect(\n 0,\n 0,\n canvasSize.current.w,\n canvasSize.current.h\n )\n }\n }\n\n const drawParticles = () => {\n clearContext()\n const particleCount = quantity\n for (let i = 0; i < particleCount; i++) {\n const circle = circleParams()\n drawCircle(circle)\n }\n }\n\n const remapValue = (\n value: number,\n start1: number,\n end1: number,\n start2: number,\n end2: number\n ): number => {\n const remapped =\n ((value - start1) * (end2 - start2)) / (end1 - start1) + start2\n return remapped > 0 ? remapped : 0\n }\n\n const animate = () => {\n clearContext()\n circles.current.forEach((circle: Circle, i: number) => {\n // Handle the alpha value\n const edge = [\n circle.x + circle.translateX - circle.size, // distance from left edge\n canvasSize.current.w - circle.x - circle.translateX - circle.size, // distance from right edge\n circle.y + circle.translateY - circle.size, // distance from top edge\n canvasSize.current.h - circle.y - circle.translateY - circle.size, // distance from bottom edge\n ]\n const closestEdge = edge.reduce((a, b) => Math.min(a, b))\n const remapClosestEdge = parseFloat(\n remapValue(closestEdge, 0, 20, 0, 1).toFixed(2)\n )\n if (remapClosestEdge > 1) {\n circle.alpha += 0.02\n if (circle.alpha > circle.targetAlpha) {\n circle.alpha = circle.targetAlpha\n }\n } else {\n circle.alpha = circle.targetAlpha * remapClosestEdge\n }\n circle.x += circle.dx + vx\n circle.y += circle.dy + vy\n circle.translateX +=\n (mouse.current.x / (staticity / circle.magnetism) - circle.translateX) /\n ease\n circle.translateY +=\n (mouse.current.y / (staticity / circle.magnetism) - circle.translateY) /\n ease\n\n drawCircle(circle, true)\n\n // circle gets out of the canvas\n if (\n circle.x < -circle.size ||\n circle.x > canvasSize.current.w + circle.size ||\n circle.y < -circle.size ||\n circle.y > canvasSize.current.h + circle.size\n ) {\n // remove the circle from the array\n circles.current.splice(i, 1)\n // create a new circle\n const newCircle = circleParams()\n drawCircle(newCircle)\n }\n })\n rafID.current = window.requestAnimationFrame(animate)\n }\n\n return (\n <div\n className={cn(\"pointer-events-none\", className)}\n ref={canvasContainerRef}\n aria-hidden=\"true\"\n {...props}\n >\n <canvas ref={canvasRef} className=\"size-full\" />\n </div>\n )\n}\n",
+ "content": "\"use client\"\n\nimport React, {\n useEffect,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n} from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface MousePosition {\n x: number\n y: number\n}\n\nfunction MousePosition(): MousePosition {\n const [mousePosition, setMousePosition] = useState<MousePosition>({\n x: 0,\n y: 0,\n })\n\n useEffect(() => {\n const handleMouseMove = (event: MouseEvent) => {\n setMousePosition({ x: event.clientX, y: event.clientY })\n }\n\n window.addEventListener(\"mousemove\", handleMouseMove)\n\n return () => {\n window.removeEventListener(\"mousemove\", handleMouseMove)\n }\n }, [])\n\n return mousePosition\n}\n\ninterface ParticlesProps extends ComponentPropsWithoutRef<\"div\"> {\n className?: string\n quantity?: number\n staticity?: number\n ease?: number\n size?: number\n refresh?: boolean\n color?: string\n vx?: number\n vy?: number\n}\n\nfunction hexToRgb(hex: string): number[] {\n hex = hex.replace(\"#\", \"\")\n\n if (hex.length === 3) {\n hex = hex\n .split(\"\")\n .map((char) => char + char)\n .join(\"\")\n }\n\n const hexInt = parseInt(hex, 16)\n const red = (hexInt >> 16) & 255\n const green = (hexInt >> 8) & 255\n const blue = hexInt & 255\n return [red, green, blue]\n}\n\ntype Circle = {\n x: number\n y: number\n translateX: number\n translateY: number\n size: number\n alpha: number\n targetAlpha: number\n dx: number\n dy: number\n magnetism: number\n}\n\nexport const Particles: React.FC<ParticlesProps> = ({\n className = \"\",\n quantity = 100,\n staticity = 50,\n ease = 50,\n size = 0.4,\n refresh = false,\n color = \"#ffffff\",\n vx = 0,\n vy = 0,\n ...props\n}) => {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const canvasContainerRef = useRef<HTMLDivElement>(null)\n const context = useRef<CanvasRenderingContext2D | null>(null)\n const circles = useRef<Circle[]>([])\n const mousePosition = MousePosition()\n const mouse = useRef<{ x: number; y: number }>({ x: 0, y: 0 })\n const canvasSize = useRef<{ w: number; h: number }>({ w: 0, h: 0 })\n const dpr = typeof window !== \"undefined\" ? window.devicePixelRatio : 1\n const rafID = useRef<number | null>(null)\n const resizeTimeout = useRef<NodeJS.Timeout | null>(null)\n const initCanvasRef = useRef<() => void>(() => {})\n const onMouseMoveRef = useRef<() => void>(() => {})\n const animateRef = useRef<() => void>(() => {})\n\n useEffect(() => {\n if (canvasRef.current) {\n context.current = canvasRef.current.getContext(\"2d\")\n }\n initCanvasRef.current()\n animateRef.current()\n\n const handleResize = () => {\n if (resizeTimeout.current) {\n clearTimeout(resizeTimeout.current)\n }\n resizeTimeout.current = setTimeout(() => {\n initCanvasRef.current()\n }, 200)\n }\n\n window.addEventListener(\"resize\", handleResize)\n\n return () => {\n if (rafID.current != null) {\n window.cancelAnimationFrame(rafID.current)\n }\n if (resizeTimeout.current) {\n clearTimeout(resizeTimeout.current)\n }\n window.removeEventListener(\"resize\", handleResize)\n }\n }, [color])\n\n useEffect(() => {\n onMouseMoveRef.current()\n }, [mousePosition.x, mousePosition.y])\n\n useEffect(() => {\n initCanvasRef.current()\n }, [refresh])\n\n const initCanvas = () => {\n resizeCanvas()\n drawParticles()\n }\n\n const onMouseMove = () => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect()\n const { w, h } = canvasSize.current\n const x = mousePosition.x - rect.left - w / 2\n const y = mousePosition.y - rect.top - h / 2\n const inside = x < w / 2 && x > -w / 2 && y < h / 2 && y > -h / 2\n if (inside) {\n mouse.current.x = x\n mouse.current.y = y\n }\n }\n }\n\n const resizeCanvas = () => {\n if (canvasContainerRef.current && canvasRef.current && context.current) {\n canvasSize.current.w = canvasContainerRef.current.offsetWidth\n canvasSize.current.h = canvasContainerRef.current.offsetHeight\n\n canvasRef.current.width = canvasSize.current.w * dpr\n canvasRef.current.height = canvasSize.current.h * dpr\n canvasRef.current.style.width = `${canvasSize.current.w}px`\n canvasRef.current.style.height = `${canvasSize.current.h}px`\n context.current.scale(dpr, dpr)\n\n // Clear existing particles and create new ones with exact quantity\n circles.current = []\n for (let i = 0; i < quantity; i++) {\n const circle = circleParams()\n drawCircle(circle)\n }\n }\n }\n\n const circleParams = (): Circle => {\n const x = Math.floor(Math.random() * canvasSize.current.w)\n const y = Math.floor(Math.random() * canvasSize.current.h)\n const translateX = 0\n const translateY = 0\n const pSize = Math.floor(Math.random() * 2) + size\n const alpha = 0\n const targetAlpha = parseFloat((Math.random() * 0.6 + 0.1).toFixed(1))\n const dx = (Math.random() - 0.5) * 0.1\n const dy = (Math.random() - 0.5) * 0.1\n const magnetism = 0.1 + Math.random() * 4\n return {\n x,\n y,\n translateX,\n translateY,\n size: pSize,\n alpha,\n targetAlpha,\n dx,\n dy,\n magnetism,\n }\n }\n\n const rgb = hexToRgb(color)\n\n const drawCircle = (circle: Circle, update = false) => {\n if (context.current) {\n const { x, y, translateX, translateY, size, alpha } = circle\n context.current.translate(translateX, translateY)\n context.current.beginPath()\n context.current.arc(x, y, size, 0, 2 * Math.PI)\n context.current.fillStyle = `rgba(${rgb.join(\", \")}, ${alpha})`\n context.current.fill()\n context.current.setTransform(dpr, 0, 0, dpr, 0, 0)\n\n if (!update) {\n circles.current.push(circle)\n }\n }\n }\n\n const clearContext = () => {\n if (context.current) {\n context.current.clearRect(\n 0,\n 0,\n canvasSize.current.w,\n canvasSize.current.h\n )\n }\n }\n\n const drawParticles = () => {\n clearContext()\n const particleCount = quantity\n for (let i = 0; i < particleCount; i++) {\n const circle = circleParams()\n drawCircle(circle)\n }\n }\n\n const remapValue = (\n value: number,\n start1: number,\n end1: number,\n start2: number,\n end2: number\n ): number => {\n const remapped =\n ((value - start1) * (end2 - start2)) / (end1 - start1) + start2\n return remapped > 0 ? remapped : 0\n }\n\n const animate = () => {\n clearContext()\n circles.current.forEach((circle: Circle, i: number) => {\n // Handle the alpha value\n const edge = [\n circle.x + circle.translateX - circle.size, // distance from left edge\n canvasSize.current.w - circle.x - circle.translateX - circle.size, // distance from right edge\n circle.y + circle.translateY - circle.size, // distance from top edge\n canvasSize.current.h - circle.y - circle.translateY - circle.size, // distance from bottom edge\n ]\n const closestEdge = edge.reduce((a, b) => Math.min(a, b))\n const remapClosestEdge = parseFloat(\n remapValue(closestEdge, 0, 20, 0, 1).toFixed(2)\n )\n if (remapClosestEdge > 1) {\n circle.alpha += 0.02\n if (circle.alpha > circle.targetAlpha) {\n circle.alpha = circle.targetAlpha\n }\n } else {\n circle.alpha = circle.targetAlpha * remapClosestEdge\n }\n circle.x += circle.dx + vx\n circle.y += circle.dy + vy\n circle.translateX +=\n (mouse.current.x / (staticity / circle.magnetism) - circle.translateX) /\n ease\n circle.translateY +=\n (mouse.current.y / (staticity / circle.magnetism) - circle.translateY) /\n ease\n\n drawCircle(circle, true)\n\n // circle gets out of the canvas\n if (\n circle.x < -circle.size ||\n circle.x > canvasSize.current.w + circle.size ||\n circle.y < -circle.size ||\n circle.y > canvasSize.current.h + circle.size\n ) {\n // remove the circle from the array\n circles.current.splice(i, 1)\n // create a new circle\n const newCircle = circleParams()\n drawCircle(newCircle)\n }\n })\n rafID.current = window.requestAnimationFrame(animateRef.current)\n }\n\n initCanvasRef.current = initCanvas\n onMouseMoveRef.current = onMouseMove\n animateRef.current = animate\n\n return (\n <div\n className={cn(\"pointer-events-none\", className)}\n ref={canvasContainerRef}\n aria-hidden=\"true\"\n {...props}\n >\n <canvas ref={canvasRef} className=\"size-full\" />\n </div>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/smooth-cursor.json b/apps/www/public/r/smooth-cursor.json
index 160a6ba8..0ed6eeb7 100644
--- a/apps/www/public/r/smooth-cursor.json
+++ b/apps/www/public/r/smooth-cursor.json
@@ -9,7 +9,7 @@
"files": [
{
"path": "registry/magicui/smooth-cursor.tsx",
- "content": "\"use client\"\n\nimport { FC, useEffect, useRef, useState } from \"react\"\nimport { motion, useSpring } from \"motion/react\"\n\ninterface Position {\n x: number\n y: number\n}\n\nexport interface SmoothCursorProps {\n cursor?: React.ReactNode\n springConfig?: {\n damping: number\n stiffness: number\n mass: number\n restDelta: number\n }\n}\n\nconst DefaultCursorSVG: FC = () => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={50}\n height={54}\n viewBox=\"0 0 50 54\"\n fill=\"none\"\n style={{ scale: 0.5 }}\n >\n <g filter=\"url(#filter0_d_91_7928)\">\n <path\n d=\"M42.6817 41.1495L27.5103 6.79925C26.7269 5.02557 24.2082 5.02558 23.3927 6.79925L7.59814 41.1495C6.75833 42.9759 8.52712 44.8902 10.4125 44.1954L24.3757 39.0496C24.8829 38.8627 25.4385 38.8627 25.9422 39.0496L39.8121 44.1954C41.6849 44.8902 43.4884 42.9759 42.6817 41.1495Z\"\n fill=\"black\"\n />\n <path\n d=\"M43.7146 40.6933L28.5431 6.34306C27.3556 3.65428 23.5772 3.69516 22.3668 6.32755L6.57226 40.6778C5.3134 43.4156 7.97238 46.298 10.803 45.2549L24.7662 40.109C25.0221 40.0147 25.2999 40.0156 25.5494 40.1082L39.4193 45.254C42.2261 46.2953 44.9254 43.4347 43.7146 40.6933Z\"\n stroke=\"white\"\n strokeWidth={2.25825}\n />\n </g>\n <defs>\n <filter\n id=\"filter0_d_91_7928\"\n x={0.602397}\n y={0.952444}\n width={49.0584}\n height={52.428}\n filterUnits=\"userSpaceOnUse\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feFlood floodOpacity={0} result=\"BackgroundImageFix\" />\n <feColorMatrix\n in=\"SourceAlpha\"\n type=\"matrix\"\n values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0\"\n result=\"hardAlpha\"\n />\n <feOffset dy={2.25825} />\n <feGaussianBlur stdDeviation={2.25825} />\n <feComposite in2=\"hardAlpha\" operator=\"out\" />\n <feColorMatrix\n type=\"matrix\"\n values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.08 0\"\n />\n <feBlend\n mode=\"normal\"\n in2=\"BackgroundImageFix\"\n result=\"effect1_dropShadow_91_7928\"\n />\n <feBlend\n mode=\"normal\"\n in=\"SourceGraphic\"\n in2=\"effect1_dropShadow_91_7928\"\n result=\"shape\"\n />\n </filter>\n </defs>\n </svg>\n )\n}\n\nexport function SmoothCursor({\n cursor = <DefaultCursorSVG />,\n springConfig = {\n damping: 45,\n stiffness: 400,\n mass: 1,\n restDelta: 0.001,\n },\n}: SmoothCursorProps) {\n const [isMoving, setIsMoving] = useState(false)\n const lastMousePos = useRef<Position>({ x: 0, y: 0 })\n const velocity = useRef<Position>({ x: 0, y: 0 })\n const lastUpdateTime = useRef(Date.now())\n const previousAngle = useRef(0)\n const accumulatedRotation = useRef(0)\n\n const cursorX = useSpring(0, springConfig)\n const cursorY = useSpring(0, springConfig)\n const rotation = useSpring(0, {\n ...springConfig,\n damping: 60,\n stiffness: 300,\n })\n const scale = useSpring(1, {\n ...springConfig,\n stiffness: 500,\n damping: 35,\n })\n\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout> | null = null\n\n const updateVelocity = (currentPos: Position) => {\n const currentTime = Date.now()\n const deltaTime = currentTime - lastUpdateTime.current\n\n if (deltaTime > 0) {\n velocity.current = {\n x: (currentPos.x - lastMousePos.current.x) / deltaTime,\n y: (currentPos.y - lastMousePos.current.y) / deltaTime,\n }\n }\n\n lastUpdateTime.current = currentTime\n lastMousePos.current = currentPos\n }\n\n const smoothMouseMove = (e: MouseEvent) => {\n const currentPos = { x: e.clientX, y: e.clientY }\n updateVelocity(currentPos)\n\n const speed = Math.sqrt(\n Math.pow(velocity.current.x, 2) + Math.pow(velocity.current.y, 2)\n )\n\n cursorX.set(currentPos.x)\n cursorY.set(currentPos.y)\n\n if (speed > 0.1) {\n const currentAngle =\n Math.atan2(velocity.current.y, velocity.current.x) * (180 / Math.PI) +\n 90\n\n let angleDiff = currentAngle - previousAngle.current\n if (angleDiff > 180) angleDiff -= 360\n if (angleDiff < -180) angleDiff += 360\n accumulatedRotation.current += angleDiff\n rotation.set(accumulatedRotation.current)\n previousAngle.current = currentAngle\n\n scale.set(0.95)\n setIsMoving(true)\n\n if (timeout !== null) {\n clearTimeout(timeout)\n }\n\n timeout = setTimeout(() => {\n scale.set(1)\n setIsMoving(false)\n }, 150)\n }\n }\n\n let rafId: number\n const throttledMouseMove = (e: MouseEvent) => {\n if (rafId) return\n\n rafId = requestAnimationFrame(() => {\n smoothMouseMove(e)\n rafId = 0\n })\n }\n\n document.body.style.cursor = \"none\"\n window.addEventListener(\"mousemove\", throttledMouseMove)\n\n return () => {\n window.removeEventListener(\"mousemove\", throttledMouseMove)\n document.body.style.cursor = \"auto\"\n if (rafId) cancelAnimationFrame(rafId)\n if (timeout !== null) {\n clearTimeout(timeout)\n }\n }\n }, [cursorX, cursorY, rotation, scale])\n\n return (\n <motion.div\n style={{\n position: \"fixed\",\n left: cursorX,\n top: cursorY,\n translateX: \"-50%\",\n translateY: \"-50%\",\n rotate: rotation,\n scale: scale,\n zIndex: 100,\n pointerEvents: \"none\",\n willChange: \"transform\",\n }}\n initial={{ scale: 0 }}\n animate={{ scale: 1 }}\n transition={{\n type: \"spring\",\n stiffness: 400,\n damping: 30,\n }}\n >\n {cursor}\n </motion.div>\n )\n}\n",
+ "content": "\"use client\"\n\nimport { FC, useEffect, useRef } from \"react\"\nimport { motion, useSpring } from \"motion/react\"\n\ninterface Position {\n x: number\n y: number\n}\n\nexport interface SmoothCursorProps {\n cursor?: React.ReactNode\n springConfig?: {\n damping: number\n stiffness: number\n mass: number\n restDelta: number\n }\n}\n\nconst DefaultCursorSVG: FC = () => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={50}\n height={54}\n viewBox=\"0 0 50 54\"\n fill=\"none\"\n style={{ scale: 0.5 }}\n >\n <g filter=\"url(#filter0_d_91_7928)\">\n <path\n d=\"M42.6817 41.1495L27.5103 6.79925C26.7269 5.02557 24.2082 5.02558 23.3927 6.79925L7.59814 41.1495C6.75833 42.9759 8.52712 44.8902 10.4125 44.1954L24.3757 39.0496C24.8829 38.8627 25.4385 38.8627 25.9422 39.0496L39.8121 44.1954C41.6849 44.8902 43.4884 42.9759 42.6817 41.1495Z\"\n fill=\"black\"\n />\n <path\n d=\"M43.7146 40.6933L28.5431 6.34306C27.3556 3.65428 23.5772 3.69516 22.3668 6.32755L6.57226 40.6778C5.3134 43.4156 7.97238 46.298 10.803 45.2549L24.7662 40.109C25.0221 40.0147 25.2999 40.0156 25.5494 40.1082L39.4193 45.254C42.2261 46.2953 44.9254 43.4347 43.7146 40.6933Z\"\n stroke=\"white\"\n strokeWidth={2.25825}\n />\n </g>\n <defs>\n <filter\n id=\"filter0_d_91_7928\"\n x={0.602397}\n y={0.952444}\n width={49.0584}\n height={52.428}\n filterUnits=\"userSpaceOnUse\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feFlood floodOpacity={0} result=\"BackgroundImageFix\" />\n <feColorMatrix\n in=\"SourceAlpha\"\n type=\"matrix\"\n values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0\"\n result=\"hardAlpha\"\n />\n <feOffset dy={2.25825} />\n <feGaussianBlur stdDeviation={2.25825} />\n <feComposite in2=\"hardAlpha\" operator=\"out\" />\n <feColorMatrix\n type=\"matrix\"\n values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.08 0\"\n />\n <feBlend\n mode=\"normal\"\n in2=\"BackgroundImageFix\"\n result=\"effect1_dropShadow_91_7928\"\n />\n <feBlend\n mode=\"normal\"\n in=\"SourceGraphic\"\n in2=\"effect1_dropShadow_91_7928\"\n result=\"shape\"\n />\n </filter>\n </defs>\n </svg>\n )\n}\n\nexport function SmoothCursor({\n cursor = <DefaultCursorSVG />,\n springConfig = {\n damping: 45,\n stiffness: 400,\n mass: 1,\n restDelta: 0.001,\n },\n}: SmoothCursorProps) {\n const lastMousePos = useRef<Position>({ x: 0, y: 0 })\n const velocity = useRef<Position>({ x: 0, y: 0 })\n const lastUpdateTime = useRef(Date.now())\n const previousAngle = useRef(0)\n const accumulatedRotation = useRef(0)\n\n const cursorX = useSpring(0, springConfig)\n const cursorY = useSpring(0, springConfig)\n const rotation = useSpring(0, {\n ...springConfig,\n damping: 60,\n stiffness: 300,\n })\n const scale = useSpring(1, {\n ...springConfig,\n stiffness: 500,\n damping: 35,\n })\n\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout> | null = null\n\n const updateVelocity = (currentPos: Position) => {\n const currentTime = Date.now()\n const deltaTime = currentTime - lastUpdateTime.current\n\n if (deltaTime > 0) {\n velocity.current = {\n x: (currentPos.x - lastMousePos.current.x) / deltaTime,\n y: (currentPos.y - lastMousePos.current.y) / deltaTime,\n }\n }\n\n lastUpdateTime.current = currentTime\n lastMousePos.current = currentPos\n }\n\n const smoothMouseMove = (e: MouseEvent) => {\n const currentPos = { x: e.clientX, y: e.clientY }\n updateVelocity(currentPos)\n\n const speed = Math.sqrt(\n Math.pow(velocity.current.x, 2) + Math.pow(velocity.current.y, 2)\n )\n\n cursorX.set(currentPos.x)\n cursorY.set(currentPos.y)\n\n if (speed > 0.1) {\n const currentAngle =\n Math.atan2(velocity.current.y, velocity.current.x) * (180 / Math.PI) +\n 90\n\n let angleDiff = currentAngle - previousAngle.current\n if (angleDiff > 180) angleDiff -= 360\n if (angleDiff < -180) angleDiff += 360\n accumulatedRotation.current += angleDiff\n rotation.set(accumulatedRotation.current)\n previousAngle.current = currentAngle\n\n scale.set(0.95)\n\n if (timeout !== null) {\n clearTimeout(timeout)\n }\n\n timeout = setTimeout(() => {\n scale.set(1)\n }, 150)\n }\n }\n\n let rafId: number\n const throttledMouseMove = (e: MouseEvent) => {\n if (rafId) return\n\n rafId = requestAnimationFrame(() => {\n smoothMouseMove(e)\n rafId = 0\n })\n }\n\n document.body.style.cursor = \"none\"\n window.addEventListener(\"mousemove\", throttledMouseMove)\n\n return () => {\n window.removeEventListener(\"mousemove\", throttledMouseMove)\n document.body.style.cursor = \"auto\"\n if (rafId) cancelAnimationFrame(rafId)\n if (timeout !== null) {\n clearTimeout(timeout)\n }\n }\n }, [cursorX, cursorY, rotation, scale])\n\n return (\n <motion.div\n style={{\n position: \"fixed\",\n left: cursorX,\n top: cursorY,\n translateX: \"-50%\",\n translateY: \"-50%\",\n rotate: rotation,\n scale: scale,\n zIndex: 100,\n pointerEvents: \"none\",\n willChange: \"transform\",\n }}\n initial={{ scale: 0 }}\n animate={{ scale: 1 }}\n transition={{\n type: \"spring\",\n stiffness: 400,\n damping: 30,\n }}\n >\n {cursor}\n </motion.div>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/terminal.json b/apps/www/public/r/terminal.json
index 98ca2abd..cc2619d2 100644
--- a/apps/www/public/r/terminal.json
+++ b/apps/www/public/r/terminal.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/terminal.tsx",
- "content": "\"use client\"\n\nimport {\n Children,\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ComponentType,\n type RefAttributes,\n} from \"react\"\nimport {\n motion,\n useInView,\n type DOMMotionComponents,\n type HTMLMotionProps,\n type MotionProps,\n} from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface SequenceContextValue {\n completeItem: (index: number) => void\n activeIndex: number\n sequenceStarted: boolean\n}\n\nconst SequenceContext = createContext<SequenceContextValue | null>(null)\n\nconst useSequence = () => useContext(SequenceContext)\n\nconst ItemIndexContext = createContext<number | null>(null)\nconst useItemIndex = () => useContext(ItemIndexContext)\n\nconst motionElements = {\n article: motion.article,\n div: motion.div,\n h1: motion.h1,\n h2: motion.h2,\n h3: motion.h3,\n h4: motion.h4,\n h5: motion.h5,\n h6: motion.h6,\n li: motion.li,\n p: motion.p,\n section: motion.section,\n span: motion.span,\n} as const\n\ntype MotionElementType = Extract<\n keyof DOMMotionComponents,\n keyof typeof motionElements\n>\ntype TerminalTypingMotionComponent = ComponentType<\n Omit<HTMLMotionProps<\"span\">, \"ref\"> & RefAttributes<HTMLElement>\n>\n\ninterface AnimatedSpanProps extends MotionProps {\n children: React.ReactNode\n delay?: number\n className?: string\n startOnView?: boolean\n}\n\nexport const AnimatedSpan = ({\n children,\n delay = 0,\n className,\n startOnView = false,\n ...props\n}: AnimatedSpanProps) => {\n const elementRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n const [hasStarted, setHasStarted] = useState(false)\n useEffect(() => {\n if (!sequence || itemIndex === null) return\n if (!sequence.sequenceStarted) return\n if (hasStarted) return\n if (sequence.activeIndex === itemIndex) {\n setHasStarted(true)\n }\n }, [sequence?.activeIndex, sequence?.sequenceStarted, hasStarted, itemIndex])\n\n const shouldAnimate = sequence ? hasStarted : startOnView ? isInView : true\n\n return (\n <motion.div\n ref={elementRef}\n initial={{ opacity: 0, y: -5 }}\n animate={shouldAnimate ? { opacity: 1, y: 0 } : { opacity: 0, y: -5 }}\n transition={{ duration: 0.3, delay: sequence ? 0 : delay / 1000 }}\n className={cn(\"grid text-sm font-normal tracking-tight\", className)}\n onAnimationComplete={() => {\n if (!sequence) return\n if (itemIndex === null) return\n sequence.completeItem(itemIndex)\n }}\n {...props}\n >\n {children}\n </motion.div>\n )\n}\n\ninterface TypingAnimationProps extends Omit<MotionProps, \"children\"> {\n children: string\n className?: string\n duration?: number\n delay?: number\n as?: MotionElementType\n startOnView?: boolean\n}\n\nexport const TypingAnimation = ({\n children,\n className,\n duration = 60,\n delay = 0,\n as: Component = \"span\",\n startOnView = true,\n ...props\n}: TypingAnimationProps) => {\n if (typeof children !== \"string\") {\n throw new Error(\"TypingAnimation: children must be a string. Received:\")\n }\n\n const MotionComponent = motionElements[\n Component\n ] as TerminalTypingMotionComponent\n\n const [displayedText, setDisplayedText] = useState<string>(\"\")\n const [started, setStarted] = useState(false)\n const elementRef = useRef<HTMLElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n\n useEffect(() => {\n let startTimeout: ReturnType<typeof setTimeout> | null = null\n\n if (sequence && itemIndex !== null) {\n if (\n sequence.sequenceStarted &&\n !started &&\n sequence.activeIndex === itemIndex\n ) {\n setStarted(true)\n }\n } else if (!startOnView || isInView) {\n startTimeout = setTimeout(() => setStarted(true), delay)\n }\n\n return () => {\n if (startTimeout !== null) {\n clearTimeout(startTimeout)\n }\n }\n }, [\n delay,\n startOnView,\n isInView,\n started,\n sequence?.activeIndex,\n sequence?.sequenceStarted,\n itemIndex,\n ])\n\n useEffect(() => {\n let typingEffect: ReturnType<typeof setInterval> | null = null\n\n if (started) {\n let i = 0\n typingEffect = setInterval(() => {\n if (i < children.length) {\n setDisplayedText(children.substring(0, i + 1))\n i++\n } else {\n if (typingEffect !== null) {\n clearInterval(typingEffect)\n }\n if (sequence && itemIndex !== null) {\n sequence.completeItem(itemIndex)\n }\n }\n }, duration)\n }\n\n return () => {\n if (typingEffect !== null) {\n clearInterval(typingEffect)\n }\n }\n }, [children, duration, started])\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"text-sm font-normal tracking-tight\", className)}\n {...props}\n >\n {displayedText}\n </MotionComponent>\n )\n}\n\ninterface TerminalProps {\n children: React.ReactNode\n className?: string\n sequence?: boolean\n startOnView?: boolean\n}\n\nexport const Terminal = ({\n children,\n className,\n sequence = true,\n startOnView = true,\n}: TerminalProps) => {\n const containerRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(containerRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const [activeIndex, setActiveIndex] = useState(0)\n const sequenceHasStarted = sequence ? !startOnView || isInView : false\n\n const contextValue = useMemo<SequenceContextValue | null>(() => {\n if (!sequence) return null\n return {\n completeItem: (index: number) => {\n setActiveIndex((current) => (index === current ? current + 1 : current))\n },\n activeIndex,\n sequenceStarted: sequenceHasStarted,\n }\n }, [sequence, activeIndex, sequenceHasStarted])\n\n const wrappedChildren = useMemo(() => {\n if (!sequence) return children\n const array = Children.toArray(children)\n return array.map((child, index) => (\n <ItemIndexContext.Provider key={index} value={index}>\n {child as React.ReactNode}\n </ItemIndexContext.Provider>\n ))\n }, [children, sequence])\n\n const content = (\n <div\n ref={containerRef}\n className={cn(\n \"border-border bg-background z-0 h-full max-h-[400px] w-full max-w-lg rounded-xl border\",\n className\n )}\n >\n <div className=\"border-border flex flex-col gap-y-2 border-b p-4\">\n <div className=\"flex flex-row gap-x-2\">\n <div className=\"h-2 w-2 rounded-full bg-red-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-yellow-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-green-500\"></div>\n </div>\n </div>\n <pre className=\"p-4\">\n <code className=\"grid gap-y-1 overflow-auto\">{wrappedChildren}</code>\n </pre>\n </div>\n )\n\n if (!sequence) return content\n\n return (\n <SequenceContext.Provider value={contextValue}>\n {content}\n </SequenceContext.Provider>\n )\n}\n",
+ "content": "\"use client\"\n\nimport {\n Children,\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ComponentType,\n type RefAttributes,\n} from \"react\"\nimport {\n motion,\n useInView,\n type DOMMotionComponents,\n type HTMLMotionProps,\n type MotionProps,\n} from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface SequenceContextValue {\n completeItem: (index: number) => void\n activeIndex: number\n sequenceStarted: boolean\n}\n\nconst SequenceContext = createContext<SequenceContextValue | null>(null)\n\nconst useSequence = () => useContext(SequenceContext)\n\nconst ItemIndexContext = createContext<number | null>(null)\nconst useItemIndex = () => useContext(ItemIndexContext)\n\nconst motionElements = {\n article: motion.article,\n div: motion.div,\n h1: motion.h1,\n h2: motion.h2,\n h3: motion.h3,\n h4: motion.h4,\n h5: motion.h5,\n h6: motion.h6,\n li: motion.li,\n p: motion.p,\n section: motion.section,\n span: motion.span,\n} as const\n\ntype MotionElementType = Extract<\n keyof DOMMotionComponents,\n keyof typeof motionElements\n>\ntype TerminalTypingMotionComponent = ComponentType<\n Omit<HTMLMotionProps<\"span\">, \"ref\"> & RefAttributes<HTMLElement>\n>\n\ninterface AnimatedSpanProps extends MotionProps {\n children: React.ReactNode\n delay?: number\n className?: string\n startOnView?: boolean\n}\n\nexport const AnimatedSpan = ({\n children,\n delay = 0,\n className,\n startOnView = false,\n ...props\n}: AnimatedSpanProps) => {\n const elementRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n const [hasStarted, setHasStarted] = useState(false)\n useEffect(() => {\n if (!sequence || itemIndex === null) return\n if (!sequence.sequenceStarted) return\n if (hasStarted) return\n if (sequence.activeIndex === itemIndex) {\n setHasStarted(true)\n }\n }, [sequence, hasStarted, itemIndex])\n\n const shouldAnimate = sequence ? hasStarted : startOnView ? isInView : true\n\n return (\n <motion.div\n ref={elementRef}\n initial={{ opacity: 0, y: -5 }}\n animate={shouldAnimate ? { opacity: 1, y: 0 } : { opacity: 0, y: -5 }}\n transition={{ duration: 0.3, delay: sequence ? 0 : delay / 1000 }}\n className={cn(\"grid text-sm font-normal tracking-tight\", className)}\n onAnimationComplete={() => {\n if (!sequence) return\n if (itemIndex === null) return\n sequence.completeItem(itemIndex)\n }}\n {...props}\n >\n {children}\n </motion.div>\n )\n}\n\ninterface TypingAnimationProps extends Omit<MotionProps, \"children\"> {\n children: string\n className?: string\n duration?: number\n delay?: number\n as?: MotionElementType\n startOnView?: boolean\n}\n\nexport const TypingAnimation = ({\n children,\n className,\n duration = 60,\n delay = 0,\n as: Component = \"span\",\n startOnView = true,\n ...props\n}: TypingAnimationProps) => {\n if (typeof children !== \"string\") {\n throw new Error(\"TypingAnimation: children must be a string. Received:\")\n }\n\n const MotionComponent = motionElements[\n Component\n ] as TerminalTypingMotionComponent\n\n const [displayedText, setDisplayedText] = useState<string>(\"\")\n const [started, setStarted] = useState(false)\n const elementRef = useRef<HTMLElement | null>(null)\n const isInView = useInView(elementRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const sequence = useSequence()\n const itemIndex = useItemIndex()\n const hasSequence = sequence !== null\n const sequenceStarted = sequence?.sequenceStarted ?? false\n const sequenceActiveIndex = sequence?.activeIndex ?? null\n const sequenceCompleteItemRef = useRef<\n SequenceContextValue[\"completeItem\"] | null\n >(null)\n const sequenceItemIndexRef = useRef<number | null>(null)\n\n useEffect(() => {\n sequenceCompleteItemRef.current = sequence?.completeItem ?? null\n sequenceItemIndexRef.current = itemIndex\n }, [sequence?.completeItem, itemIndex])\n\n useEffect(() => {\n let startTimeout: ReturnType<typeof setTimeout> | null = null\n\n if (hasSequence && itemIndex !== null) {\n if (sequenceStarted && !started && sequenceActiveIndex === itemIndex) {\n setStarted(true)\n }\n } else if (!startOnView || isInView) {\n startTimeout = setTimeout(() => setStarted(true), delay)\n }\n\n return () => {\n if (startTimeout !== null) {\n clearTimeout(startTimeout)\n }\n }\n }, [\n delay,\n startOnView,\n isInView,\n started,\n hasSequence,\n sequenceActiveIndex,\n sequenceStarted,\n itemIndex,\n ])\n\n useEffect(() => {\n let typingEffect: ReturnType<typeof setInterval> | null = null\n\n if (started) {\n let i = 0\n typingEffect = setInterval(() => {\n if (i < children.length) {\n setDisplayedText(children.substring(0, i + 1))\n i++\n } else {\n if (typingEffect !== null) {\n clearInterval(typingEffect)\n }\n const completeItem = sequenceCompleteItemRef.current\n const currentItemIndex = sequenceItemIndexRef.current\n if (completeItem && currentItemIndex !== null) {\n completeItem(currentItemIndex)\n }\n }\n }, duration)\n }\n\n return () => {\n if (typingEffect !== null) {\n clearInterval(typingEffect)\n }\n }\n }, [children, duration, started])\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"text-sm font-normal tracking-tight\", className)}\n {...props}\n >\n {displayedText}\n </MotionComponent>\n )\n}\n\ninterface TerminalProps {\n children: React.ReactNode\n className?: string\n sequence?: boolean\n startOnView?: boolean\n}\n\nexport const Terminal = ({\n children,\n className,\n sequence = true,\n startOnView = true,\n}: TerminalProps) => {\n const containerRef = useRef<HTMLDivElement | null>(null)\n const isInView = useInView(containerRef as React.RefObject<Element>, {\n amount: 0.3,\n once: true,\n })\n\n const [activeIndex, setActiveIndex] = useState(0)\n const sequenceHasStarted = sequence ? !startOnView || isInView : false\n\n const contextValue = useMemo<SequenceContextValue | null>(() => {\n if (!sequence) return null\n return {\n completeItem: (index: number) => {\n setActiveIndex((current) => (index === current ? current + 1 : current))\n },\n activeIndex,\n sequenceStarted: sequenceHasStarted,\n }\n }, [sequence, activeIndex, sequenceHasStarted])\n\n const wrappedChildren = useMemo(() => {\n if (!sequence) return children\n const array = Children.toArray(children)\n return array.map((child, index) => (\n <ItemIndexContext.Provider key={index} value={index}>\n {child as React.ReactNode}\n </ItemIndexContext.Provider>\n ))\n }, [children, sequence])\n\n const content = (\n <div\n ref={containerRef}\n className={cn(\n \"border-border bg-background z-0 h-full max-h-[400px] w-full max-w-lg rounded-xl border\",\n className\n )}\n >\n <div className=\"border-border flex flex-col gap-y-2 border-b p-4\">\n <div className=\"flex flex-row gap-x-2\">\n <div className=\"h-2 w-2 rounded-full bg-red-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-yellow-500\"></div>\n <div className=\"h-2 w-2 rounded-full bg-green-500\"></div>\n </div>\n </div>\n <pre className=\"p-4\">\n <code className=\"grid gap-y-1 overflow-auto\">{wrappedChildren}</code>\n </pre>\n </div>\n )\n\n if (!sequence) return content\n\n return (\n <SequenceContext.Provider value={contextValue}>\n {content}\n </SequenceContext.Provider>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/public/r/tweet-card.json b/apps/www/public/r/tweet-card.json
index 27d209c3..d59c5c93 100644
--- a/apps/www/public/r/tweet-card.json
+++ b/apps/www/public/r/tweet-card.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/magicui/tweet-card.tsx",
- "content": "/* eslint-disable @next/next/no-img-element */\nimport { Suspense } from \"react\"\nimport { enrichTweet, type EnrichedTweet, type TweetProps } from \"react-tweet\"\nimport { getTweet, type Tweet } from \"react-tweet/api\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface TwitterIconProps {\n className?: string\n [key: string]: unknown\n}\nconst Twitter = ({ className, ...props }: TwitterIconProps) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={className}\n {...props}\n >\n <g>\n <path fill=\"none\" d=\"M0 0h24v24H0z\"></path>\n <path d=\"M22.162 5.656a8.384 8.384 0 0 1-2.402.658A4.196 4.196 0 0 0 21.6 4c-.82.488-1.719.83-2.656 1.015a4.182 4.182 0 0 0-7.126 3.814 11.874 11.874 0 0 1-8.62-4.37 4.168 4.168 0 0 0-.566 2.103c0 1.45.738 2.731 1.86 3.481a4.168 4.168 0 0 1-1.894-.523v.052a4.185 4.185 0 0 0 3.355 4.101 4.21 4.21 0 0 1-1.89.072A4.185 4.185 0 0 0 7.97 16.65a8.394 8.394 0 0 1-6.191 1.732 11.83 11.83 0 0 0 6.41 1.88c7.693 0 11.9-6.373 11.9-11.9 0-.18-.005-.362-.013-.54a8.496 8.496 0 0 0 2.087-2.165z\"></path>\n </g>\n </svg>\n)\n\nconst Verified = ({ className, ...props }: TwitterIconProps) => (\n <svg\n aria-label=\"Verified Account\"\n viewBox=\"0 0 24 24\"\n className={className}\n {...props}\n >\n <g fill=\"currentColor\">\n <path d=\"M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .494.083.964.237 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z\" />\n </g>\n </svg>\n)\n\nexport const truncate = (str: string | null, length: number) => {\n if (!str || str.length <= length) return str\n return `${str.slice(0, length - 3)}...`\n}\n\nconst Skeleton = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => {\n return (\n <div className={cn(\"bg-primary/10 rounded-md\", className)} {...props} />\n )\n}\n\nexport const TweetSkeleton = ({\n className,\n ...props\n}: {\n className?: string\n [key: string]: unknown\n}) => (\n <div\n className={cn(\n \"flex size-full max-h-max min-w-72 flex-col gap-2 rounded-xl border p-4\",\n className\n )}\n {...props}\n >\n <div className=\"flex flex-row gap-2\">\n <Skeleton className=\"size-10 shrink-0 rounded-full\" />\n <Skeleton className=\"h-10 w-full\" />\n </div>\n <Skeleton className=\"h-20 w-full\" />\n </div>\n)\n\nexport const TweetNotFound = ({\n className,\n ...props\n}: {\n className?: string\n [key: string]: unknown\n}) => (\n <div\n className={cn(\n \"flex size-full flex-col items-center justify-center gap-2 rounded-lg border p-4\",\n className\n )}\n {...props}\n >\n <h3>Tweet not found</h3>\n </div>\n)\n\nexport const TweetHeader = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"flex flex-row items-start justify-between tracking-normal\">\n <div className=\"flex items-center space-x-3\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"shrink-0\"\n >\n <img\n title={`Profile picture of ${tweet.user.name}`}\n alt={tweet.user.screen_name}\n height={48}\n width={48}\n src={tweet.user.profile_image_url_https}\n className=\"border-border/50 overflow-hidden rounded-full border\"\n />\n </a>\n <div className=\"flex flex-col gap-0.5\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-foreground flex items-center font-medium whitespace-nowrap transition-opacity hover:opacity-80\"\n >\n {truncate(tweet.user.name, 20)}\n {tweet.user.verified ||\n (tweet.user.is_blue_verified && (\n <Verified className=\"ml-1 inline size-4 text-blue-500\" />\n ))}\n </a>\n <div className=\"flex items-center space-x-1\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-muted-foreground hover:text-foreground text-sm transition-colors\"\n >\n @{truncate(tweet.user.screen_name, 16)}\n </a>\n </div>\n </div>\n </div>\n <a href={tweet.url} target=\"_blank\" rel=\"noreferrer\">\n <span className=\"sr-only\">Link to tweet</span>\n <Twitter className=\"text-muted-foreground hover:text-foreground size-5 items-start transition-all ease-in-out hover:scale-105\" />\n </a>\n </div>\n)\n\nexport const TweetBody = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"text-[15px] leading-relaxed tracking-normal wrap-break-word\">\n {tweet.entities.map((entity, idx) => {\n switch (entity.type) {\n case \"url\":\n case \"symbol\":\n case \"hashtag\":\n case \"mention\":\n return (\n <a\n key={idx}\n href={entity.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-muted-foreground hover:text-foreground text-[15px] font-normal transition-colors\"\n >\n <span>{entity.text}</span>\n </a>\n )\n case \"text\":\n return (\n <span\n key={idx}\n className=\"text-foreground text-[15px] font-normal\"\n dangerouslySetInnerHTML={{ __html: entity.text }}\n />\n )\n default:\n return null\n }\n })}\n </div>\n)\n\nexport const TweetMedia = ({ tweet }: { tweet: EnrichedTweet }) => {\n if (!tweet.video && !tweet.photos) return null\n return (\n <div className=\"flex flex-1 items-center justify-center\">\n {tweet.video && (\n <video\n poster={tweet.video.poster}\n autoPlay\n loop\n muted\n playsInline\n className=\"rounded-xl border shadow-sm\"\n >\n <source src={tweet.video.variants[0].src} type=\"video/mp4\" />\n Your browser does not support the video tag.\n </video>\n )}\n {tweet.photos && (\n <div className=\"relative flex transform-gpu snap-x snap-mandatory gap-4 overflow-x-auto\">\n <div className=\"shrink-0 snap-center sm:w-2\" />\n {tweet.photos.map((photo) => (\n <img\n key={photo.url}\n src={photo.url}\n width={photo.width}\n height={photo.height}\n title={\"Photo by \" + tweet.user.name}\n alt={tweet.text}\n className=\"h-64 w-5/6 shrink-0 snap-center snap-always rounded-xl border object-cover shadow-sm\"\n />\n ))}\n <div className=\"shrink-0 snap-center sm:w-2\" />\n </div>\n )}\n {!tweet.video &&\n !tweet.photos &&\n // @ts-expect-error package doesn't have type definitions\n tweet?.card?.binding_values?.thumbnail_image_large?.image_value.url && (\n <img\n src={\n // @ts-expect-error package doesn't have type definitions\n tweet.card.binding_values.thumbnail_image_large.image_value.url\n }\n className=\"h-64 rounded-xl border object-cover shadow-sm\"\n alt={tweet.text}\n />\n )}\n </div>\n )\n}\n\nexport const MagicTweet = ({\n tweet,\n className,\n ...props\n}: {\n tweet: Tweet\n className?: string\n}) => {\n const enrichedTweet = enrichTweet(tweet)\n return (\n <div\n className={cn(\n \"relative flex h-fit w-full max-w-lg flex-col gap-4 overflow-hidden rounded-xl border p-5\",\n className\n )}\n {...props}\n >\n <TweetHeader tweet={enrichedTweet} />\n <TweetBody tweet={enrichedTweet} />\n <TweetMedia tweet={enrichedTweet} />\n </div>\n )\n}\n\n/**\n * TweetCard (Server Side Only)\n */\nexport const TweetCard = async ({\n id,\n components,\n fallback = <TweetSkeleton />,\n onError,\n ...props\n}: TweetProps & {\n className?: string\n}) => {\n const tweet = id\n ? await getTweet(id).catch((err) => {\n if (onError) {\n onError(err)\n } else {\n console.error(err)\n }\n })\n : undefined\n\n if (!tweet) {\n const NotFound = components?.TweetNotFound ?? TweetNotFound\n return <NotFound {...props} />\n }\n\n return (\n <Suspense fallback={fallback}>\n <MagicTweet tweet={tweet} {...props} />\n </Suspense>\n )\n}\n",
+ "content": "import { Suspense } from \"react\"\nimport { enrichTweet, type EnrichedTweet, type TweetProps } from \"react-tweet\"\nimport { getTweet, type Tweet } from \"react-tweet/api\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface TwitterIconProps {\n className?: string\n [key: string]: unknown\n}\nconst Twitter = ({ className, ...props }: TwitterIconProps) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={className}\n {...props}\n >\n <g>\n <path fill=\"none\" d=\"M0 0h24v24H0z\"></path>\n <path d=\"M22.162 5.656a8.384 8.384 0 0 1-2.402.658A4.196 4.196 0 0 0 21.6 4c-.82.488-1.719.83-2.656 1.015a4.182 4.182 0 0 0-7.126 3.814 11.874 11.874 0 0 1-8.62-4.37 4.168 4.168 0 0 0-.566 2.103c0 1.45.738 2.731 1.86 3.481a4.168 4.168 0 0 1-1.894-.523v.052a4.185 4.185 0 0 0 3.355 4.101 4.21 4.21 0 0 1-1.89.072A4.185 4.185 0 0 0 7.97 16.65a8.394 8.394 0 0 1-6.191 1.732 11.83 11.83 0 0 0 6.41 1.88c7.693 0 11.9-6.373 11.9-11.9 0-.18-.005-.362-.013-.54a8.496 8.496 0 0 0 2.087-2.165z\"></path>\n </g>\n </svg>\n)\n\nconst Verified = ({ className, ...props }: TwitterIconProps) => (\n <svg\n aria-label=\"Verified Account\"\n viewBox=\"0 0 24 24\"\n className={className}\n {...props}\n >\n <g fill=\"currentColor\">\n <path d=\"M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .494.083.964.237 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z\" />\n </g>\n </svg>\n)\n\nexport const truncate = (str: string | null, length: number) => {\n if (!str || str.length <= length) return str\n return `${str.slice(0, length - 3)}...`\n}\n\nconst Skeleton = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => {\n return (\n <div className={cn(\"bg-primary/10 rounded-md\", className)} {...props} />\n )\n}\n\nexport const TweetSkeleton = ({\n className,\n ...props\n}: {\n className?: string\n [key: string]: unknown\n}) => (\n <div\n className={cn(\n \"flex size-full max-h-max min-w-72 flex-col gap-2 rounded-xl border p-4\",\n className\n )}\n {...props}\n >\n <div className=\"flex flex-row gap-2\">\n <Skeleton className=\"size-10 shrink-0 rounded-full\" />\n <Skeleton className=\"h-10 w-full\" />\n </div>\n <Skeleton className=\"h-20 w-full\" />\n </div>\n)\n\nexport const TweetNotFound = ({\n className,\n ...props\n}: {\n className?: string\n [key: string]: unknown\n}) => (\n <div\n className={cn(\n \"flex size-full flex-col items-center justify-center gap-2 rounded-lg border p-4\",\n className\n )}\n {...props}\n >\n <h3>Tweet not found</h3>\n </div>\n)\n\nexport const TweetHeader = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"flex flex-row items-start justify-between tracking-normal\">\n <div className=\"flex items-center space-x-3\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"shrink-0\"\n >\n <img\n title={`Profile picture of ${tweet.user.name}`}\n alt={tweet.user.screen_name}\n height={48}\n width={48}\n src={tweet.user.profile_image_url_https}\n className=\"border-border/50 overflow-hidden rounded-full border\"\n />\n </a>\n <div className=\"flex flex-col gap-0.5\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-foreground flex items-center font-medium whitespace-nowrap transition-opacity hover:opacity-80\"\n >\n {truncate(tweet.user.name, 20)}\n {tweet.user.verified ||\n (tweet.user.is_blue_verified && (\n <Verified className=\"ml-1 inline size-4 text-blue-500\" />\n ))}\n </a>\n <div className=\"flex items-center space-x-1\">\n <a\n href={tweet.user.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-muted-foreground hover:text-foreground text-sm transition-colors\"\n >\n @{truncate(tweet.user.screen_name, 16)}\n </a>\n </div>\n </div>\n </div>\n <a href={tweet.url} target=\"_blank\" rel=\"noreferrer\">\n <span className=\"sr-only\">Link to tweet</span>\n <Twitter className=\"text-muted-foreground hover:text-foreground size-5 items-start transition-all ease-in-out hover:scale-105\" />\n </a>\n </div>\n)\n\nexport const TweetBody = ({ tweet }: { tweet: EnrichedTweet }) => (\n <div className=\"text-[15px] leading-relaxed tracking-normal wrap-break-word\">\n {tweet.entities.map((entity, idx) => {\n switch (entity.type) {\n case \"url\":\n case \"symbol\":\n case \"hashtag\":\n case \"mention\":\n return (\n <a\n key={idx}\n href={entity.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-muted-foreground hover:text-foreground text-[15px] font-normal transition-colors\"\n >\n <span>{entity.text}</span>\n </a>\n )\n case \"text\":\n return (\n <span\n key={idx}\n className=\"text-foreground text-[15px] font-normal\"\n dangerouslySetInnerHTML={{ __html: entity.text }}\n />\n )\n default:\n return null\n }\n })}\n </div>\n)\n\nexport const TweetMedia = ({ tweet }: { tweet: EnrichedTweet }) => {\n if (!tweet.video && !tweet.photos) return null\n return (\n <div className=\"flex flex-1 items-center justify-center\">\n {tweet.video && (\n <video\n poster={tweet.video.poster}\n autoPlay\n loop\n muted\n playsInline\n className=\"rounded-xl border shadow-sm\"\n >\n <source src={tweet.video.variants[0].src} type=\"video/mp4\" />\n Your browser does not support the video tag.\n </video>\n )}\n {tweet.photos && (\n <div className=\"relative flex transform-gpu snap-x snap-mandatory gap-4 overflow-x-auto\">\n <div className=\"shrink-0 snap-center sm:w-2\" />\n {tweet.photos.map((photo) => (\n <img\n key={photo.url}\n src={photo.url}\n width={photo.width}\n height={photo.height}\n title={\"Photo by \" + tweet.user.name}\n alt={tweet.text}\n className=\"h-64 w-5/6 shrink-0 snap-center snap-always rounded-xl border object-cover shadow-sm\"\n />\n ))}\n <div className=\"shrink-0 snap-center sm:w-2\" />\n </div>\n )}\n {!tweet.video &&\n !tweet.photos &&\n // @ts-expect-error package doesn't have type definitions\n tweet?.card?.binding_values?.thumbnail_image_large?.image_value.url && (\n <img\n src={\n // @ts-expect-error package doesn't have type definitions\n tweet.card.binding_values.thumbnail_image_large.image_value.url\n }\n className=\"h-64 rounded-xl border object-cover shadow-sm\"\n alt={tweet.text}\n />\n )}\n </div>\n )\n}\n\nexport const MagicTweet = ({\n tweet,\n className,\n ...props\n}: {\n tweet: Tweet\n className?: string\n}) => {\n const enrichedTweet = enrichTweet(tweet)\n return (\n <div\n className={cn(\n \"relative flex h-fit w-full max-w-lg flex-col gap-4 overflow-hidden rounded-xl border p-5\",\n className\n )}\n {...props}\n >\n <TweetHeader tweet={enrichedTweet} />\n <TweetBody tweet={enrichedTweet} />\n <TweetMedia tweet={enrichedTweet} />\n </div>\n )\n}\n\n/**\n * TweetCard (Server Side Only)\n */\nexport const TweetCard = async ({\n id,\n components,\n fallback = <TweetSkeleton />,\n onError,\n ...props\n}: TweetProps & {\n className?: string\n}) => {\n const tweet = id\n ? await getTweet(id).catch((err) => {\n if (onError) {\n onError(err)\n } else {\n console.error(err)\n }\n })\n : undefined\n\n if (!tweet) {\n const NotFound = components?.TweetNotFound ?? TweetNotFound\n return <NotFound {...props} />\n }\n\n return (\n <Suspense fallback={fallback}>\n <MagicTweet tweet={tweet} {...props} />\n </Suspense>\n )\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/registry/example/bento-demo-vertical.tsx b/apps/www/registry/example/bento-demo-vertical.tsx
index d1b1493e..e6897561 100644
--- a/apps/www/registry/example/bento-demo-vertical.tsx
+++ b/apps/www/registry/example/bento-demo-vertical.tsx
@@ -15,7 +15,9 @@ const features = [
description: "We automatically save your files as you type.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:row-start-1 lg:row-end-4 lg:col-start-2 lg:col-end-3",
},
{
@@ -24,7 +26,9 @@ const features = [
description: "Search through all your files in one place.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-1 lg:col-end-2 lg:row-start-1 lg:row-end-3",
},
{
@@ -33,7 +37,9 @@ const features = [
description: "Supports 100+ languages and counting.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-1 lg:col-end-2 lg:row-start-3 lg:row-end-4",
},
{
@@ -42,7 +48,9 @@ const features = [
description: "Use the calendar to filter your files by date.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-3 lg:col-end-3 lg:row-start-1 lg:row-end-2",
},
{
@@ -52,7 +60,9 @@ const features = [
"Get notified when someone shares a file or mentions you in a comment.",
href: "/",
cta: "Learn more",
- background: <img className="absolute -top-20 -right-20 opacity-60" />,
+ background: (
+ <img alt="" className="absolute -top-20 -right-20 opacity-60" />
+ ),
className: "lg:col-start-3 lg:col-end-3 lg:row-start-2 lg:row-end-4",
},
]
diff --git a/apps/www/registry/example/blur-fade-demo.tsx b/apps/www/registry/example/blur-fade-demo.tsx
index 13c738e3..cd34eedf 100644
--- a/apps/www/registry/example/blur-fade-demo.tsx
+++ b/apps/www/registry/example/blur-fade-demo.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
import { BlurFade } from "@/registry/magicui/blur-fade"
const images = Array.from({ length: 9 }, (_, i) => {
diff --git a/apps/www/registry/example/lens-demo-2.tsx b/apps/www/registry/example/lens-demo-2.tsx
index 9e287139..adc1d578 100644
--- a/apps/www/registry/example/lens-demo-2.tsx
+++ b/apps/www/registry/example/lens-demo-2.tsx
@@ -1,5 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
-
import { Button } from "@/components/ui/button"
import {
Card,
diff --git a/apps/www/registry/example/lens-demo-3.tsx b/apps/www/registry/example/lens-demo-3.tsx
index 99c4d664..43ed3732 100644
--- a/apps/www/registry/example/lens-demo-3.tsx
+++ b/apps/www/registry/example/lens-demo-3.tsx
@@ -1,5 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
-
import { Button } from "@/components/ui/button"
import {
Card,
diff --git a/apps/www/registry/example/lens-demo.tsx b/apps/www/registry/example/lens-demo.tsx
index 88c19bad..1eebca60 100644
--- a/apps/www/registry/example/lens-demo.tsx
+++ b/apps/www/registry/example/lens-demo.tsx
@@ -1,5 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
-
"use client"
import { Button } from "@/components/ui/button"
diff --git a/apps/www/registry/example/marquee-3d.tsx b/apps/www/registry/example/marquee-3d.tsx
index 854b5603..18f833af 100644
--- a/apps/www/registry/example/marquee-3d.tsx
+++ b/apps/www/registry/example/marquee-3d.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
import { cn } from "@/lib/utils"
import { Marquee } from "@/registry/magicui/marquee"
diff --git a/apps/www/registry/example/marquee-demo-vertical.tsx b/apps/www/registry/example/marquee-demo-vertical.tsx
index 1308e604..d0e3bbc0 100644
--- a/apps/www/registry/example/marquee-demo-vertical.tsx
+++ b/apps/www/registry/example/marquee-demo-vertical.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
import { cn } from "@/lib/utils"
import { Marquee } from "@/registry/magicui/marquee"
diff --git a/apps/www/registry/magicui/avatar-circles.tsx b/apps/www/registry/magicui/avatar-circles.tsx
index cb113ac2..d4a3ccc7 100644
--- a/apps/www/registry/magicui/avatar-circles.tsx
+++ b/apps/www/registry/magicui/avatar-circles.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
"use client"
import { cn } from "@/lib/utils"
diff --git a/apps/www/registry/magicui/dot-pattern.tsx b/apps/www/registry/magicui/dot-pattern.tsx
index 17d6567c..db8eb89b 100644
--- a/apps/www/registry/magicui/dot-pattern.tsx
+++ b/apps/www/registry/magicui/dot-pattern.tsx
@@ -100,8 +100,8 @@ export function DotPattern({
const col = i % Math.ceil(dimensions.width / width)
const row = Math.floor(i / Math.ceil(dimensions.width / width))
return {
- x: col * width + cx,
- y: row * height + cy,
+ x: col * width + cx + x,
+ y: row * height + cy + y,
delay: Math.random() * 5,
duration: Math.random() * 3 + 2,
}
@@ -124,7 +124,7 @@ export function DotPattern({
<stop offset="100%" stopColor="currentColor" stopOpacity="0" />
</radialGradient>
</defs>
- {dots.map((dot, index) => (
+ {dots.map((dot) => (
<motion.circle
key={`${dot.x}-${dot.y}`}
cx={dot.x}
diff --git a/apps/www/registry/magicui/file-tree.tsx b/apps/www/registry/magicui/file-tree.tsx
index abebaf69..14de368e 100644
--- a/apps/www/registry/magicui/file-tree.tsx
+++ b/apps/www/registry/magicui/file-tree.tsx
@@ -132,7 +132,7 @@ const Tree = forwardRef<HTMLDivElement, TreeViewProps>(
if (initialSelectedId) {
expandSpecificTargetedElements(elements, initialSelectedId)
}
- }, [initialSelectedId, elements])
+ }, [initialSelectedId, elements, expandSpecificTargetedElements])
const direction = dir === "rtl" ? "rtl" : "ltr"
@@ -234,6 +234,7 @@ const Folder = forwardRef<
return (
<AccordionPrimitive.Item
+ ref={ref}
{...props}
value={value}
className="relative h-full overflow-hidden"
@@ -293,6 +294,7 @@ const File = forwardRef<
value,
className,
handleSelect,
+ onClick,
isSelectable = true,
isSelect,
fileIcon,
@@ -317,7 +319,11 @@ const File = forwardRef<
direction === "rtl" ? "rtl" : "ltr",
className
)}
- onClick={() => selectItem(value)}
+ onClick={(event) => {
+ selectItem(value)
+ handleSelect?.(value)
+ onClick?.(event)
+ }}
{...props}
>
{fileIcon ?? <FileIcon className="size-4" />}
@@ -339,36 +345,43 @@ const CollapseButton = forwardRef<
const { expandedItems, setExpandedItems } = useTree()
const expendAllTree = useCallback((elements: TreeViewElement[]) => {
+ const expandedElementIds: string[] = []
+
const expandTree = (element: TreeViewElement) => {
const isSelectable = element.isSelectable ?? true
if (isSelectable && element.children && element.children.length > 0) {
- setExpandedItems?.((prev) => [...(prev ?? []), element.id])
- element.children.forEach(expandTree)
+ expandedElementIds.push(element.id)
+ for (const child of element.children) {
+ expandTree(child)
+ }
}
}
- elements.forEach(expandTree)
+ for (const element of elements) {
+ expandTree(element)
+ }
+
+ return [...new Set(expandedElementIds)]
}, [])
const closeAll = useCallback(() => {
setExpandedItems?.([])
- }, [])
+ }, [setExpandedItems])
useEffect(() => {
- console.log(expandAll)
if (expandAll) {
- expendAllTree(elements)
+ setExpandedItems?.(expendAllTree(elements))
}
- }, [expandAll])
+ }, [expandAll, elements, expendAllTree, setExpandedItems])
return (
<Button
variant={"ghost"}
- className="absolute right-2 bottom-1 h-8 w-fit p-1"
+ className={cn("absolute right-2 bottom-1 h-8 w-fit p-1", className)}
onClick={
expandedItems && expandedItems.length > 0
? closeAll
- : () => expendAllTree(elements)
+ : () => setExpandedItems?.(expendAllTree(elements))
}
ref={ref}
{...props}
diff --git a/apps/www/registry/magicui/globe.tsx b/apps/www/registry/magicui/globe.tsx
index 3c3ee505..4b2f887e 100644
--- a/apps/www/registry/magicui/globe.tsx
+++ b/apps/www/registry/magicui/globe.tsx
@@ -43,9 +43,9 @@ export function Globe({
className?: string
config?: COBEOptions
}) {
- let phi = 0
- let width = 0
const canvasRef = useRef<HTMLCanvasElement>(null)
+ const phiRef = useRef(0)
+ const widthRef = useRef(0)
const pointerInteracting = useRef<number | null>(null)
const pointerInteractionMovement = useRef(0)
@@ -74,7 +74,7 @@ export function Globe({
useEffect(() => {
const onResize = () => {
if (canvasRef.current) {
- width = canvasRef.current.offsetWidth
+ widthRef.current = canvasRef.current.offsetWidth
}
}
@@ -83,13 +83,13 @@ export function Globe({
const globe = createGlobe(canvasRef.current!, {
...config,
- width: width * 2,
- height: width * 2,
+ width: widthRef.current * 2,
+ height: widthRef.current * 2,
onRender: (state) => {
- if (!pointerInteracting.current) phi += 0.005
- state.phi = phi + rs.get()
- state.width = width * 2
- state.height = width * 2
+ if (!pointerInteracting.current) phiRef.current += 0.005
+ state.phi = phiRef.current + rs.get()
+ state.width = widthRef.current * 2
+ state.height = widthRef.current * 2
},
})
diff --git a/apps/www/registry/magicui/hero-video-dialog.tsx b/apps/www/registry/magicui/hero-video-dialog.tsx
index 967966c8..5efe1de9 100644
--- a/apps/www/registry/magicui/hero-video-dialog.tsx
+++ b/apps/www/registry/magicui/hero-video-dialog.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
"use client"
import { useState } from "react"
diff --git a/apps/www/registry/magicui/icon-cloud.tsx b/apps/www/registry/magicui/icon-cloud.tsx
index 02a1d741..54fc16a6 100644
--- a/apps/www/registry/magicui/icon-cloud.tsx
+++ b/apps/www/registry/magicui/icon-cloud.tsx
@@ -24,7 +24,6 @@ function easeOutCubic(t: number): number {
export function IconCloud({ icons, images }: IconCloudProps) {
const canvasRef = useRef<HTMLCanvasElement>(null)
const [iconPositions, setIconPositions] = useState<Icon[]>([])
- const [rotation, setRotation] = useState({ x: 0, y: 0 })
const [isDragging, setIsDragging] = useState(false)
const [lastMousePos, setLastMousePos] = useState({ x: 0, y: 0 })
const [mousePos, setMousePos] = useState({ x: 0, y: 0 })
@@ -38,7 +37,7 @@ export function IconCloud({ icons, images }: IconCloudProps) {
duration: number
} | null>(null)
const animationFrameRef = useRef<number>(0)
- const rotationRef = useRef(rotation)
+ const rotationRef = useRef({ x: 0, y: 0 })
const iconCanvasesRef = useRef<HTMLCanvasElement[]>([])
const imagesLoadedRef = useRef<boolean[]>([])
diff --git a/apps/www/registry/magicui/lens.tsx b/apps/www/registry/magicui/lens.tsx
index b0d27bb5..7f8cdbc2 100644
--- a/apps/www/registry/magicui/lens.tsx
+++ b/apps/www/registry/magicui/lens.tsx
@@ -105,7 +105,7 @@ export function Lens({
</div>
</motion.div>
)
- }, [currentPosition, lensSize, lensColor, zoomFactor, children, duration])
+ }, [currentPosition, maskImage, zoomFactor, children, duration])
return (
<div
diff --git a/apps/www/registry/magicui/particles.tsx b/apps/www/registry/magicui/particles.tsx
index 0768c34b..73e9b24a 100644
--- a/apps/www/registry/magicui/particles.tsx
+++ b/apps/www/registry/magicui/particles.tsx
@@ -99,20 +99,23 @@ export const Particles: React.FC<ParticlesProps> = ({
const dpr = typeof window !== "undefined" ? window.devicePixelRatio : 1
const rafID = useRef<number | null>(null)
const resizeTimeout = useRef<NodeJS.Timeout | null>(null)
+ const initCanvasRef = useRef<() => void>(() => {})
+ const onMouseMoveRef = useRef<() => void>(() => {})
+ const animateRef = useRef<() => void>(() => {})
useEffect(() => {
if (canvasRef.current) {
context.current = canvasRef.current.getContext("2d")
}
- initCanvas()
- animate()
+ initCanvasRef.current()
+ animateRef.current()
const handleResize = () => {
if (resizeTimeout.current) {
clearTimeout(resizeTimeout.current)
}
resizeTimeout.current = setTimeout(() => {
- initCanvas()
+ initCanvasRef.current()
}, 200)
}
@@ -130,11 +133,11 @@ export const Particles: React.FC<ParticlesProps> = ({
}, [color])
useEffect(() => {
- onMouseMove()
+ onMouseMoveRef.current()
}, [mousePosition.x, mousePosition.y])
useEffect(() => {
- initCanvas()
+ initCanvasRef.current()
}, [refresh])
const initCanvas = () => {
@@ -298,9 +301,13 @@ export const Particles: React.FC<ParticlesProps> = ({
drawCircle(newCircle)
}
})
- rafID.current = window.requestAnimationFrame(animate)
+ rafID.current = window.requestAnimationFrame(animateRef.current)
}
+ initCanvasRef.current = initCanvas
+ onMouseMoveRef.current = onMouseMove
+ animateRef.current = animate
+
return (
<div
className={cn("pointer-events-none", className)}
diff --git a/apps/www/registry/magicui/smooth-cursor.tsx b/apps/www/registry/magicui/smooth-cursor.tsx
index a4c4e90c..9b52028f 100644
--- a/apps/www/registry/magicui/smooth-cursor.tsx
+++ b/apps/www/registry/magicui/smooth-cursor.tsx
@@ -1,6 +1,6 @@
"use client"
-import { FC, useEffect, useRef, useState } from "react"
+import { FC, useEffect, useRef } from "react"
import { motion, useSpring } from "motion/react"
interface Position {
@@ -89,7 +89,6 @@ export function SmoothCursor({
restDelta: 0.001,
},
}: SmoothCursorProps) {
- const [isMoving, setIsMoving] = useState(false)
const lastMousePos = useRef<Position>({ x: 0, y: 0 })
const velocity = useRef<Position>({ x: 0, y: 0 })
const lastUpdateTime = useRef(Date.now())
@@ -151,7 +150,6 @@ export function SmoothCursor({
previousAngle.current = currentAngle
scale.set(0.95)
- setIsMoving(true)
if (timeout !== null) {
clearTimeout(timeout)
@@ -159,7 +157,6 @@ export function SmoothCursor({
timeout = setTimeout(() => {
scale.set(1)
- setIsMoving(false)
}, 150)
}
}
diff --git a/apps/www/registry/magicui/terminal.tsx b/apps/www/registry/magicui/terminal.tsx
index 1a39d88e..5349de3a 100644
--- a/apps/www/registry/magicui/terminal.tsx
+++ b/apps/www/registry/magicui/terminal.tsx
@@ -87,7 +87,7 @@ export const AnimatedSpan = ({
if (sequence.activeIndex === itemIndex) {
setHasStarted(true)
}
- }, [sequence?.activeIndex, sequence?.sequenceStarted, hasStarted, itemIndex])
+ }, [sequence, hasStarted, itemIndex])
const shouldAnimate = sequence ? hasStarted : startOnView ? isInView : true
@@ -146,16 +146,24 @@ export const TypingAnimation = ({
const sequence = useSequence()
const itemIndex = useItemIndex()
+ const hasSequence = sequence !== null
+ const sequenceStarted = sequence?.sequenceStarted ?? false
+ const sequenceActiveIndex = sequence?.activeIndex ?? null
+ const sequenceCompleteItemRef = useRef<
+ SequenceContextValue["completeItem"] | null
+ >(null)
+ const sequenceItemIndexRef = useRef<number | null>(null)
+
+ useEffect(() => {
+ sequenceCompleteItemRef.current = sequence?.completeItem ?? null
+ sequenceItemIndexRef.current = itemIndex
+ }, [sequence?.completeItem, itemIndex])
useEffect(() => {
let startTimeout: ReturnType<typeof setTimeout> | null = null
- if (sequence && itemIndex !== null) {
- if (
- sequence.sequenceStarted &&
- !started &&
- sequence.activeIndex === itemIndex
- ) {
+ if (hasSequence && itemIndex !== null) {
+ if (sequenceStarted && !started && sequenceActiveIndex === itemIndex) {
setStarted(true)
}
} else if (!startOnView || isInView) {
@@ -172,8 +180,9 @@ export const TypingAnimation = ({
startOnView,
isInView,
started,
- sequence?.activeIndex,
- sequence?.sequenceStarted,
+ hasSequence,
+ sequenceActiveIndex,
+ sequenceStarted,
itemIndex,
])
@@ -190,8 +199,10 @@ export const TypingAnimation = ({
if (typingEffect !== null) {
clearInterval(typingEffect)
}
- if (sequence && itemIndex !== null) {
- sequence.completeItem(itemIndex)
+ const completeItem = sequenceCompleteItemRef.current
+ const currentItemIndex = sequenceItemIndexRef.current
+ if (completeItem && currentItemIndex !== null) {
+ completeItem(currentItemIndex)
}
}
}, duration)
diff --git a/apps/www/registry/magicui/tweet-card.tsx b/apps/www/registry/magicui/tweet-card.tsx
index e854a1c5..899c5855 100644
--- a/apps/www/registry/magicui/tweet-card.tsx
+++ b/apps/www/registry/magicui/tweet-card.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @next/next/no-img-element */
import { Suspense } from "react"
import { enrichTweet, type EnrichedTweet, type TweetProps } from "react-tweet"
import { getTweet, type Tweet } from "react-tweet/api"