feat(core): remove loop animations (#8242)

This commit is contained in:
EYHN
2024-09-13 09:54:23 +00:00
parent 3c1cd6b648
commit 6fde967a6d
6 changed files with 13 additions and 128 deletions

View File

@@ -1,25 +1,11 @@
import { WorkbenchService } from '@affine/core/modules/workbench';
import {
GlobalStateService,
LiveData,
useLiveData,
useService,
} from '@toeverything/infra';
import { useLiveData, useService } from '@toeverything/infra';
import clsx from 'clsx';
import { useEffect, useState } from 'react';
import { ToolContainer } from '../../workspace';
import { AIIcon } from './icons';
import {
aiIslandAnimationBg,
aiIslandBtn,
aiIslandWrapper,
gradient,
toolStyle,
} from './styles.css';
const RIGHT_SIDEBAR_AI_HAS_EVER_OPENED_KEY =
'app:settings:rightsidebar:ai:has-ever-opened';
import { aiIslandBtn, aiIslandWrapper, toolStyle } from './styles.css';
export const AIIsland = () => {
// to make sure ai island is hidden first and animate in
@@ -32,19 +18,6 @@ export const AIIsland = () => {
);
const activeTab = useLiveData(activeView.activeSidebarTab$);
const sidebarOpen = useLiveData(workbench.sidebarOpen$);
const globalState = useService(GlobalStateService).globalState;
const aiChatHasEverOpened = useLiveData(
LiveData.from(
globalState.watch<boolean>(RIGHT_SIDEBAR_AI_HAS_EVER_OPENED_KEY),
false
)
);
useEffect(() => {
if (sidebarOpen && activeTab?.id === 'chat') {
globalState.set(RIGHT_SIDEBAR_AI_HAS_EVER_OPENED_KEY, true);
}
}, [activeTab, globalState, sidebarOpen]);
useEffect(() => {
setHide((sidebarOpen && activeTab?.id === 'chat') || !haveChatTab);
@@ -52,18 +25,7 @@ export const AIIsland = () => {
return (
<ToolContainer className={clsx(toolStyle, { hide })}>
<div
className={aiIslandWrapper}
data-hide={hide}
data-animation={!aiChatHasEverOpened}
>
{aiChatHasEverOpened ? null : (
<div className={aiIslandAnimationBg}>
<div className={gradient} />
<div className={gradient} />
<div className={gradient} />
</div>
)}
<div className={aiIslandWrapper} data-hide={hide}>
<button
className={aiIslandBtn}
data-testid="ai-island"

View File

@@ -1,5 +1,5 @@
import { cssVar } from '@toeverything/theme';
import { createVar, keyframes, style } from '@vanilla-extract/css';
import { style } from '@vanilla-extract/css';
export const toolStyle = style({
selectors: {
@@ -49,84 +49,3 @@ export const aiIslandBtn = style({
},
},
});
// -------- animation --------
export const borderAngle1 = createVar('border-angle-1');
export const borderAngle2 = createVar('border-angle-2');
export const borderAngle3 = createVar('border-angle-3');
const brightBlue = createVar('bright-blue');
const brightGreen = createVar('bright-green');
const brightRed = createVar('bright-red');
const borderWidth = createVar('border-width');
const rotateBg = keyframes({
to: { transform: 'rotate(360deg)' },
});
export const aiIslandAnimationBg = style({
width: 'inherit',
height: 'inherit',
top: 0,
left: 0,
position: 'absolute',
borderRadius: '50%',
overflow: 'hidden',
vars: {
[borderAngle1]: '0deg',
[borderAngle2]: '90deg',
[borderAngle3]: '180deg',
[brightBlue]: 'rgb(0, 100, 255)',
[brightGreen]: '#1E96EB',
[brightRed]: 'rgb(0, 200, 255)',
[borderWidth]: '1.5px',
},
backgroundColor: 'transparent',
selectors: {
[`${aiIslandWrapper}[data-animation="true"] &`]: {
width: `calc(100% + 2 * ${borderWidth})`,
height: `calc(100% + 2 * ${borderWidth})`,
top: `calc(-1 * ${borderWidth})`,
left: `calc(-1 * ${borderWidth})`,
},
},
});
export const gradient = style({
position: 'absolute',
width: '100%',
height: '100%',
borderRadius: 'inherit',
animationName: rotateBg,
animationIterationCount: 'infinite',
animationTimingFunction: 'linear',
pointerEvents: 'none',
willChange: 'transform',
selectors: {
[`&:nth-of-type(1)`]: {
animationDuration: '3s',
backgroundImage: `conic-gradient(from ${borderAngle1} at 50% 50%,
transparent, ${brightBlue} 10%,
transparent 30%,
transparent
)`,
},
[`&:nth-of-type(2)`]: {
animationDuration: '8s',
backgroundImage: `conic-gradient(from ${borderAngle2} at 50% 50%,
transparent, ${brightGreen} 10%,
transparent 60%,
transparent
)`,
},
[`&:nth-of-type(3)`]: {
animationDuration: '13s',
backgroundImage: `conic-gradient(from ${borderAngle3} at 50% 50%,
transparent, ${brightRed} 10%,
transparent 50%,
transparent
)`,
},
},
});

View File

@@ -42,7 +42,7 @@ const CloudWorkspaceStatus = () => {
const SyncingWorkspaceStatus = ({ progress }: { progress?: number }) => {
return (
<>
<Loading progress={progress} speed={progress ? 0 : undefined} />
<Loading progress={progress} speed={0} />
Syncing...
</>
);

View File

@@ -107,6 +107,7 @@ globalStyle(`.${workspaceActiveStatus} svg`, {
width: 16,
height: 16,
color: cssVar('iconSecondary'),
display: 'block',
});
export const workspaceInfoTooltip = style({