File size: 1,520 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import React, { Suspense } from 'react';
import { Skeleton } from 'antd';
import { createStyles } from 'antd-style';
const IconSearch = React.lazy(() => import('./IconSearch'));
const useStyle = createStyles(({ token, css }) => ({
searchWrapper: css`
display: flex;
gap: ${token.padding}px;
> *:first-child {
flex: 0 0 328px;
}
> *:last-child {
flex: 1;
}
`,
fallbackWrapper: css`
display: flex;
flex-wrap: wrap;
justify-content: space-between;
> * {
flex: 0 0 15%;
margin: ${token.marginXXS}px 0;
}
`,
skeletonWrapper: css`
text-align: center;
> * {
width: 100% !important;
}
`,
}));
const IconSearchFallback: React.FC = () => {
const { styles } = useStyle();
return (
<>
<div className={styles.searchWrapper}>
<Skeleton.Button active style={{ width: '100%', height: 40 }} />
<Skeleton.Input active style={{ width: '100%', height: 40 }} />
</div>
<Skeleton.Button active style={{ margin: '28px 0 10px', width: 100 }} />
<div className={styles.fallbackWrapper}>
{Array.from({ length: 24 }).map((_, index) => (
<div key={index} className={styles.skeletonWrapper}>
<Skeleton.Node active style={{ height: 110, width: '100%' }}>
{' '}
</Skeleton.Node>
</div>
))}
</div>
</>
);
};
export default () => (
<Suspense fallback={<IconSearchFallback />}>
<IconSearch />
</Suspense>
);
|