From ed8e526f71ff853be05b919d267fba52cc044d0d Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Thu, 7 Dec 2023 15:34:09 +0000 Subject: [PATCH] fix(core): remove duplicate loading component (#5168) --- packages/frontend/component/src/index.ts | 1 + .../src/ui/loading/loading.stories.tsx | 2 +- .../component/src/ui/loading/loading.tsx | 21 ++++++----- .../about/update-check-section.tsx | 2 +- .../workspace-card/index.css.ts | 17 --------- .../workspace-card/index.tsx | 2 +- .../workspace-card/loading-icon.tsx | 35 ------------------- 7 files changed, 17 insertions(+), 63 deletions(-) delete mode 100644 packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.css.ts delete mode 100644 packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/loading-icon.tsx diff --git a/packages/frontend/component/src/index.ts b/packages/frontend/component/src/index.ts index bd9d76dc72..aed6a07316 100644 --- a/packages/frontend/component/src/index.ts +++ b/packages/frontend/component/src/index.ts @@ -7,6 +7,7 @@ export * from './ui/divider'; export * from './ui/empty'; export * from './ui/input'; export * from './ui/layout'; +export * from './ui/loading'; export * from './ui/lottie/collections-icon'; export * from './ui/lottie/delete-icon'; export * from './ui/menu'; diff --git a/packages/frontend/component/src/ui/loading/loading.stories.tsx b/packages/frontend/component/src/ui/loading/loading.stories.tsx index 59a08780a8..ec1d8ca25a 100644 --- a/packages/frontend/component/src/ui/loading/loading.stories.tsx +++ b/packages/frontend/component/src/ui/loading/loading.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryFn } from '@storybook/react'; -import { Loading, type LoadingProps } from '.'; +import { Loading, type LoadingProps } from './loading'; export default { title: 'UI/Loading', diff --git a/packages/frontend/component/src/ui/loading/loading.tsx b/packages/frontend/component/src/ui/loading/loading.tsx index 78f7f39513..49e72705c2 100644 --- a/packages/frontend/component/src/ui/loading/loading.tsx +++ b/packages/frontend/component/src/ui/loading/loading.tsx @@ -11,20 +11,25 @@ export const Loading = ({ size, speed = 1.2 }: LoadingProps) => { return ( ); }; diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/about/update-check-section.tsx b/packages/frontend/core/src/components/affine/setting-modal/general-setting/about/update-check-section.tsx index 4aaef0b709..b28d545861 100644 --- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/about/update-check-section.tsx +++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/about/update-check-section.tsx @@ -1,3 +1,4 @@ +import { Loading } from '@affine/component'; import { SettingRow } from '@affine/component/setting-components'; import { Button } from '@affine/component/ui/button'; import { useAFFiNEI18N } from '@affine/i18n/hooks'; @@ -13,7 +14,6 @@ import clsx from 'clsx'; import { useAtomValue } from 'jotai'; import { useCallback, useMemo, useState } from 'react'; -import { Loading } from '../../../../pure/workspace-slider-bar/workspace-card/loading-icon'; import * as styles from './style.css'; enum CheckUpdateStatus { diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.css.ts b/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.css.ts deleted file mode 100644 index 465f98986e..0000000000 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.css.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { createVar, keyframes, style } from '@vanilla-extract/css'; - -export const speedVar = createVar('speedVar'); - -const rotate = keyframes({ - '0%': { transform: 'rotate(0deg)' }, - '50%': { transform: 'rotate(180deg)' }, - '100%': { transform: 'rotate(360deg)' }, -}); -export const loading = style({ - vars: { - [speedVar]: '1.5s', - }, - textRendering: 'optimizeLegibility', - WebkitFontSmoothing: 'antialiased', - animation: `${rotate} ${speedVar} infinite linear`, -}); diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.tsx index ce005f65b9..ed06618827 100644 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.tsx +++ b/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/index.tsx @@ -1,4 +1,5 @@ import { Avatar } from '@affine/component/ui/avatar'; +import { Loading } from '@affine/component/ui/loading'; import { Tooltip } from '@affine/component/ui/tooltip'; import { useCurrentSyncEngine } from '@affine/core/hooks/current/use-current-sync-engine'; import { WorkspaceFlavour } from '@affine/env/workspace'; @@ -27,7 +28,6 @@ import { import { useSystemOnline } from '../../../../hooks/use-system-online'; import type { AllWorkspace } from '../../../../shared'; -import { Loading } from './loading-icon'; import { StyledSelectorContainer, StyledSelectorWrapper, diff --git a/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/loading-icon.tsx b/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/loading-icon.tsx deleted file mode 100644 index 9921cf517d..0000000000 --- a/packages/frontend/core/src/components/pure/workspace-slider-bar/workspace-card/loading-icon.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { assignInlineVars } from '@vanilla-extract/dynamic'; - -import { loading, speedVar } from './index.css'; - -export type LoadingProps = { - size?: number; - speed?: number; -}; - -export const Loading = ({ size, speed = 1.2 }: LoadingProps) => { - return ( - - - - - ); -};