Skip to content

Commit 22a7e28

Browse files
committed
feat: add subtext for action buttons
1 parent ba8e0ef commit 22a7e28

File tree

1 file changed

+78
-76
lines changed

1 file changed

+78
-76
lines changed

src/components/UI/Button.tsx

Lines changed: 78 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,98 +4,100 @@ import {Color} from "../../styles/colors";
44
import {BIG_BREAKPOINT} from "../../constants/BreakPoints";
55

66
interface ButtonProps {
7-
text: string;
7+
text: string;
88
subtext?: string;
9-
link: string;
10-
onClick: () => void;
11-
disabled?: boolean;
12-
target?: string;
13-
children?: ReactNode;
9+
link: string;
10+
onClick: () => void;
11+
disabled?: boolean;
12+
target?: string;
13+
children?: ReactNode;
1414
}
1515

1616
const doNothingHandler = (
17-
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
17+
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
1818
) => {
19-
event.preventDefault();
19+
event.preventDefault();
2020
};
2121

2222
const StyledActionButton = styled.div`
23-
background-color: ${Color.LIGHT_BLUE};
24-
text-align: center;
25-
font-size: 1.3em;
26-
min-width: 200px;
27-
margin: 20px 5px;
28-
border-radius: 5px;
29-
box-shadow: 1px 1px 1px #000;
30-
padding: 10px 15px;
31-
transform: perspective(1px) translateZ(0);
32-
transition-duration: 0.5s;
33-
vertical-align: middle;
23+
background-color: ${Color.LIGHT_BLUE};
24+
text-align: center;
25+
font-size: 1.3em;
26+
min-width: 200px;
27+
margin: 20px 5px;
28+
border-radius: 5px;
29+
box-shadow: 1px 1px 1px #000;
30+
padding: 10px 15px;
31+
transform: perspective(1px) translateZ(0);
32+
transition-duration: 0.5s;
33+
vertical-align: middle;
34+
cursor: pointer;
3435
35-
&:hover,
36-
&:focus,
37-
&:active {
38-
background-color: ${Color.DARK_BLUE};
39-
transition-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);
40-
}
36+
&:hover,
37+
&:focus,
38+
&:active {
39+
background-color: ${Color.DARK_BLUE};
40+
transition-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);
41+
}
4142
42-
& span {
43-
font-size: 0.9rem;
44-
}
43+
& span {
44+
font-size: 0.9rem;
45+
}
4546
46-
& a {
47-
text-decoration: none;
48-
text-shadow: 1px 1px 1px #000;
49-
color: white;
50-
display: block;
51-
text-transform: uppercase;
52-
vertical-align: middle;
53-
}
47+
& a {
48+
text-decoration: none;
49+
text-shadow: 1px 1px 1px #000;
50+
color: white;
51+
display: block;
52+
text-transform: uppercase;
53+
vertical-align: middle;
54+
}
5455
55-
& small {
56-
font-weight: bold;
57-
font-size: 0.7em;
58-
color: ${Color.MAGENTA};
59-
text-shadow: none;
60-
}
56+
& small {
57+
font-weight: bold;
58+
font-size: 0.7em;
59+
color: ${Color.MAGENTA};
60+
text-shadow: none;
61+
}
6162
62-
@media (max-width: ${BIG_BREAKPOINT}px) {
63-
margin: 5px 1px;
64-
}
63+
@media (max-width: ${BIG_BREAKPOINT}px) {
64+
margin: 5px 1px;
65+
}
6566
`;
6667

6768
const Button: FC<React.PropsWithChildren<ButtonProps>> = ({
68-
text,
69+
text,
6970
subtext = "SOON",
70-
link,
71-
onClick,
72-
disabled,
73-
target = "_blank",
74-
children,
75-
}) => {
76-
return (
77-
<StyledActionButton className="hvr-bounce-in">
78-
<>
79-
<a
80-
onClick={disabled ? doNothingHandler : onClick}
81-
href={disabled ? "#top" : link}
82-
target={target}
83-
rel="noreferrer nofollow"
84-
aria-disabled={disabled}
85-
style={{
86-
display: "flex",
87-
alignItems: "center",
88-
justifyContent: "center",
89-
textDecoration: "none",
90-
flexWrap: "wrap",
91-
}}
92-
>
93-
{children}
94-
<span>{` ${text}`}</span>
95-
</a>
96-
{disabled && <small>{subtext}</small>}
97-
</>
98-
</StyledActionButton>
99-
);
71+
link,
72+
onClick,
73+
disabled,
74+
target = "_blank",
75+
children,
76+
}) => {
77+
return (
78+
<StyledActionButton className="hvr-bounce-in">
79+
<>
80+
<a
81+
onClick={disabled ? doNothingHandler : onClick}
82+
className={disabled ? "disabled" : "active"}
83+
href={disabled ? "#top" : link}
84+
target={target}
85+
rel="noreferrer nofollow"
86+
aria-disabled={disabled}
87+
style={{
88+
display: "flex",
89+
alignItems: "center",
90+
justifyContent: "center",
91+
textDecoration: "none",
92+
flexWrap: "wrap",
93+
}}
94+
>
95+
{children}
96+
<span>{` ${text}`}</span>
97+
</a>
98+
{disabled && <small>{subtext}</small>}
99+
</>
100+
</StyledActionButton>
101+
);
100102
};
101103
export default Button;

0 commit comments

Comments
 (0)