UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
feat(magicCard): extend with optional orb glow layer (#880)
Yeom-JinHo0e41c6b8134b
diff --git a/apps/www/content/docs/components/magic-card.mdx b/apps/www/content/docs/components/magic-card.mdxindex f042f009..5bfaf433 100644--- a/apps/www/content/docs/components/magic-card.mdx+++ b/apps/www/content/docs/components/magic-card.mdx@@ -2,7 +2,7 @@title: Magic Carddate: 2024-07-07description: A spotlight effect that follows your mouse cursor and highlights borders on hover.-author: dillionverma+author: dillionverma, Yeom-JinHopublished: true---@@ -40,6 +40,12 @@ npx shadcn@latest add @magicui/magic-card</Tabs>+## Examples++### Orb++<ComponentPreview name="magic-card-demo-2" />+## Usage```tsx showLineNumbers@@ -59,12 +65,19 @@ import { MagicCard } from "@/components/ui/magic-card"### MagicCard-| Prop name | Type | Default | Description |-| ----------------- | ----------------- | --------- | ------------------------------------------- |-| `children` | `React.ReactNode` | `-` | The content to be rendered inside the card |-| `className` | `string` | `-` | Additional CSS classes to apply to the card |-| `gradientSize` | `number` | `200` | Size of the gradient effect |-| `gradientColor` | `string` | `#262626` | Color of the gradient effect |-| `gradientOpacity` | `number` | `0.8` | Opacity of the gradient effect |-| `gradientFrom` | `string` | `#9E7AFF` | Start color of the gradient border |-| `gradientTo` | `string` | `#FE8BBB` | End color of the gradient border |+| Prop name | Type | Default | Description |+| ----------------- | --------------------- | ------------ | -------------------------------------------------- |+| `children` | `React.ReactNode` | `-` | The content to be rendered inside the card |+| `className` | `string` | `-` | Additional CSS classes to apply to the card |+| `mode` | `"gradient" \| "orb"` | `"gradient"` | Display mode: gradient or orb effect |+| `gradientSize` | `number` | `200` | Size of the gradient effect |+| `gradientColor` | `string` | `#262626` | Color of the gradient effect |+| `gradientOpacity` | `number` | `0.8` | Opacity of the gradient effect |+| `gradientFrom` | `string` | `#9E7AFF` | Start color of the gradient border |+| `gradientTo` | `string` | `#FE8BBB` | End color of the gradient border |+| `glowFrom` | `string` | `#ee4f27` | Start color of the orb glow effect (orb mode only) |+| `glowTo` | `string` | `#6b21ef` | End color of the orb glow effect (orb mode only) |+| `glowAngle` | `number` | `90` | Angle of the orb glow gradient (orb mode only) |+| `glowSize` | `number` | `420` | Size of the orb glow effect (orb mode only) |+| `glowBlur` | `number` | `60` | Blur amount of the orb glow effect (orb mode only) |+| `glowOpacity` | `number` | `0.9` | Opacity of the orb glow effect (orb mode only) |diff --git a/apps/www/public/llms-full.txt b/apps/www/public/llms-full.txtindex 86890804..549356c2 100644--- a/apps/www/public/llms-full.txt+++ b/apps/www/public/llms-full.txt@@ -3300,6 +3300,99 @@ export const AvatarCircles = ({}+===== EXAMPLE: magic-card-demo-2 =====+Title: Magic Card Demo 2++--- file: example/magic-card-demo2.tsx ---+"use client"++import { useEffect, useState } from "react"+import Link from "next/link"+import { useTheme } from "next-themes"++import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardFooter,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { AvatarCircles } from "@/registry/magicui/avatar-circles"+import { MagicCard } from "@/registry/magicui/magic-card"++export default function MagicCardDemo() {+ const { theme, systemTheme } = useTheme()+ const [mounted, setMounted] = useState(false)++ useEffect(() => {+ setMounted(true)+ }, [])++ const isDark = mounted+ ? (theme === "system" ? systemTheme : theme) === "dark"+ : true++ return (+ <Card className="w-full max-w-sm border-none p-0 shadow-none">+ <MagicCard+ mode="orb"+ glowFrom={isDark ? "#ee4f27" : "#E9D5FF"}+ glowTo={isDark ? "#6b21ef" : "#FBCFE8"}+ className="p-0"+ >+ <CardHeader className="border-border border-b p-4 [.border-b]:pb-4">+ <div className="flex items-center gap-3">+ <AvatarCircles+ avatarUrls={[+ {+ imageUrl: "https://avatars.githubusercontent.com/u/81306489",+ profileUrl: "https://github.com/Yeom-JinHo",+ },+ ]}+ />+ <div className="flex-1">+ <CardTitle>Yeom JinHo</CardTitle>+ <CardDescription className="mt-1">+ Frontend Developer+ </CardDescription>+ </div>+ </div>+ </CardHeader>+ <CardContent className="space-y-2 p-4">+ <p className="text-sm font-medium">+ Frontend Developer focused on Interactive UI & Performance+ </p>+ <p className="text-muted-foreground text-sm leading-relaxed">+ I'm passionate about visual presentation and currently focusing+ on interactive UI.+ </p>+ </CardContent>+ <CardFooter className="border-border border-t p-4 [.border-t]:pt-4">+ <Button asChild className="w-full">+ <Link+ href="https://github.com/Yeom-JinHo"+ target="_blank"+ rel="noopener noreferrer"+ className="flex items-center justify-center gap-2"+ >+ <svg viewBox="0 0 438.549 438.549" className="size-4">+ <path+ fill="currentColor"+ d="M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"+ ></path>+ </svg>+ View on GitHub+ </Link>+ </Button>+ </CardFooter>+ </MagicCard>+ </Card>+ )+}++===== EXAMPLE: avatar-circles-demo =====Title: Avatar Circles Demo@@ -9735,73 +9828,128 @@ Description: A spotlight effect that follows your mouse cursor and highlights bo--- file: magicui/magic-card.tsx ---"use client"-import React, { useCallback, useEffect, useRef } from "react"+import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"import {- animate,motion,useMotionTemplate,useMotionValue,+ useSpring,} from "motion/react"+import { useTheme } from "next-themes"import { cn } from "@/lib/utils"-interface MagicCardProps {+interface MagicCardBaseProps {children?: React.ReactNodeclassName?: stringgradientSize?: number- gradientColor?: string- gradientOpacity?: numbergradientFrom?: stringgradientTo?: string}-export function MagicCard({- children,- className,- gradientSize = 200,- gradientColor = "#262626",- gradientOpacity = 0.8,- gradientFrom = "#9E7AFF",- gradientTo = "#FE8BBB",-}: MagicCardProps) {- const ref = useRef<HTMLDivElement>(null)+interface MagicCardGradientProps extends MagicCardBaseProps {+ mode?: "gradient"++ gradientColor?: string+ gradientOpacity?: number++ glowFrom?: never+ glowTo?: never+ glowAngle?: never+ glowSize?: never+ glowBlur?: never+ glowOpacity?: never+}++interface MagicCardOrbProps extends MagicCardBaseProps {+ mode: "orb"++ glowFrom?: string+ glowTo?: string+ glowAngle?: number+ glowSize?: number+ glowBlur?: number+ glowOpacity?: number++ gradientColor?: never+ gradientOpacity?: never+}++type MagicCardProps = MagicCardGradientProps | MagicCardOrbProps+type ResetReason = "enter" | "leave" | "global" | "init"++function isOrbMode(props: MagicCardProps): props is MagicCardOrbProps {+ return props.mode === "orb"+}++export function MagicCard(props: MagicCardProps) {+ const {+ children,+ className,+ gradientSize = 200,+ gradientColor = "#262626",+ gradientOpacity = 0.8,+ gradientFrom = "#9E7AFF",+ gradientTo = "#FE8BBB",+ mode = "gradient",+ } = props++ const glowFrom = isOrbMode(props) ? (props.glowFrom ?? "#ee4f27") : "#ee4f27"+ const glowTo = isOrbMode(props) ? (props.glowTo ?? "#6b21ef") : "#6b21ef"+ const glowAngle = isOrbMode(props) ? (props.glowAngle ?? 90) : 90+ const glowSize = isOrbMode(props) ? (props.glowSize ?? 420) : 420+ const glowBlur = isOrbMode(props) ? (props.glowBlur ?? 60) : 60+ const glowOpacity = isOrbMode(props) ? (props.glowOpacity ?? 0.9) : 0.9+ const { theme, systemTheme } = useTheme()+ const [mounted, setMounted] = useState(false)++ useEffect(() => setMounted(true), [])++ const isDarkTheme = useMemo(() => {+ if (!mounted) return true+ const currentTheme = theme === "system" ? systemTheme : theme+ return currentTheme === "dark"+ }, [theme, systemTheme, mounted])const mouseX = useMotionValue(-gradientSize)const mouseY = useMotionValue(-gradientSize)- const reset = useCallback(() => {- if (!ref.current) return- const rect = ref.current.getBoundingClientRect()- const x = mouseX.get()- const y = mouseY.get()-- const distances = {- left: x,- right: rect.width - x,- top: y,- bottom: rect.height - y,- }+ const orbX = useSpring(mouseX, { stiffness: 250, damping: 30, mass: 0.6 })+ const orbY = useSpring(mouseY, { stiffness: 250, damping: 30, mass: 0.6 })+ const orbVisible = useSpring(0, { stiffness: 300, damping: 35 })- const closestEdge = Object.entries(distances).reduce(- (closest, [edge, distance]) =>- distance < closest.distance ? { edge, distance } : closest,- { edge: "left", distance: distances.left }- ).edge-- switch (closestEdge) {- case "left":- return animate(mouseX, -gradientSize)- case "right":- return animate(mouseX, rect.width + gradientSize)- case "top":- return animate(mouseY, -gradientSize)- case "bottom":- return animate(mouseY, rect.height + gradientSize)- default:- animate(mouseX, -gradientSize)- animate(mouseY, -gradientSize)- }- }, [gradientSize, mouseX, mouseY])+ const modeRef = useRef(mode)+ const glowOpacityRef = useRef(glowOpacity)+ const gradientSizeRef = useRef(gradientSize)++ useEffect(() => {+ modeRef.current = mode+ }, [mode])++ useEffect(() => {+ glowOpacityRef.current = glowOpacity+ }, [glowOpacity])++ useEffect(() => {+ gradientSizeRef.current = gradientSize+ }, [gradientSize])++ const reset = useCallback(+ (reason: ResetReason = "leave") => {+ const currentMode = modeRef.current++ if (currentMode === "orb") {+ if (reason === "enter") orbVisible.set(glowOpacityRef.current)+ else orbVisible.set(0)+ return+ }++ const off = -gradientSizeRef.current+ mouseX.set(off)+ mouseY.set(off)+ },+ [mouseX, mouseY, orbVisible]+ )const handlePointerMove = useCallback((e: React.PointerEvent<HTMLDivElement>) => {@@ -9813,65 +9961,95 @@ export function MagicCard({)useEffect(() => {- reset()+ reset("init")}, [reset])useEffect(() => {const handleGlobalPointerOut = (e: PointerEvent) => {- if (!e.relatedTarget) {- reset()- }+ if (!e.relatedTarget) reset("global")}-+ const handleBlur = () => reset("global")const handleVisibility = () => {- if (document.visibilityState !== "visible") {- reset()- }+ if (document.visibilityState !== "visible") reset("global")}window.addEventListener("pointerout", handleGlobalPointerOut)- window.addEventListener("blur", reset)+ window.addEventListener("blur", handleBlur)document.addEventListener("visibilitychange", handleVisibility)return () => {window.removeEventListener("pointerout", handleGlobalPointerOut)- window.removeEventListener("blur", reset)+ window.removeEventListener("blur", handleBlur)document.removeEventListener("visibilitychange", handleVisibility)}}, [reset])return (- <motion.div- ref={ref}+ <divclassName={cn(- "group relative overflow-hidden rounded-[inherit] border border-transparent",+ "group relative isolate overflow-hidden rounded-[inherit] border border-transparent",className)}onPointerMove={handlePointerMove}- onPointerLeave={reset}- onPointerEnter={reset}- style={{- background: useMotionTemplate`- linear-gradient(var(--color-background) 0 0) padding-box,- radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,- ${gradientFrom},- ${gradientTo},- var(--color-border) 100%- ) border-box- `,- }}+ onPointerLeave={() => reset("leave")}+ onPointerEnter={() => reset("enter")}><motion.div- className="pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100"+ className="bg-border pointer-events-none absolute inset-0 z-10 rounded-[inherit] duration-300 group-hover:opacity-100"style={{background: useMotionTemplate`- radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px, ${gradientColor}, transparent 100%)+ linear-gradient(var(--color-background) 0 0) padding-box,+ radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,+ ${gradientFrom},+ ${gradientTo},+ var(--border) 100%+ )`,- opacity: gradientOpacity,}}/>- <div className="relative">{children}</div>- </motion.div>++ <div className="bg-background absolute inset-px z-20 rounded-[inherit]" />++ {mode === "gradient" && (+ <motion.div+ suppressHydrationWarning+ className="pointer-events-none absolute inset-px z-30 rounded-[inherit] opacity-0 transition-opacity duration-300 group-hover:opacity-100"+ style={{+ background: useMotionTemplate`+ radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,+ ${gradientColor},+ transparent 100%+ )+ `,+ opacity: gradientOpacity,+ }}+ />+ )}++ {mode === "orb" && (+ <motion.div+ suppressHydrationWarning+ aria-hidden="true"+ className="pointer-events-none absolute z-30"+ style={{+ width: glowSize,+ height: glowSize,+ x: orbX,+ y: orbY,+ translateX: "-50%",+ translateY: "-50%",+ borderRadius: 9999,+ filter: `blur(${glowBlur}px)`,+ opacity: orbVisible,+ background: `linear-gradient(${glowAngle}deg, ${glowFrom}, ${glowTo})`,++ mixBlendMode: isDarkTheme ? "screen" : "multiply",+ willChange: "transform, opacity",+ }}+ />+ )}+ <div className="relative z-40">{children}</div>+ </div>)}@@ -9934,6 +10112,99 @@ export default function MagicCardDemo() {}+===== EXAMPLE: magic-card-demo-2 =====+Title: Magic Card Demo 2++--- file: example/magic-card-demo2.tsx ---+"use client"++import { useEffect, useState } from "react"+import Link from "next/link"+import { useTheme } from "next-themes"++import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardFooter,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { AvatarCircles } from "@/registry/magicui/avatar-circles"+import { MagicCard } from "@/registry/magicui/magic-card"++export default function MagicCardDemo() {+ const { theme, systemTheme } = useTheme()+ const [mounted, setMounted] = useState(false)++ useEffect(() => {+ setMounted(true)+ }, [])++ const isDark = mounted+ ? (theme === "system" ? systemTheme : theme) === "dark"+ : true++ return (+ <Card className="w-full max-w-sm border-none p-0 shadow-none">+ <MagicCard+ mode="orb"+ glowFrom={isDark ? "#ee4f27" : "#E9D5FF"}+ glowTo={isDark ? "#6b21ef" : "#FBCFE8"}+ className="p-0"+ >+ <CardHeader className="border-border border-b p-4 [.border-b]:pb-4">+ <div className="flex items-center gap-3">+ <AvatarCircles+ avatarUrls={[+ {+ imageUrl: "https://avatars.githubusercontent.com/u/81306489",+ profileUrl: "https://github.com/Yeom-JinHo",+ },+ ]}+ />+ <div className="flex-1">+ <CardTitle>Yeom JinHo</CardTitle>+ <CardDescription className="mt-1">+ Frontend Developer+ </CardDescription>+ </div>+ </div>+ </CardHeader>+ <CardContent className="space-y-2 p-4">+ <p className="text-sm font-medium">+ Frontend Developer focused on Interactive UI & Performance+ </p>+ <p className="text-muted-foreground text-sm leading-relaxed">+ I'm passionate about visual presentation and currently focusing+ on interactive UI.+ </p>+ </CardContent>+ <CardFooter className="border-border border-t p-4 [.border-t]:pt-4">+ <Button asChild className="w-full">+ <Link+ href="https://github.com/Yeom-JinHo"+ target="_blank"+ rel="noopener noreferrer"+ className="flex items-center justify-center gap-2"+ >+ <svg viewBox="0 0 438.549 438.549" className="size-4">+ <path+ fill="currentColor"+ d="M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"+ ></path>+ </svg>+ View on GitHub+ </Link>+ </Button>+ </CardFooter>+ </MagicCard>+ </Card>+ )+}++===== COMPONENT: marquee =====Title: Marqueediff --git a/apps/www/public/llms.txt b/apps/www/public/llms.txtindex 94f1e90c..7eba6fc9 100644--- a/apps/www/public/llms.txt+++ b/apps/www/public/llms.txt@@ -79,6 +79,7 @@ This file provides LLM-friendly entry points to documentation and examples.## Examples- [Magic Card Demo](https://github.com/magicuidesign/magicui/blob/main/example/magic-card-demo.tsx): Example usage+- [Magic Card Demo 2](https://github.com/magicuidesign/magicui/blob/main/example/magic-card-demo2.tsx): Example usage- [Android Demo](https://github.com/magicuidesign/magicui/blob/main/example/android-demo.tsx): Example usage- [Android Demo 2](https://github.com/magicuidesign/magicui/blob/main/example/android-demo-2.tsx): Example usage- [Android Demo 3](https://github.com/magicuidesign/magicui/blob/main/example/android-demo-3.tsx): Example usagediff --git a/apps/www/public/r/magic-card-demo-2.json b/apps/www/public/r/magic-card-demo-2.jsonnew file mode 100644index 00000000..01d80421--- /dev/null+++ b/apps/www/public/r/magic-card-demo-2.json@@ -0,0 +1,18 @@+{+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",+ "name": "magic-card-demo-2",+ "type": "registry:example",+ "title": "Magic Card Demo 2",+ "description": "Example showing a magic card with an orb effect.",+ "registryDependencies": [+ "@magicui/magic-card",+ "@magicui/avatar-circles"+ ],+ "files": [+ {+ "path": "registry/example/magic-card-demo2.tsx",+ "content": "\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport Link from \"next/link\"\nimport { useTheme } from \"next-themes\"\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 { AvatarCircles } from \"@/registry/magicui/avatar-circles\"\nimport { MagicCard } from \"@/registry/magicui/magic-card\"\n\nexport default function MagicCardDemo() {\n const { theme, systemTheme } = useTheme()\n const [mounted, setMounted] = useState(false)\n\n useEffect(() => {\n setMounted(true)\n }, [])\n\n const isDark = mounted\n ? (theme === \"system\" ? systemTheme : theme) === \"dark\"\n : true\n\n return (\n <Card className=\"w-full max-w-sm border-none p-0 shadow-none\">\n <MagicCard\n mode=\"orb\"\n glowFrom={isDark ? \"#ee4f27\" : \"#E9D5FF\"}\n glowTo={isDark ? \"#6b21ef\" : \"#FBCFE8\"}\n className=\"p-0\"\n >\n <CardHeader className=\"border-border border-b p-4 [.border-b]:pb-4\">\n <div className=\"flex items-center gap-3\">\n <AvatarCircles\n avatarUrls={[\n {\n imageUrl: \"https://avatars.githubusercontent.com/u/81306489\",\n profileUrl: \"https://github.com/Yeom-JinHo\",\n },\n ]}\n />\n <div className=\"flex-1\">\n <CardTitle>Yeom JinHo</CardTitle>\n <CardDescription className=\"mt-1\">\n Frontend Developer\n </CardDescription>\n </div>\n </div>\n </CardHeader>\n <CardContent className=\"space-y-2 p-4\">\n <p className=\"text-sm font-medium\">\n Frontend Developer focused on Interactive UI & Performance\n </p>\n <p className=\"text-muted-foreground text-sm leading-relaxed\">\n I'm passionate about visual presentation and currently focusing\n on interactive UI.\n </p>\n </CardContent>\n <CardFooter className=\"border-border border-t p-4 [.border-t]:pt-4\">\n <Button asChild className=\"w-full\">\n <Link\n href=\"https://github.com/Yeom-JinHo\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center justify-center gap-2\"\n >\n <svg viewBox=\"0 0 438.549 438.549\" className=\"size-4\">\n <path\n fill=\"currentColor\"\n d=\"M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z\"\n ></path>\n </svg>\n View on GitHub\n </Link>\n </Button>\n </CardFooter>\n </MagicCard>\n </Card>\n )\n}\n",+ "type": "registry:example"+ }+ ]+}\ No newline at end of filediff --git a/apps/www/public/r/magic-card.json b/apps/www/public/r/magic-card.jsonindex 56da3be3..035dca47 100644--- a/apps/www/public/r/magic-card.json+++ b/apps/www/public/r/magic-card.json@@ -5,12 +5,13 @@"title": "Magic Card","description": "A spotlight effect that follows your mouse cursor and highlights borders on hover.","dependencies": [- "motion"+ "motion",+ "next-themes"],"files": [{"path": "registry/magicui/magic-card.tsx",- "content": "\"use client\"\n\nimport React, { useCallback, useEffect, useRef } from \"react\"\nimport {\n animate,\n motion,\n useMotionTemplate,\n useMotionValue,\n} from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface MagicCardProps {\n children?: React.ReactNode\n className?: string\n gradientSize?: number\n gradientColor?: string\n gradientOpacity?: number\n gradientFrom?: string\n gradientTo?: string\n}\n\nexport function MagicCard({\n children,\n className,\n gradientSize = 200,\n gradientColor = \"#262626\",\n gradientOpacity = 0.8,\n gradientFrom = \"#9E7AFF\",\n gradientTo = \"#FE8BBB\",\n}: MagicCardProps) {\n const ref = useRef<HTMLDivElement>(null)\n\n const mouseX = useMotionValue(-gradientSize)\n const mouseY = useMotionValue(-gradientSize)\n\n const reset = useCallback(() => {\n if (!ref.current) return\n const rect = ref.current.getBoundingClientRect()\n const x = mouseX.get()\n const y = mouseY.get()\n\n const distances = {\n left: x,\n right: rect.width - x,\n top: y,\n bottom: rect.height - y,\n }\n\n const closestEdge = Object.entries(distances).reduce(\n (closest, [edge, distance]) =>\n distance < closest.distance ? { edge, distance } : closest,\n { edge: \"left\", distance: distances.left }\n ).edge\n\n switch (closestEdge) {\n case \"left\":\n return animate(mouseX, -gradientSize)\n case \"right\":\n return animate(mouseX, rect.width + gradientSize)\n case \"top\":\n return animate(mouseY, -gradientSize)\n case \"bottom\":\n return animate(mouseY, rect.height + gradientSize)\n default:\n animate(mouseX, -gradientSize)\n animate(mouseY, -gradientSize)\n }\n }, [gradientSize, mouseX, mouseY])\n\n const handlePointerMove = useCallback(\n (e: React.PointerEvent<HTMLDivElement>) => {\n const rect = e.currentTarget.getBoundingClientRect()\n mouseX.set(e.clientX - rect.left)\n mouseY.set(e.clientY - rect.top)\n },\n [mouseX, mouseY]\n )\n\n useEffect(() => {\n reset()\n }, [reset])\n\n useEffect(() => {\n const handleGlobalPointerOut = (e: PointerEvent) => {\n if (!e.relatedTarget) {\n reset()\n }\n }\n\n const handleVisibility = () => {\n if (document.visibilityState !== \"visible\") {\n reset()\n }\n }\n\n window.addEventListener(\"pointerout\", handleGlobalPointerOut)\n window.addEventListener(\"blur\", reset)\n document.addEventListener(\"visibilitychange\", handleVisibility)\n\n return () => {\n window.removeEventListener(\"pointerout\", handleGlobalPointerOut)\n window.removeEventListener(\"blur\", reset)\n document.removeEventListener(\"visibilitychange\", handleVisibility)\n }\n }, [reset])\n\n return (\n <motion.div\n ref={ref}\n className={cn(\n \"group relative overflow-hidden rounded-[inherit] border border-transparent\",\n className\n )}\n onPointerMove={handlePointerMove}\n onPointerLeave={reset}\n onPointerEnter={reset}\n style={{\n background: useMotionTemplate`\n linear-gradient(var(--color-background) 0 0) padding-box,\n radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,\n ${gradientFrom}, \n ${gradientTo},\n var(--color-border) 100%\n ) border-box\n `,\n }}\n >\n <motion.div\n className=\"pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100\"\n style={{\n background: useMotionTemplate`\n radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px, ${gradientColor}, transparent 100%)\n `,\n opacity: gradientOpacity,\n }}\n />\n <div className=\"relative\">{children}</div>\n </motion.div>\n )\n}\n",+ "content": "\"use client\"\n\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport {\n motion,\n useMotionTemplate,\n useMotionValue,\n useSpring,\n} from \"motion/react\"\nimport { useTheme } from \"next-themes\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface MagicCardBaseProps {\n children?: React.ReactNode\n className?: string\n gradientSize?: number\n gradientFrom?: string\n gradientTo?: string\n}\n\ninterface MagicCardGradientProps extends MagicCardBaseProps {\n mode?: \"gradient\"\n\n gradientColor?: string\n gradientOpacity?: number\n\n glowFrom?: never\n glowTo?: never\n glowAngle?: never\n glowSize?: never\n glowBlur?: never\n glowOpacity?: never\n}\n\ninterface MagicCardOrbProps extends MagicCardBaseProps {\n mode: \"orb\"\n\n glowFrom?: string\n glowTo?: string\n glowAngle?: number\n glowSize?: number\n glowBlur?: number\n glowOpacity?: number\n\n gradientColor?: never\n gradientOpacity?: never\n}\n\ntype MagicCardProps = MagicCardGradientProps | MagicCardOrbProps\ntype ResetReason = \"enter\" | \"leave\" | \"global\" | \"init\"\n\nfunction isOrbMode(props: MagicCardProps): props is MagicCardOrbProps {\n return props.mode === \"orb\"\n}\n\nexport function MagicCard(props: MagicCardProps) {\n const {\n children,\n className,\n gradientSize = 200,\n gradientColor = \"#262626\",\n gradientOpacity = 0.8,\n gradientFrom = \"#9E7AFF\",\n gradientTo = \"#FE8BBB\",\n mode = \"gradient\",\n } = props\n\n const glowFrom = isOrbMode(props) ? (props.glowFrom ?? \"#ee4f27\") : \"#ee4f27\"\n const glowTo = isOrbMode(props) ? (props.glowTo ?? \"#6b21ef\") : \"#6b21ef\"\n const glowAngle = isOrbMode(props) ? (props.glowAngle ?? 90) : 90\n const glowSize = isOrbMode(props) ? (props.glowSize ?? 420) : 420\n const glowBlur = isOrbMode(props) ? (props.glowBlur ?? 60) : 60\n const glowOpacity = isOrbMode(props) ? (props.glowOpacity ?? 0.9) : 0.9\n const { theme, systemTheme } = useTheme()\n const [mounted, setMounted] = useState(false)\n\n useEffect(() => setMounted(true), [])\n\n const isDarkTheme = useMemo(() => {\n if (!mounted) return true\n const currentTheme = theme === \"system\" ? systemTheme : theme\n return currentTheme === \"dark\"\n }, [theme, systemTheme, mounted])\n\n const mouseX = useMotionValue(-gradientSize)\n const mouseY = useMotionValue(-gradientSize)\n\n const orbX = useSpring(mouseX, { stiffness: 250, damping: 30, mass: 0.6 })\n const orbY = useSpring(mouseY, { stiffness: 250, damping: 30, mass: 0.6 })\n const orbVisible = useSpring(0, { stiffness: 300, damping: 35 })\n\n const modeRef = useRef(mode)\n const glowOpacityRef = useRef(glowOpacity)\n const gradientSizeRef = useRef(gradientSize)\n\n useEffect(() => {\n modeRef.current = mode\n }, [mode])\n\n useEffect(() => {\n glowOpacityRef.current = glowOpacity\n }, [glowOpacity])\n\n useEffect(() => {\n gradientSizeRef.current = gradientSize\n }, [gradientSize])\n\n const reset = useCallback(\n (reason: ResetReason = \"leave\") => {\n const currentMode = modeRef.current\n\n if (currentMode === \"orb\") {\n if (reason === \"enter\") orbVisible.set(glowOpacityRef.current)\n else orbVisible.set(0)\n return\n }\n\n const off = -gradientSizeRef.current\n mouseX.set(off)\n mouseY.set(off)\n },\n [mouseX, mouseY, orbVisible]\n )\n\n const handlePointerMove = useCallback(\n (e: React.PointerEvent<HTMLDivElement>) => {\n const rect = e.currentTarget.getBoundingClientRect()\n mouseX.set(e.clientX - rect.left)\n mouseY.set(e.clientY - rect.top)\n },\n [mouseX, mouseY]\n )\n\n useEffect(() => {\n reset(\"init\")\n }, [reset])\n\n useEffect(() => {\n const handleGlobalPointerOut = (e: PointerEvent) => {\n if (!e.relatedTarget) reset(\"global\")\n }\n const handleBlur = () => reset(\"global\")\n const handleVisibility = () => {\n if (document.visibilityState !== \"visible\") reset(\"global\")\n }\n\n window.addEventListener(\"pointerout\", handleGlobalPointerOut)\n window.addEventListener(\"blur\", handleBlur)\n document.addEventListener(\"visibilitychange\", handleVisibility)\n\n return () => {\n window.removeEventListener(\"pointerout\", handleGlobalPointerOut)\n window.removeEventListener(\"blur\", handleBlur)\n document.removeEventListener(\"visibilitychange\", handleVisibility)\n }\n }, [reset])\n\n return (\n <div\n className={cn(\n \"group relative isolate overflow-hidden rounded-[inherit] border border-transparent\",\n className\n )}\n onPointerMove={handlePointerMove}\n onPointerLeave={() => reset(\"leave\")}\n onPointerEnter={() => reset(\"enter\")}\n >\n <motion.div\n className=\"bg-border pointer-events-none absolute inset-0 z-10 rounded-[inherit] duration-300 group-hover:opacity-100\"\n style={{\n background: useMotionTemplate`\n linear-gradient(var(--color-background) 0 0) padding-box,\n radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,\n ${gradientFrom}, \n ${gradientTo}, \n var(--border) 100%\n )\n `,\n }}\n />\n\n <div className=\"bg-background absolute inset-px z-20 rounded-[inherit]\" />\n\n {mode === \"gradient\" && (\n <motion.div\n suppressHydrationWarning\n className=\"pointer-events-none absolute inset-px z-30 rounded-[inherit] opacity-0 transition-opacity duration-300 group-hover:opacity-100\"\n style={{\n background: useMotionTemplate`\n radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,\n ${gradientColor},\n transparent 100%\n )\n `,\n opacity: gradientOpacity,\n }}\n />\n )}\n\n {mode === \"orb\" && (\n <motion.div\n suppressHydrationWarning\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute z-30\"\n style={{\n width: glowSize,\n height: glowSize,\n x: orbX,\n y: orbY,\n translateX: \"-50%\",\n translateY: \"-50%\",\n borderRadius: 9999,\n filter: `blur(${glowBlur}px)`,\n opacity: orbVisible,\n background: `linear-gradient(${glowAngle}deg, ${glowFrom}, ${glowTo})`,\n\n mixBlendMode: isDarkTheme ? \"screen\" : \"multiply\",\n willChange: \"transform, opacity\",\n }}\n />\n )}\n <div className=\"relative z-40\">{children}</div>\n </div>\n )\n}\n","type": "registry:ui"}]diff --git a/apps/www/public/r/registry.json b/apps/www/public/r/registry.jsonindex 1a7c6ec9..955a61f6 100644--- a/apps/www/public/r/registry.json+++ b/apps/www/public/r/registry.json@@ -24,7 +24,8 @@"title": "Magic Card","description": "A spotlight effect that follows your mouse cursor and highlights borders on hover.","dependencies": [- "motion"+ "motion",+ "next-themes"],"files": [{@@ -1275,6 +1276,22 @@}]},+ {+ "name": "magic-card-demo-2",+ "type": "registry:example",+ "title": "Magic Card Demo 2",+ "description": "Example showing a magic card with an orb effect.",+ "registryDependencies": [+ "@magicui/magic-card",+ "@magicui/avatar-circles"+ ],+ "files": [+ {+ "path": "registry/example/magic-card-demo2.tsx",+ "type": "registry:example"+ }+ ]+ },{"name": "android-demo","type": "registry:example",diff --git a/apps/www/public/registry.json b/apps/www/public/registry.jsonindex 1a7c6ec9..955a61f6 100644--- a/apps/www/public/registry.json+++ b/apps/www/public/registry.json@@ -24,7 +24,8 @@"title": "Magic Card","description": "A spotlight effect that follows your mouse cursor and highlights borders on hover.","dependencies": [- "motion"+ "motion",+ "next-themes"],"files": [{@@ -1275,6 +1276,22 @@}]},+ {+ "name": "magic-card-demo-2",+ "type": "registry:example",+ "title": "Magic Card Demo 2",+ "description": "Example showing a magic card with an orb effect.",+ "registryDependencies": [+ "@magicui/magic-card",+ "@magicui/avatar-circles"+ ],+ "files": [+ {+ "path": "registry/example/magic-card-demo2.tsx",+ "type": "registry:example"+ }+ ]+ },{"name": "android-demo","type": "registry:example",diff --git a/apps/www/registry.json b/apps/www/registry.jsonindex 1a7c6ec9..955a61f6 100644--- a/apps/www/registry.json+++ b/apps/www/registry.json@@ -24,7 +24,8 @@"title": "Magic Card","description": "A spotlight effect that follows your mouse cursor and highlights borders on hover.","dependencies": [- "motion"+ "motion",+ "next-themes"],"files": [{@@ -1275,6 +1276,22 @@}]},+ {+ "name": "magic-card-demo-2",+ "type": "registry:example",+ "title": "Magic Card Demo 2",+ "description": "Example showing a magic card with an orb effect.",+ "registryDependencies": [+ "@magicui/magic-card",+ "@magicui/avatar-circles"+ ],+ "files": [+ {+ "path": "registry/example/magic-card-demo2.tsx",+ "type": "registry:example"+ }+ ]+ },{"name": "android-demo","type": "registry:example",diff --git a/apps/www/registry/__index__.tsx b/apps/www/registry/__index__.tsxindex 236425b6..333165ef 100644--- a/apps/www/registry/__index__.tsx+++ b/apps/www/registry/__index__.tsx@@ -1205,6 +1205,23 @@ export const Index: Record<string, any> = {}),meta: undefined,},+ "magic-card-demo-2": {+ name: "magic-card-demo-2",+ description: "Example showing a magic card with an orb effect.",+ type: "registry:example",+ registryDependencies: ["@magicui/magic-card","@magicui/avatar-circles"],+ files: [{+ path: "registry/example/magic-card-demo2.tsx",+ type: "registry:example",+ target: ""+ }],+ component: React.lazy(async () => {+ const mod = await import("@/registry/example/magic-card-demo2.tsx")+ const exportName = Object.keys(mod).find(key => typeof mod[key] === 'function' || typeof mod[key] === 'object') ?? item.name+ return { default: mod.default ?? mod[exportName] }+ }),+ meta: undefined,+ },"android-demo": {name: "android-demo",description: "Example showing a mockup of an Android device.",diff --git a/apps/www/registry/example/magic-card-demo2.tsx b/apps/www/registry/example/magic-card-demo2.tsxnew file mode 100644index 00000000..460bf73a--- /dev/null+++ b/apps/www/registry/example/magic-card-demo2.tsx@@ -0,0 +1,87 @@+"use client"++import { useEffect, useState } from "react"+import Link from "next/link"+import { useTheme } from "next-themes"++import { Button } from "@/components/ui/button"+import {+ Card,+ CardContent,+ CardDescription,+ CardFooter,+ CardHeader,+ CardTitle,+} from "@/components/ui/card"+import { AvatarCircles } from "@/registry/magicui/avatar-circles"+import { MagicCard } from "@/registry/magicui/magic-card"++export default function MagicCardDemo() {+ const { theme, systemTheme } = useTheme()+ const [mounted, setMounted] = useState(false)++ useEffect(() => {+ setMounted(true)+ }, [])++ const isDark = mounted+ ? (theme === "system" ? systemTheme : theme) === "dark"+ : true++ return (+ <Card className="w-full max-w-sm border-none p-0 shadow-none">+ <MagicCard+ mode="orb"+ glowFrom={isDark ? "#ee4f27" : "#E9D5FF"}+ glowTo={isDark ? "#6b21ef" : "#FBCFE8"}+ className="p-0"+ >+ <CardHeader className="border-border border-b p-4 [.border-b]:pb-4">+ <div className="flex items-center gap-3">+ <AvatarCircles+ avatarUrls={[+ {+ imageUrl: "https://avatars.githubusercontent.com/u/81306489",+ profileUrl: "https://github.com/Yeom-JinHo",+ },+ ]}+ />+ <div className="flex-1">+ <CardTitle>Yeom JinHo</CardTitle>+ <CardDescription className="mt-1">+ Frontend Developer+ </CardDescription>+ </div>+ </div>+ </CardHeader>+ <CardContent className="space-y-2 p-4">+ <p className="text-sm font-medium">+ Frontend Developer focused on Interactive UI & Performance+ </p>+ <p className="text-muted-foreground text-sm leading-relaxed">+ I'm passionate about visual presentation and currently focusing+ on interactive UI.+ </p>+ </CardContent>+ <CardFooter className="border-border border-t p-4 [.border-t]:pt-4">+ <Button asChild className="w-full">+ <Link+ href="https://github.com/Yeom-JinHo"+ target="_blank"+ rel="noopener noreferrer"+ className="flex items-center justify-center gap-2"+ >+ <svg viewBox="0 0 438.549 438.549" className="size-4">+ <path+ fill="currentColor"+ d="M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"+ ></path>+ </svg>+ View on GitHub+ </Link>+ </Button>+ </CardFooter>+ </MagicCard>+ </Card>+ )+}diff --git a/apps/www/registry/magicui/magic-card.tsx b/apps/www/registry/magicui/magic-card.tsxindex 5b1c5ed7..f62d345f 100644--- a/apps/www/registry/magicui/magic-card.tsx+++ b/apps/www/registry/magicui/magic-card.tsx@@ -1,72 +1,127 @@"use client"-import React, { useCallback, useEffect, useRef } from "react"+import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"import {- animate,motion,useMotionTemplate,useMotionValue,+ useSpring,} from "motion/react"+import { useTheme } from "next-themes"import { cn } from "@/lib/utils"-interface MagicCardProps {+interface MagicCardBaseProps {children?: React.ReactNodeclassName?: stringgradientSize?: number- gradientColor?: string- gradientOpacity?: numbergradientFrom?: stringgradientTo?: string}-export function MagicCard({- children,- className,- gradientSize = 200,- gradientColor = "#262626",- gradientOpacity = 0.8,- gradientFrom = "#9E7AFF",- gradientTo = "#FE8BBB",-}: MagicCardProps) {- const ref = useRef<HTMLDivElement>(null)+interface MagicCardGradientProps extends MagicCardBaseProps {+ mode?: "gradient"++ gradientColor?: string+ gradientOpacity?: number++ glowFrom?: never+ glowTo?: never+ glowAngle?: never+ glowSize?: never+ glowBlur?: never+ glowOpacity?: never+}++interface MagicCardOrbProps extends MagicCardBaseProps {+ mode: "orb"++ glowFrom?: string+ glowTo?: string+ glowAngle?: number+ glowSize?: number+ glowBlur?: number+ glowOpacity?: number++ gradientColor?: never+ gradientOpacity?: never+}++type MagicCardProps = MagicCardGradientProps | MagicCardOrbProps+type ResetReason = "enter" | "leave" | "global" | "init"++function isOrbMode(props: MagicCardProps): props is MagicCardOrbProps {+ return props.mode === "orb"+}++export function MagicCard(props: MagicCardProps) {+ const {+ children,+ className,+ gradientSize = 200,+ gradientColor = "#262626",+ gradientOpacity = 0.8,+ gradientFrom = "#9E7AFF",+ gradientTo = "#FE8BBB",+ mode = "gradient",+ } = props++ const glowFrom = isOrbMode(props) ? (props.glowFrom ?? "#ee4f27") : "#ee4f27"+ const glowTo = isOrbMode(props) ? (props.glowTo ?? "#6b21ef") : "#6b21ef"+ const glowAngle = isOrbMode(props) ? (props.glowAngle ?? 90) : 90+ const glowSize = isOrbMode(props) ? (props.glowSize ?? 420) : 420+ const glowBlur = isOrbMode(props) ? (props.glowBlur ?? 60) : 60+ const glowOpacity = isOrbMode(props) ? (props.glowOpacity ?? 0.9) : 0.9+ const { theme, systemTheme } = useTheme()+ const [mounted, setMounted] = useState(false)++ useEffect(() => setMounted(true), [])++ const isDarkTheme = useMemo(() => {+ if (!mounted) return true+ const currentTheme = theme === "system" ? systemTheme : theme+ return currentTheme === "dark"+ }, [theme, systemTheme, mounted])const mouseX = useMotionValue(-gradientSize)const mouseY = useMotionValue(-gradientSize)- const reset = useCallback(() => {- if (!ref.current) return- const rect = ref.current.getBoundingClientRect()- const x = mouseX.get()- const y = mouseY.get()-- const distances = {- left: x,- right: rect.width - x,- top: y,- bottom: rect.height - y,- }+ const orbX = useSpring(mouseX, { stiffness: 250, damping: 30, mass: 0.6 })+ const orbY = useSpring(mouseY, { stiffness: 250, damping: 30, mass: 0.6 })+ const orbVisible = useSpring(0, { stiffness: 300, damping: 35 })- const closestEdge = Object.entries(distances).reduce(- (closest, [edge, distance]) =>- distance < closest.distance ? { edge, distance } : closest,- { edge: "left", distance: distances.left }- ).edge-- switch (closestEdge) {- case "left":- return animate(mouseX, -gradientSize)- case "right":- return animate(mouseX, rect.width + gradientSize)- case "top":- return animate(mouseY, -gradientSize)- case "bottom":- return animate(mouseY, rect.height + gradientSize)- default:- animate(mouseX, -gradientSize)- animate(mouseY, -gradientSize)- }- }, [gradientSize, mouseX, mouseY])+ const modeRef = useRef(mode)+ const glowOpacityRef = useRef(glowOpacity)+ const gradientSizeRef = useRef(gradientSize)++ useEffect(() => {+ modeRef.current = mode+ }, [mode])++ useEffect(() => {+ glowOpacityRef.current = glowOpacity+ }, [glowOpacity])++ useEffect(() => {+ gradientSizeRef.current = gradientSize+ }, [gradientSize])++ const reset = useCallback(+ (reason: ResetReason = "leave") => {+ const currentMode = modeRef.current++ if (currentMode === "orb") {+ if (reason === "enter") orbVisible.set(glowOpacityRef.current)+ else orbVisible.set(0)+ return+ }++ const off = -gradientSizeRef.current+ mouseX.set(off)+ mouseY.set(off)+ },+ [mouseX, mouseY, orbVisible]+ )const handlePointerMove = useCallback((e: React.PointerEvent<HTMLDivElement>) => {@@ -78,64 +133,94 @@ export function MagicCard({)useEffect(() => {- reset()+ reset("init")}, [reset])useEffect(() => {const handleGlobalPointerOut = (e: PointerEvent) => {- if (!e.relatedTarget) {- reset()- }+ if (!e.relatedTarget) reset("global")}-+ const handleBlur = () => reset("global")const handleVisibility = () => {- if (document.visibilityState !== "visible") {- reset()- }+ if (document.visibilityState !== "visible") reset("global")}window.addEventListener("pointerout", handleGlobalPointerOut)- window.addEventListener("blur", reset)+ window.addEventListener("blur", handleBlur)document.addEventListener("visibilitychange", handleVisibility)return () => {window.removeEventListener("pointerout", handleGlobalPointerOut)- window.removeEventListener("blur", reset)+ window.removeEventListener("blur", handleBlur)document.removeEventListener("visibilitychange", handleVisibility)}}, [reset])return (- <motion.div- ref={ref}+ <divclassName={cn(- "group relative overflow-hidden rounded-[inherit] border border-transparent",+ "group relative isolate overflow-hidden rounded-[inherit] border border-transparent",className)}onPointerMove={handlePointerMove}- onPointerLeave={reset}- onPointerEnter={reset}- style={{- background: useMotionTemplate`- linear-gradient(var(--color-background) 0 0) padding-box,- radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,- ${gradientFrom},- ${gradientTo},- var(--color-border) 100%- ) border-box- `,- }}+ onPointerLeave={() => reset("leave")}+ onPointerEnter={() => reset("enter")}><motion.div- className="pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100"+ className="bg-border pointer-events-none absolute inset-0 z-10 rounded-[inherit] duration-300 group-hover:opacity-100"style={{background: useMotionTemplate`- radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px, ${gradientColor}, transparent 100%)+ linear-gradient(var(--color-background) 0 0) padding-box,+ radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,+ ${gradientFrom},+ ${gradientTo},+ var(--border) 100%+ )`,- opacity: gradientOpacity,}}/>- <div className="relative">{children}</div>- </motion.div>++ <div className="bg-background absolute inset-px z-20 rounded-[inherit]" />++ {mode === "gradient" && (+ <motion.div+ suppressHydrationWarning+ className="pointer-events-none absolute inset-px z-30 rounded-[inherit] opacity-0 transition-opacity duration-300 group-hover:opacity-100"+ style={{+ background: useMotionTemplate`+ radial-gradient(${gradientSize}px circle at ${mouseX}px ${mouseY}px,+ ${gradientColor},+ transparent 100%+ )+ `,+ opacity: gradientOpacity,+ }}+ />+ )}++ {mode === "orb" && (+ <motion.div+ suppressHydrationWarning+ aria-hidden="true"+ className="pointer-events-none absolute z-30"+ style={{+ width: glowSize,+ height: glowSize,+ x: orbX,+ y: orbY,+ translateX: "-50%",+ translateY: "-50%",+ borderRadius: 9999,+ filter: `blur(${glowBlur}px)`,+ opacity: orbVisible,+ background: `linear-gradient(${glowAngle}deg, ${glowFrom}, ${glowTo})`,++ mixBlendMode: isDarkTheme ? "screen" : "multiply",+ willChange: "transform, opacity",+ }}+ />+ )}+ <div className="relative z-40">{children}</div>+ </div>)}diff --git a/apps/www/registry/registry-examples.ts b/apps/www/registry/registry-examples.tsindex 9ea1736e..5dd95b72 100644--- a/apps/www/registry/registry-examples.ts+++ b/apps/www/registry/registry-examples.ts@@ -15,6 +15,19 @@ export const examples: Registry["items"] = [},],},+ {+ name: "magic-card-demo-2",+ type: "registry:example",+ title: "Magic Card Demo 2",+ description: "Example showing a magic card with an orb effect.",+ registryDependencies: ["@magicui/magic-card", "@magicui/avatar-circles"],+ files: [+ {+ path: "example/magic-card-demo2.tsx",+ type: "registry:example",+ },+ ],+ },{name: "android-demo",type: "registry:example",diff --git a/apps/www/registry/registry-ui.ts b/apps/www/registry/registry-ui.tsindex c7cadab2..9f30e55c 100644--- a/apps/www/registry/registry-ui.ts+++ b/apps/www/registry/registry-ui.ts@@ -7,7 +7,7 @@ export const ui: Registry["items"] = [title: "Magic Card",description:"A spotlight effect that follows your mouse cursor and highlights borders on hover.",- dependencies: ["motion"],+ dependencies: ["motion", "next-themes"],files: [{path: "magicui/magic-card.tsx",