Skip to content

Commit 3128eb3

Browse files
authored
Merge pull request #188 from MBTips/feature/ToggleChatTipsbutton-열고-닫는-기능
feat: ToggleChatTIpsButton 열고 닫히는 기능 구현 완료
2 parents a05f8c0 + f564125 commit 3128eb3

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed

src/components/ChatActionBar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ChangeEvent, KeyboardEvent } from "react";
22
import ToggleChatTipsButton from "@/components/button/ToggleChatTipsButton";
33
import MessageInput from "@/components/input/MessageInput";
4+
import TipsMenuContainer from "@/components/tips/TipsMenuContainer";
45

56
interface ChatActionProps {
67
isOpen: boolean;

src/components/button/ToggleChatTipsButton.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ const ToggleChatTipsButton = ({
88
setIsOpen
99
}: ToggleChatTipsButtonProps) => {
1010
return (
11-
<img
12-
src={isOpen ? "/icon/close.svg" : "/icon/plus.svg"}
13-
onClick={() => setIsOpen(!isOpen)}
14-
alt="토글 메뉴 버튼"
15-
width={14}
16-
height={14}
17-
/>
11+
<button>
12+
<img
13+
src={isOpen ? "/icon/close.svg" : "/icon/plus.svg"}
14+
onClick={() => setIsOpen(!isOpen)}
15+
alt="토글 메뉴 버튼"
16+
width={14}
17+
height={14}
18+
/>
19+
</button>
1820
);
1921
};
2022

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1+
import { Link } from "react-router-dom";
2+
13
const TipsMenu = ({
24
mode
35
}: {
46
mode: "topic" | "conversation" | "temporature";
57
}) => {
68
let text = "";
79
let imageUrl = "";
10+
let href = "";
11+
812
switch (mode) {
913
case "topic":
1014
text = "대화 주제 추천";
1115
imageUrl = "/icon/starbubble.svg";
16+
href = "/chat-recommend";
1217
break;
1318
case "conversation":
1419
text = "대화 꿀팁";
1520
imageUrl = "/icon/lightbulb.svg";
21+
href = "/chat-tips";
1622
break;
1723
case "temporature":
1824
text = "현재 대화의 온도 측정하기";
1925
imageUrl = "/icon/thermometer.svg";
26+
href = "/chat-temporature";
2027
break;
2128
default:
2229
return;
2330
}
2431

2532
return (
26-
<div className="flex bg-white px-4 py-4 border-gray-100 border-b w-[375px] h-[56px]">
27-
<img src={imageUrl} alt={text} width={20} height={20} />
28-
<h2 className="ml-[22px] font-medium text-2lg text-gray-800">{text}</h2>
29-
</div>
33+
<Link to={href}>
34+
<div className="flex h-[56px] w-full border-t border-gray-100 bg-white px-4 py-4 hover:bg-primary-pale">
35+
<img src={imageUrl} alt={text} width={20} height={20} />
36+
<h2 className="text-2lg ml-[22px] font-medium text-gray-800">{text}</h2>
37+
</div>
38+
</Link>
3039
);
3140
};
3241

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import TipsMenu from "@/components/tips/TipsMenu";
2+
3+
const TipsMenuContainer = () => {
4+
return (
5+
<>
6+
<TipsMenu mode="topic" />
7+
<TipsMenu mode="conversation" />
8+
<TipsMenu mode="temporature" />
9+
</>
10+
);
11+
};
12+
13+
export default TipsMenuContainer;

src/index.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ body {
3131
main {
3232
@media screen and (min-width: 360px) {
3333
width: 360px;
34-
3534
}
3635
@media screen and (min-width: 375px) {
3736
width: 375px;
38-
3937
}
4038
@media screen and (min-width: 500px) {
4139
width: 500px;
@@ -55,7 +53,6 @@ button:hover {
5553
}
5654

5755
@keyframes pulse-custom {
58-
5956
0%,
6057
100% {
6158
transform: scale(1);
@@ -87,4 +84,4 @@ button:hover {
8784
* {
8885
@apply transition-transform duration-200 ease-in-out;
8986
}
90-
}
87+
}

src/pages/Chat.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import ChatActionBar from "@/components/ChatActionBar";
66
import pickMbtiImage from "@/utils/pickMbtiImage";
77
import instance from "@/api/axios";
88
import { useLocation } from "react-router-dom";
9+
import { cls } from "@/utils/cls";
10+
import TipsMenuContainer from "@/components/tips/TipsMenuContainer";
911

1012
interface Message {
1113
role: "user" | "assistant";
@@ -27,7 +29,7 @@ const Chat = () => {
2729

2830
useEffect(() => {
2931
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
30-
}, [messages]);
32+
}, [messages, isOpen]);
3133

3234
const chatTitle = `${mbti}와 대화`;
3335
const assistantInfo = mbti;
@@ -123,7 +125,6 @@ const Chat = () => {
123125

124126
<div ref={bottomRef} />
125127
</div>
126-
127128
<ChatActionBar
128129
isOpen={isOpen}
129130
setIsOpen={setIsOpen}
@@ -132,6 +133,7 @@ const Chat = () => {
132133
onKeyUp={handleKeyup}
133134
onSend={() => handleSend(input)}
134135
/>
136+
{isOpen && <TipsMenuContainer />}
135137
</div>
136138
);
137139
};

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig(({ mode }: { mode: string }) => {
1414

1515
return {
1616
server: {
17-
port: 3000,
17+
port: 5173,
1818
host: true, // 외부에서 접속 가능하도록 설정
1919
strictPort: true,
2020
allowedHosts: ["mbtips.kr"],

0 commit comments

Comments
 (0)