Skip to content

Commit fbd5d07

Browse files
authored
Merge pull request #29 from prnsslcn/frontend-ui
Feat: 디자인 색상 변경 및 category추가
2 parents c64a800 + 3376974 commit fbd5d07

7 files changed

Lines changed: 93 additions & 53 deletions

File tree

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
import axios from "axios";
2-
import { customAxios } from "./axiosCustom"
2+
import { customAxios } from "./axiosCustom";
33

4-
export const postQuery = async ( user_input ) => {
5-
try {
6-
const response = await customAxios.post('/query', {user_input});
7-
return response.data;
8-
} catch (error) {
9-
throw error;
10-
}
11-
}
4+
// const response = await customAxios.post('/query', {user_input, category})
5+
export const postQuery = async (user_input, category) => {
6+
try {
7+
const response = await customAxios.post("/query", { user_input, category });
8+
return response.data;
9+
} catch (error) {
10+
throw error;
11+
}
12+
};
1213

1314
// json-server 테스트용
1415
export const getRecipes = async () => {
15-
try {
16-
const response = await axios.get('http://localhost:5000/0')
17-
return response.data
18-
} catch (error) {
19-
throw error
20-
}
21-
}
16+
try {
17+
const response = await axios.get("http://localhost:5000/0");
18+
return response.data;
19+
} catch (error) {
20+
throw error;
21+
}
22+
};
2223

2324
export const postRecipes = async (user_input) => {
24-
try {
25-
const reponse = await customAxios.post('/recipes', user_input)
26-
return reponse.data
27-
} catch (error) {
28-
throw error
29-
}
30-
}
25+
try {
26+
const reponse = await customAxios.post("/recipes", user_input);
27+
return reponse.data;
28+
} catch (error) {
29+
throw error;
30+
}
31+
};

frontend/chatbot-ui/src/components/AllChatBubble.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ const AllChatBubble = () => {
5959
<div
6060
className={`chat-bubble text-xl ${
6161
message === "어떤 요리를 만들고 싶으세요?"
62-
? "bg-yellow-400"
63-
: "bg-sky-400"
62+
? "bg-lime-600 text-lime-50"
63+
: "bg-stone-200 text-stone-900"
6464
}`}
6565
>
6666
{message}
@@ -74,7 +74,7 @@ const AllChatBubble = () => {
7474
if (message.content) {
7575
return (
7676
<div key={index} className="chat chat-start">
77-
<div className="chat-bubble bg-yellow-400 text-xl">
77+
<div className="chat-bubble bg-lime-600 text-lime-50 text-xl">
7878
{message.type === "text" ? (
7979
<div>{message.content}</div>
8080
) : (
@@ -95,10 +95,10 @@ const AllChatBubble = () => {
9595
);
9696

9797
return (
98-
<div className="bg-white w-full h-full grow p-6 flex flex-col">
98+
<div className="bg-white w-full h-full grow p-6 flex flex-col rounded-t-xl border-t border-l border-r border-stone-300">
9999
<div
100100
ref={chatContainerRef}
101-
className="overflow-y-auto flex-grow max-h-[75vh] flex flex-col"
101+
className="overflow-y-auto flex-grow max-h-[60vh] flex flex-col"
102102
>
103103
{renderedMessages}
104104
{callResponse && (
@@ -112,14 +112,14 @@ const AllChatBubble = () => {
112112
<div className="flex flex-col items-center my-6">
113113
{!showSteps ? (
114114
<button
115-
className="btn bg-sky-400 w-1/3 text-2xl p-6"
115+
className="btn bg-amber-500 text-amber-50 w-1/3 text-2xl p-6"
116116
onClick={() => setShowSteps(true)}
117117
>
118118
시작
119119
</button>
120120
) : (
121-
<div className="w-full flex flex-col items-center">
122-
<ul className="steps steps-vertical w-2/3">
121+
<div className="w-full flex items-center flex-col border-t border-stone-300 pt-4">
122+
<ul className="steps steps-vertical">
123123
{allMessages
124124
.find((msg) => msg.recipe?.steps)
125125
?.recipe?.steps?.slice(0, currentStep + 1)
@@ -135,8 +135,8 @@ const AllChatBubble = () => {
135135
(allMessages.find((msg) => msg.recipe?.steps)?.recipe?.steps
136136
.length || 0) -
137137
1
138-
? "bg-emerald-400 text-emerald-900"
139-
: "bg-red-400 text-white"
138+
? "bg-amber-600 text-amber-50"
139+
: "bg-red-600 text-red-50"
140140
}`}
141141
onClick={() => {
142142
if (

frontend/chatbot-ui/src/components/LoadingSpinner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const LoadingSpinner = () => {
22
return (
33
<div className="chat chat-start">
4-
<div className="chat-bubble bg-yellow-400 text-xl">
4+
<div className="chat-bubble bg-lime-600 text-lime-50 text-xl">
55
<div className="loading loading-infinity loading-xl"></div>
66
</div>
77
</div>

frontend/chatbot-ui/src/components/UserInput.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from "react";
22
import { useChat } from "../context/ChatContext";
3+
import { postQuery } from "../api/getQuery";
34

45
export const UserInput = () => {
56
const [userInput, setUserInput] = useState("");
@@ -17,23 +18,41 @@ export const UserInput = () => {
1718
const category = ["한식", "일식", "중식", "양식"];
1819

1920
const handleSubmit = async () => {
21+
if (!optionCheck) {
22+
const noCategoryMessage = {
23+
type: "text",
24+
content: "🚨 카테고리를 선택해주세요.",
25+
};
26+
setMessages((prev) => [...prev, noCategoryMessage]);
27+
setAllMessages((prev) => [...prev, noCategoryMessage]);
28+
return;
29+
}
30+
2031
if (userInput.trim() !== "" && !isAiResponding) {
2132
setMessages((prevMessages) => [...prevMessages, userInput]);
2233
setAllMessages((prevMessages) => [...prevMessages, userInput]);
2334
setCallResponse(true);
2435
setUserInput("");
36+
37+
try {
38+
const response = await postQuery(userInput, optionCheck);
39+
console.log(response);
40+
} catch (err) {
41+
console.log(err);
42+
}
2543
}
2644
};
2745

28-
const handleKeyDown = (e) => {
46+
const handleKeyUp = (e) => {
2947
if (e.key === "Enter") {
3048
e.preventDefault();
3149
handleSubmit();
3250
}
3351
};
3452

3553
return (
36-
<div className="bg-white p-6 rounded-lg shadow-md">
54+
<div className="bg-white p-6 relative rounded-b-xl border-b border-l border-r border-stone-300">
55+
<div className="font-semibold mb-2 text-lime-950">카테고리(필수)</div>
3756
<div className="flex space-x-4 mb-4">
3857
{category.map((category, idx) => (
3958
<label key={idx} className="flex items-center space-x-2">
@@ -47,18 +66,17 @@ export const UserInput = () => {
4766
</label>
4867
))}
4968
</div>
50-
5169
<div className="relative flex items-center">
5270
<input
5371
type="text"
5472
placeholder="만들고 싶은 요리를 입력해주세요"
5573
className="input input-xl w-full pr-28 p-3 border border-gray-300 rounded-lg focus:outline-none"
5674
value={userInput}
5775
onChange={handleInputChange}
58-
onKeyUp={handleKeyDown}
76+
onKeyUp={handleKeyUp}
5977
/>
6078
<button
61-
className="btn absolute right-9 top-1/2 transform -translate-y-1/2"
79+
className="btn absolute right-5 top-1/2 transform -translate-y-1/2"
6280
onClick={handleSubmit}
6381
disabled={isAiResponding}
6482
>

frontend/chatbot-ui/src/context/ChatContext.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const ChatProvider = ({ children }) => {
77
const [aiResponse, setAiResponse] = useState([]);
88
const [callResponse, setCallResponse] = useState(false);
99
const [allMessages, setAllMessages] = useState([
10-
"어떤 요리를 만들고 싶으세요?"
10+
"어떤 요리를 만들고 싶으세요?",
1111
]);
1212
const [isAiResponding, setIsAiResponding] = useState(false);
1313
const [optionCheck, setOptionCheck] = useState("");
@@ -25,7 +25,8 @@ export const ChatProvider = ({ children }) => {
2525
setAllMessages,
2626
isAiResponding,
2727
setIsAiResponding,
28-
optionCheck, setOptionCheck
28+
optionCheck,
29+
setOptionCheck,
2930
}}
3031
>
3132
{children}

frontend/chatbot-ui/src/index.css

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
[data-theme="light"] {
6+
--color-primary: oklch(70% 0.3 310); /* ✅ primary 색상 변경 */
7+
}
8+
19
body {
210
margin: 0;
311
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
@@ -21,6 +29,20 @@ code {
2129
.steps .step {
2230
text-align: left !important;
2331
}
24-
@tailwind base;
25-
@tailwind components;
26-
@tailwind utilities;
32+
33+
.steps .step > .step-icon,
34+
.steps .step:not(:has(.step-icon)):after,
35+
.steps .step:not(:has(.step-icon)):before {
36+
background-color: oklch(76% 0.188 70.08);
37+
border: 1px solid oklch(76% 0.188 70.08);
38+
color: oklch(98% 0.022 95.277);
39+
}
40+
41+
.checkbox-primary {
42+
border: 1px solid oklch(53% 0.157 131.589);
43+
--input-color: oklch(53% 0.157 131.589);
44+
}
45+
46+
.checkbox checkbox-primary span {
47+
color: oklch(27% 0.072 132.109);
48+
}

frontend/chatbot-ui/src/pages/Home.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ import AllChatBubble from "../components/AllChatBubble";
33
import { UserInput } from "../components/UserInput";
44

55
export default function Home() {
6-
7-
return (
8-
<div className="bg-gray-300 p-10 min-h-screen flex flex-col">
9-
<AiChatValidate/>
10-
<AllChatBubble/>
11-
<UserInput/>
12-
</div>
13-
);
6+
return (
7+
<div className="bg-stone-200 p-10 min-h-screen flex flex-col">
8+
<AiChatValidate />
9+
<AllChatBubble />
10+
<UserInput />
11+
</div>
12+
);
1413
}
1514

1615
/*
1716
2025-03-17-14:40 pull develop
1817
*/
19-

0 commit comments

Comments
 (0)