mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-26 01:42:30 +08:00
67165a78fc
* docs: live demo * chore: bump dumi * chore: fix lint * chore: fix lint * chore: update demo * chore: bump dumi * docs: enhance live demo * docs: update text
39 lines
923 B
TypeScript
39 lines
923 B
TypeScript
import React from 'react';
|
|
import type { IPreviewerProps } from 'dumi';
|
|
import { LiveProvider, useTabMeta } from 'dumi';
|
|
|
|
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} />;
|
|
}
|
|
|
|
const codePreviewer = <CodePreviewer {...props} />;
|
|
|
|
if (props.live === false || props.iframe) {
|
|
return codePreviewer;
|
|
}
|
|
|
|
return (
|
|
<LiveProvider
|
|
initialCode={
|
|
Object.entries(props.asset.dependencies).filter(([, { type }]) => type === 'FILE')[0][1]
|
|
.value
|
|
}
|
|
demoId={props.asset.id}
|
|
>
|
|
{codePreviewer}
|
|
</LiveProvider>
|
|
);
|
|
};
|
|
|
|
export default Previewer;
|