Skip to content

Commit 6fde967

Browse files
committed
feat(core): remove loop animations (#8242)
1 parent 3c1cd6b commit 6fde967

File tree

6 files changed

+13
-128
lines changed

6 files changed

+13
-128
lines changed

packages/frontend/component/src/ui/loading/loading.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { assignInlineVars } from '@vanilla-extract/dynamic';
2+
import clsx from 'clsx';
23

34
import { withUnit } from '../../utils/with-unit';
4-
import { loading, speedVar } from './styles.css';
5+
import { loading, rotateAnimation, speedVar } from './styles.css';
56

67
export interface LoadingProps {
78
size?: number | string;
@@ -18,7 +19,7 @@ export const Loading = ({
1819
const sizeWithUnit = size ? withUnit(size, 'px') : '16px';
1920
return (
2021
<svg
21-
className={loading}
22+
className={clsx(loading, speed !== 0 && rotateAnimation)}
2223
width={sizeWithUnit}
2324
height={sizeWithUnit}
2425
viewBox="0 0 24 24"

packages/frontend/component/src/ui/loading/styles.css.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ const rotate = keyframes({
1212
},
1313
});
1414
export const loading = style({
15+
transform: 'rotate(-90deg)',
16+
});
17+
18+
export const rotateAnimation = style({
1519
vars: {
1620
[speedVar]: '1.5s',
1721
},
18-
textRendering: 'optimizeLegibility',
19-
transform: 'rotate(-90deg)',
2022
animation: `${rotate} ${speedVar} infinite linear`,
2123
});

packages/frontend/core/src/components/pure/ai-island/index.tsx

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import { WorkbenchService } from '@affine/core/modules/workbench';
2-
import {
3-
GlobalStateService,
4-
LiveData,
5-
useLiveData,
6-
useService,
7-
} from '@toeverything/infra';
2+
import { useLiveData, useService } from '@toeverything/infra';
83
import clsx from 'clsx';
94
import { useEffect, useState } from 'react';
105

116
import { ToolContainer } from '../../workspace';
127
import { AIIcon } from './icons';
13-
import {
14-
aiIslandAnimationBg,
15-
aiIslandBtn,
16-
aiIslandWrapper,
17-
gradient,
18-
toolStyle,
19-
} from './styles.css';
20-
21-
const RIGHT_SIDEBAR_AI_HAS_EVER_OPENED_KEY =
22-
'app:settings:rightsidebar:ai:has-ever-opened';
8+
import { aiIslandBtn, aiIslandWrapper, toolStyle } from './styles.css';
239

2410
export const AIIsland = () => {
2511
// to make sure ai island is hidden first and animate in
@@ -32,38 +18,14 @@ export const AIIsland = () => {
3218
);
3319
const activeTab = useLiveData(activeView.activeSidebarTab$);
3420
const sidebarOpen = useLiveData(workbench.sidebarOpen$);
35-
const globalState = useService(GlobalStateService).globalState;
36-
const aiChatHasEverOpened = useLiveData(
37-
LiveData.from(
38-
globalState.watch<boolean>(RIGHT_SIDEBAR_AI_HAS_EVER_OPENED_KEY),
39-
false
40-
)
41-
);
42-
43-
useEffect(() => {
44-
if (sidebarOpen && activeTab?.id === 'chat') {
45-
globalState.set(RIGHT_SIDEBAR_AI_HAS_EVER_OPENED_KEY, true);
46-
}
47-
}, [activeTab, globalState, sidebarOpen]);
4821

4922
useEffect(() => {
5023
setHide((sidebarOpen && activeTab?.id === 'chat') || !haveChatTab);
5124
}, [activeTab, haveChatTab, sidebarOpen]);
5225

5326
return (
5427
<ToolContainer className={clsx(toolStyle, { hide })}>
55-
<div
56-
className={aiIslandWrapper}
57-
data-hide={hide}
58-
data-animation={!aiChatHasEverOpened}
59-
>
60-
{aiChatHasEverOpened ? null : (
61-
<div className={aiIslandAnimationBg}>
62-
<div className={gradient} />
63-
<div className={gradient} />
64-
<div className={gradient} />
65-
</div>
66-
)}
28+
<div className={aiIslandWrapper} data-hide={hide}>
6729
<button
6830
className={aiIslandBtn}
6931
data-testid="ai-island"
Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cssVar } from '@toeverything/theme';
2-
import { createVar, keyframes, style } from '@vanilla-extract/css';
2+
import { style } from '@vanilla-extract/css';
33

44
export const toolStyle = style({
55
selectors: {
@@ -49,84 +49,3 @@ export const aiIslandBtn = style({
4949
},
5050
},
5151
});
52-
53-
// -------- animation --------
54-
export const borderAngle1 = createVar('border-angle-1');
55-
export const borderAngle2 = createVar('border-angle-2');
56-
export const borderAngle3 = createVar('border-angle-3');
57-
const brightBlue = createVar('bright-blue');
58-
const brightGreen = createVar('bright-green');
59-
const brightRed = createVar('bright-red');
60-
const borderWidth = createVar('border-width');
61-
62-
const rotateBg = keyframes({
63-
to: { transform: 'rotate(360deg)' },
64-
});
65-
66-
export const aiIslandAnimationBg = style({
67-
width: 'inherit',
68-
height: 'inherit',
69-
top: 0,
70-
left: 0,
71-
position: 'absolute',
72-
borderRadius: '50%',
73-
overflow: 'hidden',
74-
75-
vars: {
76-
[borderAngle1]: '0deg',
77-
[borderAngle2]: '90deg',
78-
[borderAngle3]: '180deg',
79-
[brightBlue]: 'rgb(0, 100, 255)',
80-
[brightGreen]: '#1E96EB',
81-
[brightRed]: 'rgb(0, 200, 255)',
82-
[borderWidth]: '1.5px',
83-
},
84-
backgroundColor: 'transparent',
85-
86-
selectors: {
87-
[`${aiIslandWrapper}[data-animation="true"] &`]: {
88-
width: `calc(100% + 2 * ${borderWidth})`,
89-
height: `calc(100% + 2 * ${borderWidth})`,
90-
top: `calc(-1 * ${borderWidth})`,
91-
left: `calc(-1 * ${borderWidth})`,
92-
},
93-
},
94-
});
95-
96-
export const gradient = style({
97-
position: 'absolute',
98-
width: '100%',
99-
height: '100%',
100-
borderRadius: 'inherit',
101-
animationName: rotateBg,
102-
animationIterationCount: 'infinite',
103-
animationTimingFunction: 'linear',
104-
pointerEvents: 'none',
105-
willChange: 'transform',
106-
selectors: {
107-
[`&:nth-of-type(1)`]: {
108-
animationDuration: '3s',
109-
backgroundImage: `conic-gradient(from ${borderAngle1} at 50% 50%,
110-
transparent, ${brightBlue} 10%,
111-
transparent 30%,
112-
transparent
113-
)`,
114-
},
115-
[`&:nth-of-type(2)`]: {
116-
animationDuration: '8s',
117-
backgroundImage: `conic-gradient(from ${borderAngle2} at 50% 50%,
118-
transparent, ${brightGreen} 10%,
119-
transparent 60%,
120-
transparent
121-
)`,
122-
},
123-
[`&:nth-of-type(3)`]: {
124-
animationDuration: '13s',
125-
backgroundImage: `conic-gradient(from ${borderAngle3} at 50% 50%,
126-
transparent, ${brightRed} 10%,
127-
transparent 50%,
128-
transparent
129-
)`,
130-
},
131-
},
132-
});

packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const CloudWorkspaceStatus = () => {
4242
const SyncingWorkspaceStatus = ({ progress }: { progress?: number }) => {
4343
return (
4444
<>
45-
<Loading progress={progress} speed={progress ? 0 : undefined} />
45+
<Loading progress={progress} speed={0} />
4646
Syncing...
4747
</>
4848
);

packages/frontend/core/src/components/workspace-selector/workspace-card/styles.css.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ globalStyle(`.${workspaceActiveStatus} svg`, {
107107
width: 16,
108108
height: 16,
109109
color: cssVar('iconSecondary'),
110+
display: 'block',
110111
});
111112

112113
export const workspaceInfoTooltip = style({

0 commit comments

Comments
 (0)