Skip to content

Commit 5c4f38b

Browse files
authored
Merge pull request #6459 from chezsmithy/refactor-ellipsis
refactor: ♻️ Refactor to use a single animated ellipsis component
2 parents 10e2b9a + 68fd28f commit 5c4f38b

File tree

7 files changed

+39
-54
lines changed

7 files changed

+39
-54
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import styled, { keyframes } from "styled-components";
2+
3+
const ellipsisAnimation = keyframes`
4+
0% { width: 0; }
5+
33% { width: 0.33em; }
6+
66% { width: 0.66em; }
7+
100% { width: 1em; }
8+
`;
9+
10+
export const AnimatedEllipsis = styled.span`
11+
display: inline-block;
12+
width: 1em; /* Fixed width to match the maximum animation width */
13+
14+
&::after {
15+
content: "...";
16+
display: inline-block;
17+
overflow: hidden;
18+
vertical-align: bottom;
19+
animation: ${ellipsisAnimation} 2s infinite;
20+
width: 0;
21+
}
22+
`;
23+
24+
export default AnimatedEllipsis;

gui/src/components/StepContainer/ConversationSummary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/solid";
22
import { TrashIcon } from "@heroicons/react/24/outline";
33
import { ChatHistoryItem } from "core";
44
import { useState } from "react";
5-
import { AnimatedEllipsis } from "../";
5+
import { AnimatedEllipsis } from "../AnimatedEllipsis";
66
import { useAppSelector } from "../../redux/hooks";
77
import StyledMarkdownPreview from "../StyledMarkdownPreview";
88
import { useDeleteCompaction } from "../../util/compactConversation";

gui/src/components/index.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled, { keyframes } from "styled-components";
1+
import styled from "styled-components";
22
import { varWithFallback } from "../styles/theme";
33

44
export const defaultBorderRadius = "0.5rem";
@@ -199,21 +199,3 @@ export const CloseButton = styled.button`
199199
justify-content: center;
200200
cursor: pointer;
201201
`;
202-
203-
const ellipsisAnimation = keyframes`
204-
0% { width: 0; }
205-
33% { width: 0.33em; }
206-
66% { width: 0.66em; }
207-
100% { width: 1em; }
208-
`;
209-
210-
export const AnimatedEllipsis = styled.span`
211-
&::after {
212-
content: "...";
213-
display: inline-block;
214-
overflow: hidden;
215-
vertical-align: bottom;
216-
animation: ${ellipsisAnimation} 2s infinite;
217-
width: 0;
218-
}
219-
`;

gui/src/components/mainInput/Lump/LumpToolbar/GeneratingIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnimatedEllipsis } from "../../..";
1+
import { AnimatedEllipsis } from "../../../AnimatedEllipsis";
22

33
export function GeneratingIndicator({
44
text = "Generating",

gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { ContextItemWithId } from "core";
33
import { ctxItemToRifWithContents } from "core/commands/util";
44
import { getUriPathBasename } from "core/util/uri";
55
import { ComponentType, useContext, useMemo } from "react";
6-
import { AnimatedEllipsis } from "../..";
76
import {
87
IdeMessengerContext,
98
IIdeMessenger,
109
} from "../../../context/IdeMessenger";
1110
import { useAppSelector } from "../../../redux/hooks";
1211
import { selectIsGatheringContext } from "../../../redux/slices/sessionSlice";
12+
import { AnimatedEllipsis } from "../../AnimatedEllipsis";
1313
import FileIcon from "../../FileIcon";
1414
import SafeImg from "../../SafeImg";
1515
import ToggleDiv from "../../ToggleDiv";

gui/src/components/mainInput/belowMainInput/ThinkingBlockPeek.tsx

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { ChevronUpIcon } from "@heroicons/react/24/solid";
44
import { ChatHistoryItem } from "core";
55
import { useEffect, useState } from "react";
66
import styled from "styled-components";
7+
78
import { defaultBorderRadius, lightGray, vscBackground } from "../..";
89
import { getFontSize } from "../../../util";
10+
import { AnimatedEllipsis } from "../../AnimatedEllipsis";
911
import StyledMarkdownPreview from "../../StyledMarkdownPreview";
1012

1113
const SpoilerButton = styled.div`
@@ -36,34 +38,11 @@ const ButtonContent = styled.div`
3638
gap: 6px;
3739
`;
3840

39-
export const ThinkingText = styled.span`
40-
position: relative;
41-
padding-right: 12px;
42-
43-
&:after {
44-
content: "...";
45-
position: absolute;
46-
animation: ellipsis 1s steps(4, end) infinite;
47-
width: 0px;
48-
display: inline-block;
49-
overflow: hidden;
50-
}
41+
const ThinkingTextContainer = styled.span`
42+
display: inline-block;
43+
min-width: fit-content;
5144
52-
@keyframes ellipsis {
53-
0%,
54-
100% {
55-
width: 0px;
56-
}
57-
33% {
58-
width: 8px;
59-
}
60-
66% {
61-
width: 16px;
62-
}
63-
90% {
64-
width: 24px;
65-
}
66-
}
45+
padding-right: 1em; /* Reserve space for the ellipsis animation */
6746
`;
6847

6948
const MarkdownWrapper = styled.div`
@@ -120,12 +99,13 @@ function ThinkingBlockPeek({
12099
className="flex items-center justify-start pl-2 text-xs text-gray-300"
121100
data-testid="thinking-block-peek"
122101
>
123-
<SpoilerButton onClick={() => setOpen((prev) => !prev)}>
102+
<SpoilerButton onClick={() => setOpen(!open)}>
124103
<ButtonContent>
125104
{inProgress ? (
126-
<ThinkingText>
105+
<span>
127106
{redactedThinking ? "Redacted Thinking" : "Thinking"}
128-
</ThinkingText>
107+
<AnimatedEllipsis />
108+
</span>
129109
) : redactedThinking ? (
130110
"Redacted Thinking"
131111
) : (
@@ -141,7 +121,6 @@ function ThinkingBlockPeek({
141121
</ButtonContent>
142122
</SpoilerButton>
143123
</div>
144-
145124
<div
146125
className={`ml-2 mt-2 overflow-y-auto transition-none duration-300 ease-in-out ${
147126
open ? "mb-2 mt-5 opacity-100" : "max-h-0 border-0 opacity-0"

gui/src/pages/config/IndexingProgress/IndexingProgressTitleText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IndexingProgressUpdate } from "core";
2-
import { AnimatedEllipsis } from "../../../components";
2+
import { AnimatedEllipsis } from "../../../components/AnimatedEllipsis";
33

44
export interface IndexingProgressTitleTextProps {
55
update: IndexingProgressUpdate;

0 commit comments

Comments
 (0)