Skip to content

Commit

Permalink
💄 style: improve loading
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 20, 2024
1 parent 2aedb73 commit c15b469
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"polished": "^4.2.2",
"qs": "^6.11.2",
"react": "^18",
"react-animated-ellipsis": "^1.0.0",
"react-dom": "^18",
"react-i18next": "^14.0.0",
"react-image-size": "^2.3.2",
Expand Down
29 changes: 29 additions & 0 deletions src/features/Preview/AnimatedEllipsis.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createStyles } from 'antd-style';
import React, { memo } from 'react';

const useStyles = createStyles(({ css, token }) => ({
container: css`
aspect-ratio: 4;
width: 24px;
background: radial-gradient(circle closest-side, ${token.colorTextLightSolid} 40%, #0000) 0 /
calc(100% / 3) 80% space;
clip-path: inset(0 100% 0 0);
animation: step 0.7s steps(4) infinite;
@keyframes step {
to {
clip-path: inset(0 -34% 0 0);
}
}
`,
}));

const ReactAnimatedEllipsis = memo(() => {
const { styles } = useStyles();

return <div className={styles.container} />;
});

export default ReactAnimatedEllipsis;
9 changes: 5 additions & 4 deletions src/features/Preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { useSize } from 'ahooks';
import { Progress } from 'antd';
import { createStyles } from 'antd-style';
import { memo, useEffect, useRef } from 'react';
// @ts-ignore
import ReactAnimatedEllipsis from 'react-animated-ellipsis';
import { useTranslation } from 'react-i18next';
import { Center } from 'react-layout-kit';

import { midjourneySelectors, useMidjourneyStore } from '@/store/midjourney';

import ReactAnimatedEllipsis from './AnimatedEllipsis';
import Guide from './Guide';
import ImagePreview from './ImagePreview';
import Loading from './Loading';
Expand All @@ -30,6 +29,7 @@ const useStyles = createStyles(({ css, token, cx, stylish, prefixCls }) => ({
border-radius: 50%;
.${prefixCls}-progress-text {
font-family: ${token.fontFamilyCode};
color: ${token.colorTextLightSolid};
}
`,
),
Expand Down Expand Up @@ -67,8 +67,9 @@ const Preview = memo(() => {
{showProgress && (
<div className={styles.process}>
{progress === 0 ? (
<Center className={styles.waiting} height={72} horizontal width={72}>
{t('task.starting')} <ReactAnimatedEllipsis fontSize="1rem" />
<Center className={styles.waiting} gap={2} height={72} horizontal width={72}>
<div>{t('task.starting')}</div>
<ReactAnimatedEllipsis />
</Center>
) : (
<Progress percent={progress} size="small" type="circle" />
Expand Down

0 comments on commit c15b469

Please sign in to comment.