Skip to content

Commit b4d13e1

Browse files
committed
style: added border beam
1 parent 384d909 commit b4d13e1

File tree

3 files changed

+100
-2
lines changed

3 files changed

+100
-2
lines changed

www/src/app/(auth)/signin/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { BorderBeam } from '@/components/magicui/border-beam';
34
import { Button } from '@/components/ui/button';
45
import {
56
Card,
@@ -77,7 +78,7 @@ export default function SignIn() {
7778

7879
return (
7980
<div className='mx-4 w-full md:mx-auto md:w-1/2 lg:mx-auto lg:w-1/2'>
80-
<Card className='rounded-md shadow-none'>
81+
<Card className='relative overflow-hidden rounded-md shadow-none'>
8182
<CardHeader>
8283
<CardTitle>Sign In</CardTitle>
8384
<CardDescription>
@@ -140,6 +141,7 @@ export default function SignIn() {
140141
Sign Up
141142
</Link>
142143
</CardFooter>
144+
<BorderBeam duration={8} size={100} colorTo='#ffd230' />
143145
</Card>
144146
</div>
145147
);

www/src/app/(auth)/signup/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from '@/components/ui/form';
2626
import { toast } from 'sonner';
2727
import { authClient } from '@/lib/auth-client';
28+
import { BorderBeam } from '@/components/magicui/border-beam';
2829

2930
const formSchema = z.object({
3031
name: z.string().min(3, {
@@ -72,7 +73,7 @@ export default function SignUp() {
7273

7374
return (
7475
<div className='mx-4 w-full md:mx-auto lg:mx-auto lg:w-1/2'>
75-
<Card className='rounded-md shadow-none'>
76+
<Card className='relative overflow-hidden rounded-md shadow-none'>
7677
<CardHeader>
7778
<CardTitle>Sign Up</CardTitle>
7879
<CardDescription>
@@ -147,6 +148,7 @@ export default function SignUp() {
147148
Sign In
148149
</Link>
149150
</CardFooter>
151+
<BorderBeam duration={8} size={100} colorTo='#ffd230' />
150152
</Card>
151153
</div>
152154
);
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
'use client';
2+
3+
import { cn } from '@/lib/utils';
4+
import { motion, MotionStyle, Transition } from 'motion/react';
5+
6+
interface BorderBeamProps {
7+
/**
8+
* The size of the border beam.
9+
*/
10+
size?: number;
11+
/**
12+
* The duration of the border beam.
13+
*/
14+
duration?: number;
15+
/**
16+
* The delay of the border beam.
17+
*/
18+
delay?: number;
19+
/**
20+
* The color of the border beam from.
21+
*/
22+
colorFrom?: string;
23+
/**
24+
* The color of the border beam to.
25+
*/
26+
colorTo?: string;
27+
/**
28+
* The motion transition of the border beam.
29+
*/
30+
transition?: Transition;
31+
/**
32+
* The class name of the border beam.
33+
*/
34+
className?: string;
35+
/**
36+
* The style of the border beam.
37+
*/
38+
style?: React.CSSProperties;
39+
/**
40+
* Whether to reverse the animation direction.
41+
*/
42+
reverse?: boolean;
43+
/**
44+
* The initial offset position (0-100).
45+
*/
46+
initialOffset?: number;
47+
}
48+
49+
export const BorderBeam = ({
50+
className,
51+
size = 50,
52+
delay = 0,
53+
duration = 6,
54+
colorFrom = '#ffaa40',
55+
colorTo = '#9c40ff',
56+
transition,
57+
style,
58+
reverse = false,
59+
initialOffset = 0,
60+
}: BorderBeamProps) => {
61+
return (
62+
<div className='pointer-events-none absolute inset-0 rounded-[inherit] border border-transparent [mask-image:linear-gradient(transparent,transparent),linear-gradient(#000,#000)] [mask-composite:intersect] [mask-clip:padding-box,border-box]'>
63+
<motion.div
64+
className={cn(
65+
'absolute aspect-square',
66+
'bg-gradient-to-l from-[var(--color-from)] via-[var(--color-to)] to-transparent',
67+
className
68+
)}
69+
style={
70+
{
71+
width: size,
72+
offsetPath: `rect(0 auto auto 0 round ${size}px)`,
73+
'--color-from': colorFrom,
74+
'--color-to': colorTo,
75+
...style,
76+
} as MotionStyle
77+
}
78+
initial={{ offsetDistance: `${initialOffset}%` }}
79+
animate={{
80+
offsetDistance: reverse
81+
? [`${100 - initialOffset}%`, `${-initialOffset}%`]
82+
: [`${initialOffset}%`, `${100 + initialOffset}%`],
83+
}}
84+
transition={{
85+
repeat: Infinity,
86+
ease: 'linear',
87+
duration,
88+
delay: -delay,
89+
...transition,
90+
}}
91+
/>
92+
</div>
93+
);
94+
};

0 commit comments

Comments
 (0)