{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"glare-card","type":"registry:ui","title":"GlareCard","description":"Holographic trading card effect with mouse-tracking glare and rainbow foil","author":"fancy-ui <https://fancy-ui.rama.app>","categories":["cards"],"registryDependencies":["https://fancy-ui.rama.app/r/utils.json"],"files":[{"path":"react/src/components/glare-card/GlareCard.tsx","content":"\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport type { CSSProperties, PointerEvent, ReactNode } from \"react\";\n\nimport { cn } from \"../../utils\";\nimport \"./glare-card.css\";\n\nexport interface GlareCardProps {\n\t/** Additional CSS classes for the card content wrapper. */\n\tclassName?: string;\n\t/** Card content. */\n\tchildren?: ReactNode;\n}\n\ninterface Point {\n\tx: number;\n\ty: number;\n}\n\n/**\n * The full inline custom-property string, rebuilt wholesale on every pointer\n * move and on pointer leave — mirroring the Svelte source, where the style\n * attribute is a single derived string re-rendered whenever glare/rotate/\n * background state changes (which also clobbers the enter-timeout's\n * `--duration: 0s` override on the next move, exactly as the source does).\n */\nfunction cssVars(glare: Point, rotate: Point, background: Point): string {\n\treturn `--m-x:${glare.x}%;--m-y:${glare.y}%;--r-x:${rotate.x}deg;--r-y:${rotate.y}deg;--bg-x:${background.x}%;--bg-y:${background.y}%;--duration:300ms;--foil-size:100%;--opacity:0;--radius:48px;--easing:ease;--transition:var(--duration) var(--easing);`;\n}\n\nconst initialStyle = {\n\t\"--m-x\": \"50%\",\n\t\"--m-y\": \"50%\",\n\t\"--r-x\": \"0deg\",\n\t\"--r-y\": \"0deg\",\n\t\"--bg-x\": \"50%\",\n\t\"--bg-y\": \"50%\",\n\t\"--duration\": \"300ms\",\n\t\"--foil-size\": \"100%\",\n\t\"--opacity\": \"0\",\n\t\"--radius\": \"48px\",\n\t\"--easing\": \"ease\",\n\t\"--transition\": \"var(--duration) var(--easing)\",\n} as CSSProperties;\n\nexport function GlareCard({ className = \"\", children }: GlareCardProps) {\n\tconst refElement = useRef<HTMLDivElement | null>(null);\n\tconst isPointerInside = useRef(false);\n\tconst timeoutId = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n\t// Per-frame values that only drive the style attribute — never state.\n\tconst glare = useRef<Point>({ x: 50, y: 50 });\n\tconst background = useRef<Point>({ x: 50, y: 50 });\n\tconst rotate = useRef<Point>({ x: 0, y: 0 });\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (timeoutId.current) clearTimeout(timeoutId.current);\n\t\t};\n\t}, []);\n\n\tfunction writeVars() {\n\t\trefElement.current?.setAttribute(\n\t\t\t\"style\",\n\t\t\tcssVars(glare.current, rotate.current, background.current)\n\t\t);\n\t}\n\n\tfunction handlePointerMove(event: PointerEvent<HTMLDivElement>) {\n\t\tconst rotateFactor = 0.4;\n\t\tconst rect = refElement.current?.getBoundingClientRect();\n\t\tif (rect) {\n\t\t\tconst position = {\n\t\t\t\tx: event.clientX - rect.left,\n\t\t\t\ty: event.clientY - rect.top,\n\t\t\t};\n\t\t\tconst percentage = {\n\t\t\t\tx: (100 / rect.width) * position.x,\n\t\t\t\ty: (100 / rect.height) * position.y,\n\t\t\t};\n\t\t\tconst delta = {\n\t\t\t\tx: percentage.x - 50,\n\t\t\t\ty: percentage.y - 50,\n\t\t\t};\n\t\t\tbackground.current.x = 50 + percentage.x / 4 - 12.5;\n\t\t\tbackground.current.y = 50 + percentage.y / 3 - 16.67;\n\t\t\trotate.current.x = -(delta.x / 3.5) * rotateFactor;\n\t\t\trotate.current.y = (delta.y / 2) * rotateFactor;\n\t\t\tglare.current.x = percentage.x;\n\t\t\tglare.current.y = percentage.y;\n\t\t\twriteVars();\n\t\t}\n\t}\n\n\tfunction handlePointerEnter() {\n\t\tisPointerInside.current = true;\n\t\tif (timeoutId.current) clearTimeout(timeoutId.current);\n\t\ttimeoutId.current = setTimeout(() => {\n\t\t\tif (isPointerInside.current && refElement.current) {\n\t\t\t\trefElement.current.style.setProperty(\"--duration\", \"0s\");\n\t\t\t}\n\t\t}, 300);\n\t}\n\n\tfunction handlePointerLeave() {\n\t\tisPointerInside.current = false;\n\t\tif (timeoutId.current) clearTimeout(timeoutId.current);\n\t\tif (refElement.current) {\n\t\t\trefElement.current.style.removeProperty(\"--duration\");\n\t\t\trotate.current = { x: 0, y: 0 };\n\t\t\twriteVars();\n\t\t}\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={refElement}\n\t\t\tclassName=\"glare-container relative isolate [aspect-ratio:17/21] w-[320px] motion-safe:delay-[var(--delay)] motion-safe:duration-[var(--duration)] ease-[var(--easing)] will-change-transform [contain:layout_style] [perspective:600px] motion-safe:transition-transform\"\n\t\t\tstyle={initialStyle}\n\t\t\tonPointerMove={handlePointerMove}\n\t\t\tonPointerEnter={handlePointerEnter}\n\t\t\tonPointerLeave={handlePointerLeave}\n\t\t>\n\t\t\t<div className=\"grid h-full origin-center [transform:rotateY(var(--r-x))_rotateX(var(--r-y))] overflow-hidden rounded-lg border border-slate-800 motion-safe:delay-[var(--delay)] motion-safe:duration-[var(--duration)] ease-[var(--easing)] will-change-transform hover:filter-none hover:[--duration:200ms] hover:[--easing:linear] hover:[--opacity:0.6] motion-safe:transition-transform\">\n\t\t\t\t<div className=\"grid size-full mix-blend-soft-light [clip-path:inset(0_0_0_0_round_var(--radius))] [grid-area:1/1]\">\n\t\t\t\t\t<div className={cn(\"size-full bg-slate-950\", className)}>{children}</div>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"will-change-background grid size-full opacity-[var(--opacity)] mix-blend-soft-light motion-safe:delay-[var(--delay)] motion-safe:duration-[var(--duration)] ease-[var(--easing)] [background:radial-gradient(farthest-corner_circle_at_var(--m-x)_var(--m-y),_rgba(255,255,255,0.8)_10%,_rgba(255,255,255,0.65)_20%,_rgba(255,255,255,0)_90%)] [clip-path:inset(0_0_1px_0_round_var(--radius))] [grid-area:1/1] motion-safe:transition-opacity\"></div>\n\t\t\t\t<div className=\"glare-foil relative grid size-full opacity-[var(--opacity)] [background-blend-mode:hue_hue_hue_overlay] mix-blend-color-dodge will-change-[background] [background:var(--pattern),_var(--rainbow),_var(--diagonal),_var(--shade)] [clip-path:inset(0_0_1px_0_round_var(--radius))] [grid-area:1/1] after:bg-[inherit] after:[background-size:var(--foil-size),_200%_400%,_800%,_200%] after:[background-position:center,_0%_var(--bg-y),_calc(var(--bg-x)*_-1)_calc(var(--bg-y)*_-1),_var(--bg-x)_var(--bg-y)] after:[background-blend-mode:soft-light,_hue,_hard-light] after:mix-blend-exclusion after:content-[''] after:[grid-area:1/1] motion-safe:transition-opacity\"></div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n","type":"registry:ui","target":"@ui/fancy/components/glare-card/GlareCard.tsx"},{"path":"react/src/components/glare-card/glare-card.css","content":"/*\n * Ported from the Svelte <style> block. The Svelte compiler scoped this rule;\n * plain CSS is global, so the selector is anchored under the component's root\n * class (.glare-container) — port-added anchor, .glare-foil is always inside it.\n */\n.glare-container .glare-foil {\n\t--step: 5%;\n\t--foil-svg: url(\"data:image/svg+xml,%3Csvg width='26' height='26' viewBox='0 0 26 26' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.99994 3.419C2.99994 3.419 21.6142 7.43646 22.7921 12.153C23.97 16.8695 3.41838 23.0306 3.41838 23.0306' stroke='white' stroke-width='5' stroke-miterlimit='3.86874' stroke-linecap='round' style='mix-blend-mode:darken'/%3E%3C/svg%3E\");\n\t--pattern: var(--foil-svg) center/100% no-repeat;\n\t--rainbow: repeating-linear-gradient(\n\t\t\t0deg,\n\t\t\trgb(255, 119, 115) calc(var(--step) * 1),\n\t\t\trgba(255, 237, 95, 1) calc(var(--step) * 2),\n\t\t\trgba(168, 255, 95, 1) calc(var(--step) * 3),\n\t\t\trgba(131, 255, 247, 1) calc(var(--step) * 4),\n\t\t\trgba(120, 148, 255, 1) calc(var(--step) * 5),\n\t\t\trgb(216, 117, 255) calc(var(--step) * 6),\n\t\t\trgb(255, 119, 115) calc(var(--step) * 7)\n\t\t)\n\t\t0% var(--bg-y) / 200% 700% no-repeat;\n\t--diagonal: repeating-linear-gradient(\n\t\t\t128deg,\n\t\t\t#0e152e 0%,\n\t\t\thsl(180, 10%, 60%) 3.8%,\n\t\t\thsl(180, 10%, 60%) 4.5%,\n\t\t\thsl(180, 10%, 60%) 5.2%,\n\t\t\t#0e152e 10%,\n\t\t\t#0e152e 12%\n\t\t)\n\t\tvar(--bg-x) var(--bg-y) / 300% no-repeat;\n\t--shade: radial-gradient(\n\t\t\tfarthest-corner circle at var(--m-x) var(--m-y),\n\t\t\trgba(255, 255, 255, 0.1) 12%,\n\t\t\trgba(255, 255, 255, 0.15) 20%,\n\t\t\trgba(255, 255, 255, 0.25) 120%\n\t\t)\n\t\tvar(--bg-x) var(--bg-y) / 300% no-repeat;\n\tbackground-blend-mode: hue, hue, hue, overlay;\n}\n","type":"registry:ui","target":"@ui/fancy/components/glare-card/glare-card.css"},{"path":"react/src/components/glare-card/index.ts","content":"\"use client\";\n\nexport { GlareCard } from \"./GlareCard\";\nexport type { GlareCardProps } from \"./GlareCard\";\n","type":"registry:ui","target":"@ui/fancy/components/glare-card/index.ts"}],"meta":{"license":"MIT","package":"fancy-ui-react","version":"0.7.0","source":"https://fancy-ui.rama.app/docs/components/glare-card?framework=react"}}