|
1 | | -import React from 'react'; |
| 1 | +import React from "react"; |
2 | 2 |
|
3 | | -type StarBorderProps<T extends React.ElementType> = React.ComponentPropsWithoutRef<T> & { |
4 | | - as?: T; |
5 | | - className?: string; |
6 | | - children?: React.ReactNode; |
7 | | - color?: string; |
8 | | - speed?: React.CSSProperties['animationDuration']; |
9 | | - thickness?: number; |
10 | | -}; |
| 3 | +type StarBorderProps<T extends React.ElementType> = |
| 4 | + React.ComponentPropsWithoutRef<T> & { |
| 5 | + as?: T; |
| 6 | + className?: string; |
| 7 | + children?: React.ReactNode; |
| 8 | + color?: string; |
| 9 | + speed?: React.CSSProperties["animationDuration"]; |
| 10 | + thickness?: number; |
| 11 | + }; |
11 | 12 |
|
12 | | -const StarBorder = <T extends React.ElementType = 'button'>({ |
| 13 | +const StarBorder = <T extends React.ElementType = "button">({ |
13 | 14 | as, |
14 | | - className = '', |
15 | | - color = 'white', |
16 | | - speed = '6s', |
| 15 | + className = "", |
| 16 | + color = "white", |
| 17 | + speed = "6s", |
17 | 18 | thickness = 1, |
18 | 19 | children, |
19 | 20 | ...rest |
20 | 21 | }: StarBorderProps<T>) => { |
21 | | - const Component = as || 'button'; |
| 22 | + const Component = as || "button"; |
22 | 23 |
|
23 | 24 | return ( |
24 | 25 | <Component |
25 | | - className={`relative inline-block overflow-hidden shadow ${className}`} |
| 26 | + className={`relative overflow-hidden inline-block shadow ${className}`} |
26 | 27 | {...(rest as any)} |
27 | 28 | style={{ |
28 | 29 | padding: `${thickness}px 0`, |
29 | | - ...(rest as any).style |
| 30 | + ...(rest as any).style, |
30 | 31 | }} |
31 | 32 | > |
32 | 33 | <div |
33 | | - className="absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0" |
| 34 | + className={ |
| 35 | + "absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0" |
| 36 | + } |
34 | 37 | style={{ |
35 | 38 | background: `radial-gradient(circle, ${color}, transparent 10%)`, |
36 | | - animationDuration: speed |
| 39 | + animationDuration: speed, |
37 | 40 | }} |
38 | 41 | ></div> |
39 | 42 | <div |
40 | 43 | className="absolute w-[300%] h-[50%] opacity-70 -top-2.5 left-[-250%] rounded-full animate-star-movement-top z-0" |
41 | 44 | style={{ |
42 | 45 | background: `radial-gradient(circle, ${color}, transparent 10%)`, |
43 | | - animationDuration: speed |
| 46 | + animationDuration: speed, |
44 | 47 | }} |
45 | 48 | ></div> |
46 | | - <div className="relative z-1 bg-linear-to-b from-black to-gray-900 border border-gray-800 text-white text-center text-[16px] py-4 px-[26px] rounded"> |
| 49 | + <div |
| 50 | + className={`relative z-1 bg-linear-to-b from-black to-gray-900 border border-gray-800 text-white text-center text-[16px] py-4 px-[26px] rounded ${className}`} |
| 51 | + > |
47 | 52 | {children} |
48 | 53 | </div> |
49 | 54 | </Component> |
50 | 55 | ); |
51 | 56 | }; |
52 | 57 |
|
53 | 58 | export default StarBorder; |
54 | | - |
|
0 commit comments