Skip to content

Commit fa28832

Browse files
authored
Updated Button component and donate button in footer (#680)
1 parent be5d2a9 commit fa28832

File tree

3 files changed

+57
-20
lines changed

3 files changed

+57
-20
lines changed

frontend/src/tw-components/Buttons.tsx

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,77 @@ const buttonSizes = {
1414

1515
type ButtonSize = keyof typeof buttonSizes;
1616

17+
type ButtonVariant = "default" | "primary-dark";
18+
1719
type BaseButtonProps = {
1820
size?: ButtonSize;
1921
disabled?: boolean;
2022
className?: string;
23+
variant?: ButtonVariant;
2124
children?: React.ReactNode;
2225
onClick?: () => void;
26+
href?: string;
2327
};
2428

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+
};
3254

3355
// Base Button, no text, just styling
3456
const BaseButton: React.FC<BaseButtonProps> = ({
3557
size = "medium",
3658
disabled = false,
3759
className,
60+
variant = "default",
3861
children,
3962
onClick,
63+
href,
4064
}) => {
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+
4186
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}>
5288
{children}
5389
</button>
5490
);

frontend/src/tw-components/Dialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function Dialog({ open = false, ...props }: DialogProps) {
2828
}
2929
}, [isBackdropOpen]);
3030

31+
3132
useEffect(() => {
3233
if (open) {
3334
setIsBackdropOpen(true);

frontend/src/tw-components/FooterNav.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { Fragment } from "react";
33
import { Link } from "react-router-dom";
44

55
// Internal imports
6-
import { Button } from "components/components";
6+
import { Button } from "tw-components/Buttons";
77
import { logoHorizontalOnDark, logoStackedOnDark } from "assets/images/images";
88

99
interface menuObject {
@@ -55,9 +55,9 @@ function FooterNav() {
5555
</nav>
5656
<div className="mx-0 flex lg:ml-auto">
5757
<Button
58-
color="primary-dark"
58+
size="small"
59+
variant="primary-dark"
5960
href="https://www.hackforla.org/donate/"
60-
size="sm"
6161
>
6262
Donate
6363
</Button>

0 commit comments

Comments
 (0)