Skip to content

Commit 9d6bbee

Browse files
committed
add glow-conic
1 parent a639ff9 commit 9d6bbee

9 files changed

Lines changed: 103 additions & 17 deletions

File tree

public/build/assets/app-UslHHovD.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/assets/app-ayw7E--E.css

Lines changed: 0 additions & 2 deletions
This file was deleted.

public/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
"src": "node_modules/@fontsource/bebas-neue/files/bebas-neue-latin-ext-400-normal.woff2"
189189
},
190190
"resources/css/app.css": {
191-
"file": "assets/app-ayw7E--E.css",
191+
"file": "assets/app-UslHHovD.css",
192192
"name": "app",
193193
"names": [
194194
"app.css"

public/r/glow-conic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"cssVars": {
2222
"theme": {
2323
"--conic-color": "var(--color-primary)",
24-
"--animate-glow-conic": "glow-conic 3s ease-in-out"
24+
"--animate-glow-conic": "glow-conic 3s linear infinite"
2525
}
2626
},
2727
"css": {

public/r/registry.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3190,7 +3190,7 @@
31903190
"cssVars": {
31913191
"theme": {
31923192
"--conic-color": "var(--color-primary)",
3193-
"--animate-glow-conic": "glow-conic 3s ease-in-out"
3193+
"--animate-glow-conic": "glow-conic 3s linear infinite"
31943194
}
31953195
},
31963196
"css": {

registry.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3190,7 +3190,7 @@
31903190
"cssVars": {
31913191
"theme": {
31923192
"--conic-color": "var(--color-primary)",
3193-
"--animate-glow-conic": "glow-conic 3s ease-in-out"
3193+
"--animate-glow-conic": "glow-conic 3s linear infinite"
31943194
}
31953195
},
31963196
"css": {

resources/css/app.css

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,11 @@
248248
--animate-tilt: tilt 1.5s ease-in-out infinite alternate;
249249
--font-bebas-neue: 'Bebas Neue', sans-serif;
250250
--font-playfair-display: 'Playfair Display Variable', sans-serif;
251-
--animate-glow-conic: glow-conic 5s linear infinite;
252-
}
253251

254-
@layer utilities {
255252

253+
}
256254

257-
@keyframes glow-conic {
258-
0% {
259-
--glow-conic-angle: 0deg;
260-
}
261-
100% {
262-
--glow-conic-angle: 360deg;
263-
}
264-
}
255+
@layer utilities {
265256

266257
@keyframes bounce {
267258
0%, 20%, 50%, 80%, 100% {
@@ -1584,4 +1575,6 @@
15841575
transform: perspective(400px) rotateY(15deg);
15851576
}
15861577
}
1578+
1579+
15871580
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useEffect } from 'react';
2+
import { cn } from '@/lib/utils';
3+
4+
export interface GlowConicProps {
5+
className?: string;
6+
[key: string]: unknown;
7+
}
8+
9+
export default function GlowConic({ className, ...props }: GlowConicProps) {
10+
useEffect(() => {
11+
if (typeof CSS !== 'undefined' && CSS.registerProperty) {
12+
CSS.registerProperty({
13+
name: '--glow-conic-angle',
14+
syntax: '<angle>',
15+
initialValue: '0deg',
16+
inherits: false,
17+
});
18+
}
19+
}, []);
20+
21+
return (
22+
<div
23+
{...props}
24+
className={cn(
25+
'absolute inset-0 animate-glow-conic rounded-[inherit] p-px',
26+
className,
27+
)}
28+
style={{
29+
background:
30+
'repeating-conic-gradient(from var(--glow-conic-angle), transparent 10%, var(--conic-color) 20%, transparent 50%)',
31+
mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0) border-box',
32+
maskComposite: 'exclude' as const,
33+
WebkitMask:
34+
'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0) border-box',
35+
WebkitMaskComposite: 'xor' as const,
36+
}}
37+
></div>
38+
);
39+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
'use client';
2+
import { createContext, useContext, useEffect, useRef, useState } from 'react';
3+
import type { ReactNode } from 'react';
4+
5+
interface MouseGlowContext {
6+
position: { x: number; y: number };
7+
radius: number;
8+
}
9+
export const GlowContext = createContext<MouseGlowContext>({
10+
position: { x: -9999, y: -9999 },
11+
radius: 100,
12+
});
13+
export const useGlowStack = (): MouseGlowContext => {
14+
const context = useContext(GlowContext);
15+
16+
return context ?? { position: { x: -9999, y: -9999 }, radius: 100 };
17+
};
18+
19+
interface GlowStackProps {
20+
children: ReactNode;
21+
radius?: number;
22+
className?: string;
23+
}
24+
25+
export function GlowStack({
26+
children,
27+
radius = 100,
28+
className,
29+
}: GlowStackProps) {
30+
const [pos, setPos] = useState({ x: -9999, y: -9999 });
31+
const rafRef = useRef<number>(0);
32+
33+
useEffect(() => {
34+
const onMove = (e: MouseEvent) => {
35+
cancelAnimationFrame(rafRef.current);
36+
rafRef.current = requestAnimationFrame(() =>
37+
setPos({ x: e.clientX, y: e.clientY }),
38+
);
39+
};
40+
41+
window.addEventListener('mousemove', onMove, { passive: true });
42+
43+
return () => {
44+
window.removeEventListener('mousemove', onMove);
45+
cancelAnimationFrame(rafRef.current);
46+
};
47+
}, []);
48+
49+
return (
50+
<GlowContext.Provider value={{ position: pos, radius }}>
51+
<div className={className}>{children}</div>
52+
</GlowContext.Provider>
53+
);
54+
}

0 commit comments

Comments
 (0)