@@ -14,41 +14,77 @@ const buttonSizes = {
14
14
15
15
type ButtonSize = keyof typeof buttonSizes ;
16
16
17
+ type ButtonVariant = "default" | "primary-dark" ;
18
+
17
19
type BaseButtonProps = {
18
20
size ?: ButtonSize ;
19
21
disabled ?: boolean ;
20
22
className ?: string ;
23
+ variant ?: ButtonVariant ;
21
24
children ?: React . ReactNode ;
22
25
onClick ?: ( ) => void ;
26
+ href ?: string ;
23
27
} ;
24
28
25
- // Shared styles
26
- const baseButtonStyles =
27
- "transition-all duration-200 flex items-center justify-center rounded-[64px] bg-blue-dark text-white hover:bg-blue-dark-hover focus:bg-blue-dark-focused focus:outline-none active:bg-blue-dark-focused disabled:bg-grey disabled:text-white disabled:cursor-not-allowed" ;
28
-
29
- // Dark mode styles for enabled buttons
30
- const enabledDarkModeStyles =
31
- "dark:bg-white dark:text-blue-dark dark:hover:bg-grey-light dark:focus:bg-[#D9DBDF] dark:active:bg-[#D9DBDF] dark:disabled:bg-grey dark:disabled:text-grey-light" ;
29
+ const variantStyles : Record < ButtonVariant , string > = {
30
+ default : `
31
+ bg-blue-dark
32
+ text-white
33
+ hover:bg-blue-dark-hover
34
+ focus:bg-blue-dark-focused
35
+ active:bg-blue-dark-focused
36
+ disabled:bg-grey
37
+ disabled:text-white
38
+ dark:bg-white
39
+ dark:text-blue-dark
40
+ dark:hover:bg-grey-light
41
+ dark:focus:bg-[#D9DBDF]
42
+ dark:active:bg-[#D9DBDF]
43
+ dark:disabled:bg-grey
44
+ dark:disabled:text-grey-light
45
+ ` ,
46
+ "primary-dark" : `
47
+ bg-white
48
+ text-blue-dark
49
+ hover:bg-grey-light
50
+ focus:bg-grey-light
51
+ active:bg-grey-light
52
+ ` ,
53
+ } ;
32
54
33
55
// Base Button, no text, just styling
34
56
const BaseButton : React . FC < BaseButtonProps > = ( {
35
57
size = "medium" ,
36
58
disabled = false ,
37
59
className,
60
+ variant = "default" ,
38
61
children,
39
62
onClick,
63
+ href,
40
64
} ) => {
65
+ const buttonClasses = cn (
66
+ "transition-all duration-200 flex items-center justify-center rounded-[64px] focus:outline-none disabled:cursor-not-allowed" ,
67
+ buttonSizes [ size ] ,
68
+ variantStyles [ variant ] ,
69
+ className ,
70
+ ) ;
71
+
72
+ if ( href ) {
73
+ return (
74
+ < a
75
+ href = { href }
76
+ className = { buttonClasses }
77
+ onClick = { onClick }
78
+ target = "_blank"
79
+ rel = "noopener noreferrer"
80
+ >
81
+ { children }
82
+ </ a >
83
+ ) ;
84
+ }
85
+
41
86
return (
42
- < button
43
- className = { cn (
44
- baseButtonStyles ,
45
- buttonSizes [ size ] ,
46
- ! disabled && enabledDarkModeStyles ,
47
- className ,
48
- ) }
49
- disabled = { disabled }
50
- onClick = { onClick }
51
- >
87
+ < button className = { buttonClasses } disabled = { disabled } onClick = { onClick } >
52
88
{ children }
53
89
</ button >
54
90
) ;
0 commit comments