2023-08-21 14:38:22 +08:00
|
|
|
import React, { Suspense } from 'react';
|
2023-02-20 10:51:18 +08:00
|
|
|
import type { IPreviewerProps } from 'dumi';
|
2023-08-22 19:00:06 +08:00
|
|
|
import { Skeleton, Alert } from 'antd';
|
2023-08-21 23:28:14 +08:00
|
|
|
import { createStyles } from 'antd-style';
|
2023-02-20 10:51:18 +08:00
|
|
|
|
2023-08-22 19:00:06 +08:00
|
|
|
const { ErrorBoundary } = Alert;
|
|
|
|
|
2023-08-21 14:38:22 +08:00
|
|
|
const Previewer = React.lazy(() => import('./Previewer'));
|
2023-04-11 10:13:58 +08:00
|
|
|
|
2023-08-21 23:28:14 +08:00
|
|
|
const useStyle = createStyles(({ css }) => ({
|
|
|
|
skeletonWrapper: css`
|
|
|
|
width: 100% !important;
|
|
|
|
height: 500px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
`,
|
|
|
|
}));
|
|
|
|
|
|
|
|
export default (props: IPreviewerProps) => {
|
|
|
|
const { styles } = useStyle();
|
|
|
|
return (
|
2023-08-22 19:00:06 +08:00
|
|
|
<ErrorBoundary>
|
|
|
|
<Suspense
|
|
|
|
fallback={
|
|
|
|
<Skeleton.Node
|
|
|
|
active
|
|
|
|
className={styles.skeletonWrapper}
|
|
|
|
style={{
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{' '}
|
|
|
|
</Skeleton.Node>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<Previewer {...props} />
|
|
|
|
</Suspense>
|
|
|
|
</ErrorBoundary>
|
2023-08-21 23:28:14 +08:00
|
|
|
);
|
|
|
|
};
|