Skip to content

Commit 3d7899c

Browse files
committed
feat: 오픈 채팅방 UI 개발
1 parent 079905b commit 3d7899c

File tree

4 files changed

+70
-18
lines changed

4 files changed

+70
-18
lines changed

src/components/ChatActionBar.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface ChatActionProps {
99
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
1010
onKeyUp: (e: KeyboardEvent<HTMLInputElement>) => void;
1111
onSend: () => void;
12+
mode?: string;
1213
}
1314

1415
const ChatActionBar = ({
@@ -17,12 +18,23 @@ const ChatActionBar = ({
1718
value,
1819
onChange,
1920
onKeyUp,
20-
onSend
21+
onSend,
22+
mode
2123
}: ChatActionProps) => {
24+
const isTopicChat = mode === "topicChat";
25+
2226
return (
2327
<section className="flex h-[68px] w-full items-center justify-center border-t border-gray-100 bg-white">
24-
<ToggleChatTipsButton isOpen={isOpen} setIsOpen={setIsOpen} />
25-
<MessageInput value={value} onChange={onChange} onKeyUp={onKeyUp} />
28+
{!isTopicChat && (
29+
<ToggleChatTipsButton isOpen={isOpen} setIsOpen={setIsOpen} />
30+
)}
31+
<MessageInput
32+
value={value}
33+
onChange={onChange}
34+
onKeyUp={onKeyUp}
35+
mode={mode}
36+
/>
37+
2638
<img
2739
className={`ml-4 ${value ? "cursor-pointer" : "cursor-not-allowed"}`}
2840
onClick={onSend}

src/components/IntroGuide.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
const IntroGuide = () => {
1+
interface IntroGuideProps {
2+
mode?: string;
3+
chatTitle?: string;
4+
}
5+
6+
const IntroGuide = ({ mode, chatTitle }: IntroGuideProps) => {
7+
const isTopicChat = mode === "topicChat";
8+
29
return (
310
<div className="rounded-xl border border-primary-light bg-white p-5 text-black">
4-
<p className="text-md font-light whitespace-pre-line">
5-
{`MBTI 대화에 참여하셨군요!
6-
대화 상황에 대해 구체적으로
7-
말씀해주시면,더 좋은 답변을 드릴 수 있어요 :)`}
8-
</p>
9-
<p className="mt-2 block text-md font-medium">
10-
언제, 어디서, 어떤 상황인지 자유롭게 알려주세요
11-
</p>
11+
{isTopicChat ? (
12+
<>
13+
<p className="text-md font-light whitespace-pre-line">
14+
{`오픈채팅에 오신 걸 환영해요!
15+
${chatTitle}에 대한 이야기를 자유롭게 나눠보세요`}
16+
</p>
17+
</>
18+
) : (
19+
<>
20+
<p className="text-md font-light whitespace-pre-line">
21+
{`MBTI 대화에 참여하셨군요!
22+
대화 상황에 대해 구체적으로
23+
말씀해주시면,더 좋은 답변을 드릴 수 있어요 :)`}
24+
</p>
25+
<p className="mt-2 block text-md font-medium">
26+
언제, 어디서, 어떤 상황인지 자유롭게 알려주세요
27+
</p>
28+
</>
29+
)}
1230
</div>
1331
);
1432
};

src/components/input/MessageInput.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@ interface MessageInputProps {
44
value: string;
55
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
66
onKeyUp: (e: KeyboardEvent<HTMLInputElement>) => void;
7+
mode?: string;
78
}
89

9-
const MessageInput = ({ value, onChange, onKeyUp }: MessageInputProps) => {
10+
const MessageInput = ({
11+
value,
12+
onChange,
13+
onKeyUp,
14+
mode
15+
}: MessageInputProps) => {
16+
const isTopicChat = mode === "topicChat";
17+
const widthClasses = isTopicChat
18+
? "w-[267px] md:w-[282px] lg:w-[407px]"
19+
: "w-[242px] md:w-[257px] lg:w-[382px]";
20+
1021
return (
1122
<input
1223
type="text"
13-
className="ml-2.5 flex h-[44px] w-[242px] justify-center rounded-[40px] bg-gray-50 py-2.5 pl-4 text-lg leading-[24px] font-medium text-gray-900 placeholder:text-gray-600 md:w-[257px] lg:w-[382px]"
24+
className={`ml-2.5 flex h-[44px] justify-center rounded-[40px] bg-gray-50 py-2.5 pl-4 text-lg leading-[24px] font-medium text-gray-900 placeholder:text-gray-600 ${widthClasses}`}
1425
placeholder="메시지를 입력해주세요"
1526
value={value}
1627
onChange={onChange}

src/pages/Chat.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,22 @@ interface ChatHistoryResponse {
3030

3131
const Chat = () => {
3232
const { state } = useLocation();
33-
const { mbti, mode, id = Date.now().toString(), name } = state;
33+
const {
34+
mbti,
35+
mode,
36+
id = Date.now().toString(),
37+
name,
38+
chatTitle: openChatTitle,
39+
description: _description
40+
} = state;
3441

3542
const [messages, setMessages] = useState<Message[]>([]);
3643
const [input, setInput] = useState("");
3744
const [isOpen, setIsOpen] = useState(false);
3845
const bottomRef = useRef<HTMLDivElement>(null);
3946

40-
const chatTitle = name ? `${name}과 대화` : `${mbti}와 대화`;
47+
const chatTitle =
48+
openChatTitle || (name ? `${name}과 대화` : `${mbti}와 대화`);
4149
const assistantImgUrl = pickMbtiImage(mbti);
4250
const storageKey = `chatMessages_${id}`;
4351

@@ -146,7 +154,7 @@ const Chat = () => {
146154
<Header title={chatTitle} showShareIcon={false} />
147155
<main>
148156
<section className="h-[calc(100vh-124px)] flex-1 space-y-4 overflow-y-auto px-[20px] pt-6">
149-
<IntroGuide />
157+
<IntroGuide mode={mode} chatTitle={openChatTitle} />
150158
{/* 메시지 리스트 */}
151159
{messages.map((msg, idx) => (
152160
<div
@@ -181,9 +189,12 @@ const Chat = () => {
181189
onChange={handleChange}
182190
onKeyUp={handleKeyup}
183191
onSend={() => handleSend(input)}
192+
mode={mode}
184193
/>
185194

186-
{isOpen && <TipsMenuContainer conversationId={id} mbti={mbti} />}
195+
{mode !== "topicChat" && isOpen && (
196+
<TipsMenuContainer conversationId={id} mbti={mbti} />
197+
)}
187198
</main>
188199
</>
189200
);

0 commit comments

Comments
 (0)