ant-design/.dumi/theme/builtins/Previewer/index.tsx
MadCcc da699b11be
docs: add fallback for previewer (#44327)
* docs: add fallback for previewer

* chore: code clean
2023-08-21 23:28:14 +08:00

37 lines
788 B
TypeScript

import React, { Suspense } from 'react';
import type { IPreviewerProps } from 'dumi';
import { Skeleton } from 'antd';
import { createStyles } from 'antd-style';
const Previewer = React.lazy(() => import('./Previewer'));
const useStyle = createStyles(({ css }) => ({
skeletonWrapper: css`
width: 100% !important;
height: 500px;
margin-bottom: 16px;
`,
}));
export default (props: IPreviewerProps) => {
const { styles } = useStyle();
return (
<Suspense
fallback={
<Skeleton.Node
active
className={styles.skeletonWrapper}
style={{
width: '100%',
height: '100%',
}}
>
{' '}
</Skeleton.Node>
}
>
<Previewer {...props} />
</Suspense>
);
};