Skip to content

Commit 501e0ca

Browse files
feat: Animated waiting icon for chat (#120)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a456a25 commit 501e0ca

File tree

2 files changed

+112
-2
lines changed

2 files changed

+112
-2
lines changed

src/components/AiChat/AiChat.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { FC } from "react"
44
import styled from "@emotion/styled"
55
import Typography from "@mui/material/Typography"
66
import classNames from "classnames"
7-
import { RiSendPlaneFill, RiStopFill, RiMoreFill } from "@remixicon/react"
7+
import { RiSendPlaneFill, RiStopFill } from "@remixicon/react"
88
import { Input, AdornmentButton } from "../Input/Input"
99
import type { AiChatDisplayProps, AiChatProps } from "./types"
1010
import { EntryScreen } from "./EntryScreen"
@@ -17,6 +17,7 @@ import { AiChatProvider, useAiChat } from "./AiChatContext"
1717
import { useScrollSnap } from "../ScrollSnap/useScrollSnap"
1818
import type { Message } from "@ai-sdk/react"
1919
import Markdown from "./Markdown"
20+
import EllipsisIcon from "./EllipsisIcon"
2021

2122
const classes = {
2223
root: "MitAiChat--root",
@@ -203,6 +204,14 @@ const Disclaimer = styled(Typography)(({ theme }) => ({
203204
textAlign: "center",
204205
}))
205206

207+
const StyledEllipsisIcon = styled(EllipsisIcon)(({ theme }) => ({
208+
ellipse: {
209+
fill: theme.custom.colors.darkGray2,
210+
},
211+
width: "24px",
212+
height: "24px",
213+
}))
214+
206215
const AiChatDisplay: FC<AiChatDisplayProps> = ({
207216
conversationStarters,
208217
askTimTitle,
@@ -364,7 +373,7 @@ const AiChatDisplay: FC<AiChatDisplayProps> = ({
364373
key={"loading"}
365374
>
366375
<Message>
367-
<RiMoreFill />
376+
<StyledEllipsisIcon />
368377
</Message>
369378
</MessageRow>
370379
) : null}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import * as React from "react"
2+
import type { FC } from "react"
3+
4+
type EllipsisIconProps = {
5+
className?: string
6+
}
7+
8+
const EllipsisIcon: FC<EllipsisIconProps> = ({ className }) => (
9+
<svg
10+
viewBox="0 -10 100 40"
11+
xmlns="http://www.w3.org/2000/svg"
12+
className={className}
13+
>
14+
<ellipse cx="20" cy="15" rx="8" ry="8" fill="#000">
15+
<animate
16+
attributeName="cy"
17+
values="15;4;15;15"
18+
dur="1.2s"
19+
keyTimes="0;0.3;0.6;1"
20+
keySplines="0.42 0 0.58 1; 0.42 0 0.58 1; 0.42 0 0.58 1"
21+
calcMode="spline"
22+
repeatCount="indefinite"
23+
begin="0s"
24+
></animate>
25+
<animate
26+
attributeName="ry"
27+
values="8;8;7;8;8"
28+
dur="1.2s"
29+
keyTimes="0;0.52;0.6;0.7;1"
30+
repeatCount="indefinite"
31+
begin="0s"
32+
></animate>
33+
<animate
34+
attributeName="rx"
35+
values="8;8;9;8;8"
36+
dur="1.2s"
37+
keyTimes="0;0.52;0.6;0.7;1"
38+
repeatCount="indefinite"
39+
begin="0s"
40+
></animate>
41+
</ellipse>
42+
<ellipse cx="50" cy="15" rx="8" ry="8" fill="#000">
43+
<animate
44+
attributeName="cy"
45+
values="15;4;15;15"
46+
dur="1.2s"
47+
keyTimes="0;0.3;0.6;1"
48+
keySplines="0.42 0 0.58 1; 0.42 0 0.58 1; 0.42 0 0.58 1"
49+
calcMode="spline"
50+
repeatCount="indefinite"
51+
begin="0.2s"
52+
></animate>
53+
<animate
54+
attributeName="ry"
55+
values="8;8;7;8;8"
56+
dur="1.2s"
57+
keyTimes="0;0.52;0.6;0.7;1"
58+
repeatCount="indefinite"
59+
begin="0.2s"
60+
></animate>
61+
<animate
62+
attributeName="rx"
63+
values="8;8;9;8;8"
64+
dur="1.2s"
65+
keyTimes="0;0.52;0.6;0.7;1"
66+
repeatCount="indefinite"
67+
begin="0.2s"
68+
></animate>
69+
</ellipse>
70+
<ellipse cx="80" cy="15" rx="8" ry="8" fill="#000">
71+
<animate
72+
attributeName="cy"
73+
values="15;4;15;15"
74+
dur="1.2s"
75+
keyTimes="0;0.3;0.6;1"
76+
keySplines="0.42 0 0.58 1; 0.42 0 0.58 1; 0.42 0 0.58 1"
77+
calcMode="spline"
78+
repeatCount="indefinite"
79+
begin="0.4s"
80+
></animate>
81+
<animate
82+
attributeName="ry"
83+
values="8;8;7;8;8"
84+
dur="1.2s"
85+
keyTimes="0;0.52;0.6;0.7;1"
86+
repeatCount="indefinite"
87+
begin="0.4s"
88+
></animate>
89+
<animate
90+
attributeName="rx"
91+
values="8;8;9;8;8"
92+
dur="1.2s"
93+
keyTimes="0;0.52;0.6;0.7;1"
94+
repeatCount="indefinite"
95+
begin="0.4s"
96+
></animate>
97+
</ellipse>
98+
</svg>
99+
)
100+
101+
export default EllipsisIcon

0 commit comments

Comments
 (0)