-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: document support Sandpack component (#4551)
* feat: adjust ts template dependencies handle method * feat: add @modern-js/sandpack-react package * feat: doc support Sandpack component * fix: isTs name * docs: changeset * fix: tsconfig config * fix: comments
- Loading branch information
Showing
35 changed files
with
1,026 additions
and
126 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,7 @@ | ||
--- | ||
'@modern-js/sandpack-react': patch | ||
--- | ||
|
||
feat: add @modern-js/sandpack-react package | ||
|
||
feat: 增加 @modern-js/sandpack-react 包 |
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,9 @@ | ||
--- | ||
'@modern-js/module-generator': minor | ||
'@modern-js/base-generator': minor | ||
'@modern-js/mwa-generator': minor | ||
--- | ||
|
||
feat: adjust ts template, handle dependencies through handlebars | ||
|
||
feat: 调整生成器 ts 模板,使用 handlebars 处理依赖 |
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,7 @@ | ||
.light { | ||
--sp-layout-height: 500px !important; | ||
} | ||
|
||
.dark { | ||
--sp-layout-height: 500px !important; | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/document/main-doc/src/components/Sandpack/index.tsx
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,28 @@ | ||
import ModernSandpack, { ModernSandpackProps } from '@modern-js/sandpack-react'; | ||
import React, { PropsWithChildren } from 'react'; | ||
import { useDark } from 'rspress/runtime'; | ||
|
||
import './index.css'; | ||
|
||
const Sandpack = (props: PropsWithChildren<ModernSandpackProps>) => { | ||
const dark = useDark(); | ||
const { children, ...otherProps } = props; | ||
const files: Record<string, string> = {}; | ||
React.Children.forEach(children, (child: any) => { | ||
if (child) { | ||
const { meta, children } = child.props.children.props; | ||
const matches = meta.match(/title="(.*)"/); | ||
if (matches.length > 1) { | ||
files[matches[1]] = children; | ||
} | ||
} | ||
}); | ||
return ( | ||
<ModernSandpack | ||
files={files} | ||
theme={dark ? 'dark' : 'light'} | ||
{...otherProps} | ||
/> | ||
); | ||
}; | ||
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['@modern-js'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.json'], | ||
}, | ||
ignorePatterns: [ | ||
'src/templates/common.ts', | ||
'src/templates/mwa.ts', | ||
'src/templates/module.ts', | ||
], | ||
}; |
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 @@ | ||
src/templates/common.ts | ||
src/templates/mwa.ts | ||
src/templates/module.ts |
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,31 @@ | ||
.DS_Store | ||
|
||
.pnp | ||
.pnp.js | ||
.env.local | ||
.env.*.local | ||
*.log* | ||
|
||
node_modules/ | ||
*.tsbuildinfo | ||
.eslintcache | ||
|
||
coverage/ | ||
output/ | ||
output_resource/ | ||
tests/ | ||
|
||
.vscode/**/* | ||
!.vscode/settings.json | ||
!.vscode/extensions.json | ||
.idea/ | ||
|
||
src/ | ||
|
||
modern.config.js | ||
modern.config.ts | ||
jest.config.js | ||
.eslintrc.js | ||
.eslintrc | ||
tsconfig.json | ||
|
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021-present Modern.js | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,26 @@ | ||
<p align="center"> | ||
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a> | ||
</p> | ||
|
||
<h1 align="center">Modern.js</h1> | ||
|
||
<p align="center"> | ||
A Progressive React Framework for modern web development. | ||
</p> | ||
|
||
## Getting Started | ||
|
||
Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js. | ||
|
||
## Documentation | ||
|
||
- [English Documentation](https://modernjs.dev/en/) | ||
- [中文文档](https://modernjs.dev) | ||
|
||
## Contributing | ||
|
||
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md). | ||
|
||
## License | ||
|
||
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE). |
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,7 @@ | ||
const sharedConfig = require('@scripts/jest-config'); | ||
|
||
/** @type {import('@jest/types').Config.InitialOptions} */ | ||
module.exports = { | ||
...sharedConfig, | ||
rootDir: __dirname, | ||
}; |
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,5 @@ | ||
const { universalBuildConfig } = require('@scripts/build'); | ||
|
||
module.exports = { | ||
buildConfig: universalBuildConfig, | ||
}; |
Oops, something went wrong.