Skip to content

Commit

Permalink
Merge pull request MARU-EGG#42 from MARU-EGG/feat/loader_2
Browse files Browse the repository at this point in the history
Feat: loader component 재오픈
  • Loading branch information
sangmaaaaan authored Aug 23, 2024
2 parents 041f5e6 + 79cd9e9 commit 68eef11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/hooks/use-chat-form.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const useChatForm = () => {
e.preventDefault();
try {
useChatStore.getState().addMessage({ content, role: 'user' });
useChatStore.getState().addMessage({ content: '답변을 생성중입니다...', role: 'system' });
useChatStore.getState().addMessage({ content: 'loading', role: 'system' });
useChatStore.getState().setLoading(true);
setContent('');
setAutoOpen(false);
Expand Down
3 changes: 2 additions & 1 deletion src/ui/components/atom/chat-card/chat-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { cn } from '../../../../utils/style';
import maru from '../../../../assets/maru-egg.png';
import Loader from '../loader/loader';
interface ChatCardProps {
content: string;
role: 'user' | 'system';
Expand All @@ -24,7 +25,7 @@ const ChatCard = ({ content, role }: ChatCardProps) => {
})}
>
<div className="font-pretendard text-sm font-normal">
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>
{content === 'loading' ? <Loader /> : <ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>}
</div>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/ui/components/atom/loader/loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

const Loader: React.FC = () => {
return (
<div className="flex h-full w-full items-center justify-center">
<div className="flex space-x-2">
<div className="h-2 w-2 animate-pulse rounded-full bg-primary-blue" style={{ animationDelay: '-0.3s' }}></div>
<div className="h-2 w-2 animate-pulse rounded-full bg-primary-blue" style={{ animationDelay: '0.1s' }}></div>
<div className="h-2 w-2 animate-pulse rounded-full bg-primary-blue" style={{ animationDelay: '0.5s' }}></div>
</div>
</div>
);
};

export default Loader;

0 comments on commit 68eef11

Please sign in to comment.