Skip to content

Commit 9a86afb

Browse files
authored
Merge pull request #44 from Soohyuniii/feature/form-button-component
feat: form button 컴포넌트 개발
2 parents 4bc6285 + 546b360 commit 9a86afb

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { MouseEvent } from "react";
2+
3+
interface FormButtonProps {
4+
size: "sm" | "md";
5+
children: string;
6+
selected?: boolean;
7+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
8+
}
9+
10+
const FormButton = ({
11+
size = "sm",
12+
selected = false,
13+
children,
14+
onClick
15+
}: FormButtonProps) => {
16+
const baseStyles = "flex justify-center items-center rounded-lg transition";
17+
18+
const sizeStyles =
19+
size === "sm" ? "min-w-[68px] w-auto h-[40px]" : "w-[72px] h-[72px]";
20+
21+
const fontSize =
22+
size === "md"
23+
? "text-[var(--text-2xl)]"
24+
: selected
25+
? "text-[16px]"
26+
: "text-[14px]";
27+
28+
const fontWeight =
29+
size === "md" ? "font-bold" : selected ? "font-bold" : "font-medium";
30+
31+
const backgroundColor = selected ? "bg-primary-pale" : "bg-white";
32+
const borderColor = selected ? "border-primary-light" : "border-gray-200";
33+
const fontColor = selected ? "text-primary-normal" : "text-gray-900";
34+
35+
return (
36+
<button
37+
className={`${baseStyles} ${sizeStyles} ${fontSize} ${fontWeight} ${backgroundColor} ${borderColor} ${fontColor} border`}
38+
onClick={onClick}
39+
>
40+
{children}
41+
</button>
42+
);
43+
};
44+
export default FormButton;

0 commit comments

Comments
 (0)