Skip to content

Commit f8f5fe8

Browse files
authored
[style, docs] 챗봇 로딩 컴포넌트 /페이지 안 컴포넌트 네이밍 변경 (#81)
* [style] 추천 배경 이미지 변경 , repeat 넣기 * [style] 하트 z-index 제거 * [style] 배경 변경 * [style] input 최대 width 제한 * [style] 스켈레톤 ui 추가(spinner 오류로 임시) * [feat, fix] textarea 유틸함수 추가 및 수정 (resize. submit) * [fix] 채팅 목록 및 입력창 컴포넌트 분리 * [feat] textarea 입력 시 mychat이랑 연결 * [fix] husky 오류 해결 * [docs] 챗봇페이지 컴포넌트 직관적인 네이밍으로 변경 * [feat] 채팅 로딩 컴포넌트 구현
1 parent 1a80f70 commit f8f5fe8

File tree

10 files changed

+70
-34
lines changed

10 files changed

+70
-34
lines changed

src/domains/recommend/components/ChatCocktailCard.tsx renamed to src/domains/recommend/components/BotCocktailCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Dummy from '@/shared/assets/images/dummy/exampleCocktail.png';
33
import Link from 'next/link';
44
import Keep from '@/domains/shared/components/keep/Keep';
55

6-
function ChatCocktailCard() {
6+
function BotCocktailCard() {
77
return (
88
<div className="relative flex flex-col w-full min-w-[200px] rounded-2xl overflow-hidden bg-white shadow-[0_0_12px_rgba(255,255,255,0.4)]">
99
<Link href="/" className="block relative">
@@ -20,4 +20,4 @@ function ChatCocktailCard() {
2020
</div>
2121
);
2222
}
23-
export default ChatCocktailCard;
23+
export default BotCocktailCard;

src/domains/recommend/components/SsuryChat.tsx renamed to src/domains/recommend/components/BotMessage.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import Ssury from '@/shared/assets/ssury/ssury_shaker.webp';
44
import Image from 'next/image';
55
import { useState } from 'react';
6-
import ChatRadio from './ChatRadio';
7-
import ChatCocktailCard from './ChatCocktailCard';
6+
import BotCocktailCard from './BotCocktailCard';
7+
import BotOptions from './BotOptions';
88

99
interface Message {
1010
id: string;
1111
text?: string;
1212
type?: 'radio' | 'text' | 'recommend';
1313
}
1414

15-
function SsuryChat() {
15+
function BotMessage() {
1616
const [selected, setSelected] = useState('option1');
1717

1818
// radio 옵션
@@ -61,13 +61,13 @@ function SsuryChat() {
6161
{msg.type === 'recommend' ? (
6262
<ul className="inline-grid grid-cols-1 sm:grid-cols-3 gap-2 justify-start">
6363
<li>
64-
<ChatCocktailCard />
64+
<BotCocktailCard />
6565
</li>
6666
<li>
67-
<ChatCocktailCard />
67+
<BotCocktailCard />
6868
</li>
6969
<li>
70-
<ChatCocktailCard />
70+
<BotCocktailCard />
7171
</li>
7272
</ul>
7373
) : (
@@ -76,7 +76,7 @@ function SsuryChat() {
7676

7777
{/* radio */}
7878
{msg.type === 'radio' && (
79-
<ChatRadio options={options} value={selected} onChange={setSelected} />
79+
<BotOptions options={options} value={selected} onChange={setSelected} />
8080
)}
8181
</div>
8282
)}
@@ -86,4 +86,4 @@ function SsuryChat() {
8686
</article>
8787
);
8888
}
89-
export default SsuryChat;
89+
export default BotMessage;

src/domains/recommend/components/ChatRadio.tsx renamed to src/domains/recommend/components/BotOptions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface RadioGroupProps {
99
onChange: (value: string) => void;
1010
}
1111

12-
function ChatRadio({ options, value, onChange }: RadioGroupProps) {
12+
function BotOptions({ options, value, onChange }: RadioGroupProps) {
1313
return (
1414
<div role="radiogroup" className="flex flex-col gap-3 mt-5">
1515
{options.map((opt) => (
@@ -39,4 +39,4 @@ function ChatRadio({ options, value, onChange }: RadioGroupProps) {
3939
</div>
4040
);
4141
}
42-
export default ChatRadio;
42+
export default BotOptions;

src/domains/recommend/components/ChatSection.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use client';
22

33
import { useState } from 'react';
4-
import ChatForm from './ChatForm';
5-
import MyChat from './MyChat';
6-
import SsuryChat from './SsuryChat';
4+
import BotMessage from './BotMessage';
5+
import UserMessage from './UserMessage';
6+
import MessageInput from './MessageInput';
7+
import TypingIndicator from './TypingIndicator';
78

89
function ChatSection() {
910
const [messages, setMessages] = useState<string[]>([]);
@@ -16,12 +17,13 @@ function ChatSection() {
1617
<section className="page-layout max-w-1024 py-12 ">
1718
<h2 className="sr-only">대화 목록 및 입력 창</h2>
1819
<div className="flex flex-col gap-10 pb-20">
19-
<SsuryChat />
20+
<BotMessage />
21+
<TypingIndicator />
2022
{messages.map((msg, i) => (
21-
<MyChat key={i} message={msg} />
23+
<UserMessage key={i} message={msg} />
2224
))}
2325
</div>
24-
<ChatForm onSubmit={handleSubmit} />
26+
<MessageInput onSubmit={handleSubmit} />
2527
</section>
2628
);
2729
}

src/domains/recommend/components/ChatForm.tsx renamed to src/domains/recommend/components/MessageInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Props {
99
onSubmit: (message: string) => void;
1010
}
1111

12-
function ChatForm({ onSubmit }: Props) {
12+
function MessageInput({ onSubmit }: Props) {
1313
const [value, setValue] = useState('');
1414
const textareaRef = useRef<HTMLTextAreaElement>(null);
1515

@@ -51,4 +51,4 @@ function ChatForm({ onSubmit }: Props) {
5151
</div>
5252
);
5353
}
54-
export default ChatForm;
54+
export default MessageInput;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Image from 'next/image';
2+
import shaker from '@/shared/assets/images/shaker.png';
3+
4+
function TypingIndicator() {
5+
return (
6+
<div className="relative flex items-center w-fit p-3 rounded-2xl rounded-tl-none bg-white text-black overflow-hidden">
7+
<p className="inline-block animate-fade-in">준비 중…</p>
8+
<div className="relative w-10 h-10 animate-shake">
9+
<Image src={shaker} alt="Cocktail Shaker" fill className="object-contain" priority />
10+
</div>
11+
</div>
12+
);
13+
}
14+
export default TypingIndicator;

src/domains/recommend/components/MyChat.tsx renamed to src/domains/recommend/components/UserMessage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props {
1212
// { id: '2', sender: 'user', text: '배고파요' },
1313
// ];
1414

15-
function MyChat({ message }: Props) {
15+
function UserMessage({ message }: Props) {
1616
return (
1717
<article aria-label="내 메시지" className="flex flex-col items-end">
1818
<header className="w-fit">
@@ -28,4 +28,4 @@ function MyChat({ message }: Props) {
2828
</article>
2929
);
3030
}
31-
export default MyChat;
31+
export default UserMessage;
2.25 KB
Loading
27.9 KB
Loading

src/shared/styles/_utilities.css

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,44 @@
5555
display: none;
5656
}
5757

58-
@media (min-width: 768px) {
59-
.custom-scrollbar {
60-
scrollbar-width: thin; /* Firefox 전용 */
61-
scrollbar-color: #7a7581; /* Firefox 전용: thumb track */
58+
@keyframes shake {
59+
0%,
60+
100% {
61+
transform: translateY(0) rotate(0deg) scale(1);
6262
}
6363

64-
.custom-scrollbar::-webkit-scrollbar {
65-
width: 4px;
66-
border-radius: 8px;
64+
10% {
65+
transform: rotate(-25deg) scaleX(1.05) scaleY(0.95);
66+
}
67+
20% {
68+
transform: rotate(25deg) scaleX(0.95) scaleY(1.05);
69+
}
70+
30% {
71+
transform: rotate(-20deg) scaleX(1.05) scaleY(0.95);
72+
}
73+
40% {
74+
transform: rotate(20deg) scaleX(0.95) scaleY(1.05);
6775
}
6876

69-
.custom-scrollbar::-webkit-scrollbar-thumb {
70-
background-color: #ab98c2;
71-
border-radius: 8px;
77+
50% {
78+
transform: translateY(-10px) rotate(360deg) scale(1);
7279
}
7380

74-
.custom-scrollbar::-webkit-scrollbar-track {
75-
background-color: aliceblue;
81+
60% {
82+
transform: translateY(-25px) rotate(20deg) scaleX(1.05) scaleY(0.95);
83+
}
84+
70% {
85+
transform: translateY(-10px) rotate(-25deg) scaleX(0.95) scaleY(1.05);
7686
}
87+
80% {
88+
transform: translateY(-5px) rotate(20deg) scaleX(1.02) scaleY(0.98);
89+
}
90+
90% {
91+
transform: translateY(-2px) rotate(-15deg) scale(1);
92+
}
93+
}
94+
95+
.animate-shake {
96+
animation: shake 3s ease-in-out infinite;
7797
}
7898
}

0 commit comments

Comments
 (0)