-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathreact-sfc.html
113 lines (108 loc) · 3.22 KB
/
react-sfc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<div id="sandbox-demo10"></div>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/[email protected]/dist/react-loader.js"></script>
<!-- <script src="./dist/index.umd.js"></script>
<script src="./dist/react-loader.js"></script> -->
<script type="text/javascript">
new MiniSandbox({
el: '#sandbox-demo10',
files: {
'App.jsx': {
urlField: 'app',
defaultValue: `import React, { useState } from 'react'
import antd from 'antd'
const { Button, Pagination, Badge, Space, Switch, Alert } = antd
export default function App() {
const [show, setShow] = useState(true)
return <>
{/* 按钮组件 */}
<Space>
<Button type="primary">普通按钮</Button>
<Button type="primary" loading>加载中</Button>
<Button type="primary" danger>危险按钮</Button>
<Button type="link">文字按钮</Button>
<Button>默认按钮</Button>
</Space>
<Button type="primary" block>超长按钮</Button>
{/* 徽章组件 */}
<Space>
<Switch checked={show} onChange={() => setShow(!show)} />
<Badge count={show ? 25 : 0} />
<Badge
count={show ? 109 : 0}
style={{ backgroundColor: '#52c41a' }}
/>
</Space>
{/* 分页组件 */}
<div>
<Pagination
showSizeChanger
defaultCurrent={3}
total={500}
/>
</div>
{/* 警告提示 */}
<Alert message="Success Tips" type="success" showIcon />
<Alert message="Informational Notes" type="info" showIcon />
<Alert message="Warning" type="warning" showIcon closable />
<Alert message="Error" type="error" showIcon />
</>
}`,
},
'Child.jsx': {
module: 'esm',
template: false,
urlField: 'child',
defaultValue: `
import React, { useState } from 'react'
export default function Demo() {
return <h1>标题</h1>
}
`,
},
},
loaders: {
'.jsx': SandboxReactLoader
},
defaultConfig: {
height: '100vh'
},
publicConfig: {
cssLibs: ['https://unpkg.com/[email protected]/dist/antd.min.css'],
css: `body { padding: 10px; } #root>div { margin: 10px 0; }`,
importMap: {
"imports": {
"react": "https://esm.sh/[email protected]/index.js",
"react-dom": "https://esm.sh/[email protected]/index.js",
"antd": "https://esm.sh/[email protected]/dist/antd.js",
"moment": "https://esm.sh/[email protected]/moment.js",
"@lucky-canvas/react": "https://unpkg.com/@lucky-canvas/[email protected]/dist/index.esm.js"
},
"scopes": {
"https://esm.sh/": {
"object-assign": "https://esm.sh/[email protected]/index.js",
"scheduler": "https://esm.sh/[email protected]/index.js",
"scheduler/tracing": "https://esm.sh/[email protected]/tracing.js",
}
}
},
}
})
</script>
</body>
</html>