Skip to content

Commit 8e7abe5

Browse files
authored
Merge pull request #18 from MBTips/feature/alert-컴포넌트-개발
feat: Alert 컴포넌트 구현
2 parents 1c24361 + 4ad0515 commit 8e7abe5

File tree

9 files changed

+77
-9
lines changed

9 files changed

+77
-9
lines changed

src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import Alert from "./components/Alert";
2+
13
function App() {
2-
return;
4+
return <Alert />;
35
}
46

57
export default App;

src/components/Alert.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import AlertButton from "@/components/button/AlertButton";
2+
3+
const Alert = () => {
4+
return (
5+
<>
6+
<div className="flex flex-col justify-center items-center bg-white rounded-2xl w-[294px] h-[200px]">
7+
<h3 className="font-bold text-2xl">채팅방 나가기</h3>
8+
<p className="mt-[9px] font-medium text-xl">
9+
<span>대화가 저장되지 않아요.</span>
10+
<span className="flex justify-center">정말 나갈까요?</span>
11+
</p>
12+
<div className="flex gap-3.5 mt-[19px]">
13+
<AlertButton>취소</AlertButton>
14+
<AlertButton>확인</AlertButton>
15+
</div>
16+
</div>
17+
</>
18+
);
19+
};
20+
21+
export default Alert;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { MouseEvent } from "react";
2+
import { cls } from "@/utils/cls";
3+
4+
interface AlertButtonProps {
5+
children: string;
6+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
7+
}
8+
const AlertButton = ({ children, onClick }: AlertButtonProps) => {
9+
return (
10+
<button
11+
className={cls(
12+
"flex justify-center items-center rounded-lg w-[124px] h-[44px] font-medium text-xl",
13+
children === "확인"
14+
? "bg-primary-normal text-white"
15+
: "bg-gray-100 text-gray-900"
16+
)}
17+
onClick={onClick}
18+
>
19+
{children}
20+
</button>
21+
);
22+
};
23+
24+
export default AlertButton;

src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { StrictMode } from "react";
22
import { createRoot } from "react-dom/client";
33
import "./index.css";
4-
import App from "./App.tsx";
4+
import App from "./App";
55

66
createRoot(document.getElementById("root")!).render(
77
<StrictMode>

src/utils/cls.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// 여러 문자열의 className을 인자로 받아 하나의 className으로 반환해주는 함수
2-
const cls = (...classses: (string | undefined | false)[]) => {
2+
export const cls = (...classses: (string | undefined | false)[]) => {
33
return classses.filter(Boolean).join(" ");
44
};
5-
6-
export default cls;

tsconfig.app.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": "src",
3+
"baseUrl": "./src",
44
"paths": {
5-
"@/*": ["*"]
5+
"@/*": ["/*"],
6+
"@/components/*": ["components/*"],
7+
"@/utils/*": ["utils/*"]
68
},
79
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
810
"target": "ES2020",
@@ -26,5 +28,5 @@
2628
"noFallthroughCasesInSwitch": true,
2729
"noUncheckedSideEffectImports": true
2830
},
29-
"include": ["src"]
31+
"include": ["src", "**/*.ts", "**/*.tsx"]
3032
}

vite.config.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1+
import * as path from "path";
12
import react from "@vitejs/plugin-react";
23
import tailwindcss from "@tailwindcss/vite";
34
import { defineConfig } from "vite";
45

56
// https://vite.dev/config/
67
export default defineConfig({
7-
plugins: [react(), tailwindcss()]
8+
plugins: [react(), tailwindcss()],
9+
resolve: {
10+
alias: [
11+
{ find: "@/", replacement: path.resolve(__dirname, "src") },
12+
{
13+
find: "@/components",
14+
replacement: path.resolve(__dirname, "src/components")
15+
},
16+
{ find: "@/hooks", replacement: path.resolve(__dirname, "src/hooks") },
17+
{ find: "@/utils", replacement: path.resolve(__dirname, "src/utils") },
18+
{ find: "@/types", replacement: path.resolve(__dirname, "src/types") },
19+
{
20+
find: "@/constants",
21+
replacement: path.resolve(__dirname, "src/constants")
22+
},
23+
{
24+
find: "@/api",
25+
replacement: path.resolve(__dirname, "src/api")
26+
}
27+
]
28+
}
829
});

0 commit comments

Comments
 (0)