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: auto merge branches (ant-design#43940)
chore: merge master into feature
- Loading branch information
Showing
150 changed files
with
3,229 additions
and
660 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
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
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,3 @@ | ||
import { Sandpack } from '@codesandbox/sandpack-react'; | ||
|
||
export default Sandpack; |
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,91 @@ | ||
import type { ReactNode } from 'react'; | ||
import React, { Suspense } from 'react'; | ||
import { useSearchParams, useServerInsertedHTML } from 'dumi'; | ||
import { createStyles } from 'antd-style'; | ||
import { getSandpackCssText } from '@codesandbox/sandpack-react'; | ||
import { Skeleton } from 'antd'; | ||
|
||
const OriginSandpack = React.lazy(() => import('./Sandpack')); | ||
|
||
const setup = { | ||
dependencies: { | ||
react: '^18.0.0', | ||
'react-dom': '^18.0.0', | ||
antd: '^5.0.0', | ||
}, | ||
devDependencies: { | ||
'@types/react': '^18.0.0', | ||
'@types/react-dom': '^18.0.0', | ||
typescript: '^5', | ||
}, | ||
entry: 'index.tsx', | ||
}; | ||
|
||
const options = { | ||
activeFile: 'app.tsx' as never, | ||
visibleFiles: ['index.tsx', 'app.tsx', 'package.json'] as any, | ||
showLineNumbers: true, | ||
editorHeight: '500px', | ||
}; | ||
|
||
const indexContent = `import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import App from './app'; | ||
const root = createRoot(document.getElementById("root")); | ||
root.render(<App />); | ||
`; | ||
|
||
const useStyle = createStyles(({ token, css }) => ({ | ||
fallback: css` | ||
width: 100%; | ||
> * { | ||
width: 100% !important; | ||
border-radius: 8px; | ||
} | ||
`, | ||
placeholder: css` | ||
color: ${token.colorTextDescription}; | ||
font-size: 16px; | ||
`, | ||
})); | ||
|
||
const SandpackFallback = () => { | ||
const { styles } = useStyle(); | ||
|
||
return ( | ||
<div className={styles.fallback}> | ||
<Skeleton.Node active style={{ height: 500, width: '100%' }}> | ||
<span className={styles.placeholder}>Loading Demo...</span> | ||
</Skeleton.Node> | ||
</div> | ||
); | ||
}; | ||
|
||
const Sandpack = ({ children }: { children: ReactNode }) => { | ||
const [searchParams] = useSearchParams(); | ||
|
||
useServerInsertedHTML(() => ( | ||
<style | ||
data-sandpack="true" | ||
id="sandpack" | ||
dangerouslySetInnerHTML={{ __html: getSandpackCssText() }} | ||
/> | ||
)); | ||
|
||
return ( | ||
<Suspense fallback={<SandpackFallback />}> | ||
<OriginSandpack | ||
theme={searchParams.getAll('theme').includes('dark') ? 'dark' : undefined} | ||
customSetup={setup} | ||
options={options} | ||
files={{ | ||
'index.tsx': indexContent, | ||
'app.tsx': children, | ||
}} | ||
/> | ||
</Suspense> | ||
); | ||
}; | ||
|
||
export default Sandpack; |
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
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
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
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
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
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
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
Oops, something went wrong.