Skip to content

Commit 4859458

Browse files
committed
style: 색상 템플릿 추가 및 commonButton 일부 적용
1 parent 14d9223 commit 4859458

File tree

5 files changed

+55
-46
lines changed

5 files changed

+55
-46
lines changed

pages/test/modals-test.tsx

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { ThumbnailSelectorProps } from "modalContent/ThumbnailSelector";
22
import Image from "next/image";
33
import { useState } from "react";
4+
import { Button } from "signup";
5+
import CommonButton from "@shared/components/CommonButton";
46
import useModal from "../../src/shared/hook/useModal";
57

68
const AlertTest = () => {
79
const { openAlert, openConfirm, openModal } = useModal();
810
const [selectedId, setSelectedId] = useState<string>();
911
const handleAlert = () => {
10-
openAlert({ text: "test\nasdf", isHeaderCloseBtn: true });
12+
openAlert({ text: "testasdf", isHeaderCloseBtn: true });
1113
};
1214
const handleConfirm = () => {
1315
openConfirm({
@@ -34,37 +36,25 @@ const AlertTest = () => {
3436
return (
3537
<div>
3638
Enter
37-
<button
38-
// 테스트용 버튼 스타일 클래스
39-
className="px-4 py-2 font-bold text-white bg-blue-500 rounded hover:bg-blue-700 disabled:bg-gray-300 disabled:text-gray-500 disabled:cursor-not-allowed disabled:opacity-50"
40-
onClick={handleAlert}
41-
>
39+
<CommonButton variant={"accept"} onClick={handleAlert}>
4240
Alert!
43-
</button>
44-
<button
45-
className="px-4 py-2 font-bold text-white bg-blue-500 rounded hover:bg-blue-700 disabled:bg-gray-300 disabled:text-gray-500 disabled:cursor-not-allowed disabled:opacity-50"
46-
onClick={handleConfirm}
47-
>
41+
</CommonButton>
42+
<CommonButton variant={"purple"} onClick={handleConfirm}>
4843
Confirm!
49-
</button>
50-
<div>
51-
<button
52-
className="px-4 py-2 font-bold text-white bg-blue-500 rounded hover:bg-blue-700 disabled:bg-gray-300 disabled:text-gray-500 disabled:cursor-not-allowed disabled:opacity-50"
53-
onClick={handleModal}
54-
>
55-
Modal!
56-
</button>
57-
<p>and selected image : </p>
58-
{selectedId && (
59-
<Image
60-
src={`https://images.pexels.com/photos/${selectedId}/pexels-photo-${selectedId}.jpeg`}
61-
width={350}
62-
height={350}
63-
objectFit="cover"
64-
alt="selected image"
65-
/>
66-
)}
67-
</div>
44+
</CommonButton>
45+
<CommonButton variant={"accept"} onClick={handleModal}>
46+
Modal!
47+
</CommonButton>
48+
<p>and selected image : </p>
49+
{selectedId && (
50+
<Image
51+
src={`https://images.pexels.com/photos/${selectedId}/pexels-photo-${selectedId}.jpeg`}
52+
width={350}
53+
height={350}
54+
objectFit="cover"
55+
alt="selected image"
56+
/>
57+
)}
6858
</div>
6959
);
7060
};

src/shared/components/CommonButton.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
interface CommonButtonProps
22
extends Partial<React.ButtonHTMLAttributes<HTMLButtonElement>> {
3-
variant: "primary" | "secondary" | "danger";
3+
variant:
4+
| "accept"
5+
| "warn"
6+
| "danger"
7+
| "pink"
8+
| "orange"
9+
| "yellow"
10+
| "purple"
11+
| "gray"
12+
| "black";
13+
414
children: React.ReactNode;
515
}
616
export type ButtonVariants = keyof typeof BUTTON_VARIANTS;
717
const BUTTON_VARIANTS = {
8-
primary: "bg-b-primary text-white disabled:bg-b-primary-disabled",
9-
secondary: "bg-b-secondary text-white disabled:bg-b-secondary-disabled",
10-
danger: "bg-b-danger text-white disabled:bg-b-danger-disabled",
18+
accept: "bg-c-accept text-white disabled:bg-c-accept-disabled",
19+
warn: "bg-c-warn text-white disabled:bg-c-warn-disabled",
20+
danger: "bg-c-danger text-white disabled:bg-c-danger-disabled",
21+
pink: "bg-c-pink text-white disabled:bg-c-pink-disabled",
22+
orange: "bg-c-orange text-white disabled:bg-c-orange-disabled",
23+
yellow: "bg-c-yellow text-white disabled:bg-c-yellow-disabled",
24+
purple: "bg-c-purple text-white disabled:bg-c-purple-disabled",
25+
gray: "bg-c-gray text-white disabled:bg-c-gray-disabled",
26+
black: "bg-c-black text-white",
1127
};
1228

1329
const CommonButton = (props: CommonButtonProps) => {

src/shared/modal/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const Alert = () => {
5151
)}
5252
</div>
5353

54-
<CommonButton variant={okVariant ?? "primary"} onClick={handleOk}>
54+
<CommonButton variant={okVariant ?? "accept"} onClick={handleOk}>
5555
{okText ?? "확인"}
5656
</CommonButton>
5757
</div>

src/shared/modal/Confirm.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ const Confirm = () => {
5858
)}
5959
</div>
6060
<div className="flex gap-2">
61-
<CommonButton
62-
variant={noVariant ?? "secondary"}
63-
onClick={handleNo}
64-
>
61+
<CommonButton variant={noVariant ?? "warn"} onClick={handleNo}>
6562
{noText ?? "취소"}
6663
</CommonButton>
67-
<CommonButton variant={okVariant ?? "primary"} onClick={handleOk}>
64+
<CommonButton variant={okVariant ?? "accept"} onClick={handleOk}>
6865
{okText ?? "확인"}
6966
</CommonButton>
7067
</div>

tailwind.config.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ module.exports = {
77
theme: {
88
extend: {
99
colors: {
10-
"b-primary": "#00D179",
11-
"b-primary-disabled": "#00D17975",
12-
"b-secondary": "#FACD49",
13-
"b-secondary-disabled": "#FACD4975",
14-
"b-danger": "#FF2330",
15-
"b-danger-disabled": "#FFA4A475",
10+
"c-accept": "#00D179",
11+
"c-accept-disabled": "#00D17975",
12+
"c-warn": "#FACD49",
13+
"c-warn-disabled": "#FACD4975",
14+
"c-danger": "#FF2330",
15+
"c-danger-disabled": "#FFA4A475",
16+
"c-pink": "#F864A1",
17+
"c-orange": "#F5A200",
18+
"c-yellow": "#FACD49",
19+
"c-purple": "#A564F8",
20+
"c-gray": "#BABABA",
21+
"c-black": "#222222",
1622
},
1723
backgroundImage: {
1824
stayLoggedIn: "url(/images/samples/StayLoggedIn.svg)",

0 commit comments

Comments
 (0)