Skip to content

Commit

Permalink
docs: add fallback for previewer (ant-design#44327)
Browse files Browse the repository at this point in the history
* docs: add fallback for previewer

* chore: code clean
  • Loading branch information
MadCcc authored Aug 21, 2023
1 parent b26e3a7 commit da699b1
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions .dumi/theme/builtins/Previewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
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'));

export default (props: IPreviewerProps) => (
<Suspense fallback={null}>
<Previewer {...props} />
</Suspense>
);
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>
);
};

0 comments on commit da699b1

Please sign in to comment.