forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: split previewer (ant-design#44310)
- Loading branch information
Showing
2 changed files
with
28 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { IPreviewerProps } from 'dumi'; | ||
import { useTabMeta } from 'dumi'; | ||
import React from 'react'; | ||
import CodePreviewer from './CodePreviewer'; | ||
import DesignPreviewer from './DesignPreviewer'; | ||
|
||
export interface AntdPreviewerProps extends IPreviewerProps { | ||
originDebug?: IPreviewerProps['debug']; | ||
} | ||
|
||
const Previewer: React.FC<AntdPreviewerProps> = (props) => { | ||
const tab = useTabMeta(); | ||
|
||
if (tab?.frontmatter.title === 'Design') { | ||
return <DesignPreviewer {...props} />; | ||
} | ||
|
||
return <CodePreviewer {...props} />; | ||
}; | ||
|
||
export default Previewer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,10 @@ | ||
import React, { Suspense } from 'react'; | ||
import type { IPreviewerProps } from 'dumi'; | ||
import { useTabMeta } from 'dumi'; | ||
import React from 'react'; | ||
import CodePreviewer from './CodePreviewer'; | ||
import DesignPreviewer from './DesignPreviewer'; | ||
|
||
export interface AntdPreviewerProps extends IPreviewerProps { | ||
originDebug?: IPreviewerProps['debug']; | ||
} | ||
const Previewer = React.lazy(() => import('./Previewer')); | ||
|
||
const Previewer: React.FC<AntdPreviewerProps> = (props) => { | ||
const tab = useTabMeta(); | ||
|
||
if (tab?.frontmatter.title === 'Design') { | ||
return <DesignPreviewer {...props} />; | ||
} | ||
|
||
return <CodePreviewer {...props} />; | ||
}; | ||
|
||
export default Previewer; | ||
export default (props: IPreviewerProps) => ( | ||
<Suspense fallback={null}> | ||
<Previewer {...props} /> | ||
</Suspense> | ||
); |