diff --git a/app/components/chat/index.tsx b/app/components/chat/index.tsx index 96e7d1b..f5700a3 100644 --- a/app/components/chat/index.tsx +++ b/app/components/chat/index.tsx @@ -11,6 +11,7 @@ import Tooltip from '@/app/components/base/tooltip' import Toast from '@/app/components/base/toast' import AutoHeightTextarea from '@/app/components/base/auto-height-textarea' import { Markdown } from '@/app/components/base/markdown' +import LoadingAnim from './loading-anim' export type FeedbackFunc = (messageId: string, feedback: Feedbacktype) => Promise @@ -166,7 +167,13 @@ const Answer: FC = ({ item, feedbackDisabled = false, onFeedback, return (
-
+
+ {isResponsing && +
+ +
+ } +
@@ -176,7 +183,13 @@ const Answer: FC = ({ item, feedbackDisabled = false, onFeedback,
{t('app.chat.openingStatementTitle')}
)} - + {(isResponsing && !content) ? ( +
+ +
+ ) : ( + + )}
{!feedbackDisabled && !item.feedbackDisabled && renderItemOperation()} diff --git a/app/components/chat/loading-anim/index.tsx b/app/components/chat/loading-anim/index.tsx new file mode 100644 index 0000000..0cd4111 --- /dev/null +++ b/app/components/chat/loading-anim/index.tsx @@ -0,0 +1,16 @@ +'use client' +import React, { FC } from 'react' +import s from './style.module.css' + +export interface ILoaidingAnimProps { + type: 'text' | 'avatar' +} + +const LoaidingAnim: FC = ({ + type +}) => { + return ( +
+ ) +} +export default React.memo(LoaidingAnim) diff --git a/app/components/chat/loading-anim/style.module.css b/app/components/chat/loading-anim/style.module.css new file mode 100644 index 0000000..5a764db --- /dev/null +++ b/app/components/chat/loading-anim/style.module.css @@ -0,0 +1,82 @@ +.dot-flashing { + position: relative; + animation: 1s infinite linear alternate; + animation-delay: 0.5s; +} + +.dot-flashing::before, +.dot-flashing::after { + content: ""; + display: inline-block; + position: absolute; + top: 0; + animation: 1s infinite linear alternate; +} + +.dot-flashing::before { + animation-delay: 0s; +} + +.dot-flashing::after { + animation-delay: 1s; +} + +@keyframes dot-flashing { + 0% { + background-color: #667085; + } + + 50%, + 100% { + background-color: rgba(102, 112, 133, 0.3); + } +} + +@keyframes dot-flashing-avatar { + 0% { + background-color: #155EEF; + } + + 50%, + 100% { + background-color: rgba(21, 94, 239, 0.3); + } +} + +.text, +.text::before, +.text::after { + width: 4px; + height: 4px; + border-radius: 50%; + background-color: #667085; + color: #667085; + animation-name: dot-flashing; +} + +.text::before { + left: -7px; +} + +.text::after { + left: 7px; +} + +.avatar, +.avatar::before, +.avatar::after { + width: 2px; + height: 2px; + border-radius: 50%; + background-color: #155EEF; + color: #155EEF; + animation-name: dot-flashing-avatar; +} + +.avatar::before { + left: -5px; +} + +.avatar::after { + left: 5px; +} \ No newline at end of file diff --git a/app/components/chat/style.module.css b/app/components/chat/style.module.css index 7619d2d..0744311 100644 --- a/app/components/chat/style.module.css +++ b/app/components/chat/style.module.css @@ -1,22 +1,23 @@ .answerIcon { + position: relative; background: url(./icons/robot.svg); } .typeingIcon { - position: relative; -} - -.typeingIcon::after { - content: ''; position: absolute; - top: -3px; - left: -3px; + top: 0px; + left: 0px; + display: flex; + justify-content: center; + align-items: center; width: 16px; height: 16px; - background: url(./icons/typing.svg) no-repeat; - background-size: contain; + background: #FFFFFF; + box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05); + border-radius: 16px; } + .questionIcon { background: url(./icons/default-avatar.jpg); background-size: contain; diff --git a/app/components/index.tsx b/app/components/index.tsx index 4a27087..448f763 100644 --- a/app/components/index.tsx +++ b/app/components/index.tsx @@ -282,7 +282,7 @@ const Main: FC = () => { const placeholderAnswerId = `answer-placeholder-${Date.now()}` const placeholderAnswerItem = { id: placeholderAnswerId, - content: '...', + content: '', isAnswer: true, }