@@ -4,11 +4,14 @@ import CodeSandbox from '@uiw/react-codesandbox';
4
4
import Codepen from '@uiw/react-codepen' ;
5
5
import { Button } from 'uiw' ;
6
6
7
+ const Preview = CodeLayout . Preview ;
8
+ const Code = CodeLayout . Code ;
9
+ const Toolbar = CodeLayout . Toolbar ;
10
+
7
11
const code = `import React from "react";\nimport { Button } from "uiw";\nconst Demo = ()=>{\n return<div><Button>按钮</Button></div>\n};\nexport default Demo;` ;
8
12
9
13
const codePenOptions = {
10
14
title : `demo` ,
11
- includeModule : [ 'uiw' ] ,
12
15
js : `${ code . replace (
13
16
'export default' ,
14
17
'const APP_render =' ,
@@ -47,70 +50,104 @@ const App = () => {
47
50
< React . Fragment >
48
51
< fieldset >
49
52
< legend > 基础</ legend >
50
- < CodeLayout title = "示例" code = { < pre > { code } </ pre > } text = { code } >
51
- < Button > 按钮</ Button >
53
+ < CodeLayout >
54
+ < Preview >
55
+ < Button > 按钮</ Button >
56
+ </ Preview >
57
+ < Toolbar text = { code } > 示例</ Toolbar >
58
+ < Code >
59
+ < pre > { code } </ pre >
60
+ </ Code >
52
61
</ CodeLayout >
53
62
</ fieldset >
54
63
55
64
< fieldset >
56
65
< legend > 禁用方格背景</ legend >
57
- < CodeLayout code = { < pre > { code } </ pre > } text = { code } disableCheckered >
58
- < Button > 禁用方格背景</ Button >
66
+ < CodeLayout disableCheckered >
67
+ < Preview >
68
+ < Button > 禁用方格背景</ Button >
69
+ </ Preview >
70
+ < Toolbar text = { code } > 示例</ Toolbar >
71
+ < Code >
72
+ < pre > { code } </ pre >
73
+ </ Code >
59
74
</ CodeLayout >
60
75
</ fieldset >
61
76
62
77
< fieldset >
63
78
< legend > 无边框</ legend >
64
- < CodeLayout code = { < pre > { code } </ pre > } text = { code } bordered = { false } >
65
- < Button > 按钮</ Button >
79
+ < CodeLayout bordered = { false } >
80
+ < Preview >
81
+ < Button > 无边框</ Button >
82
+ </ Preview >
83
+ < Toolbar text = { code } > 示例</ Toolbar >
84
+ < Code >
85
+ < pre > { code } </ pre >
86
+ </ Code >
66
87
</ CodeLayout >
67
88
</ fieldset >
68
89
69
90
< fieldset >
70
91
< legend > 第三方预览按钮</ legend >
71
- < CodeLayout
72
- code = { < pre > { code } </ pre > }
73
- text = { code }
74
- toolbarExtra = {
75
- < Fragment >
76
- < CodeSandbox { ...codeSandboxOptions } >
77
- < svg viewBox = "0 0 1024 1024" width = "18" height = "18" >
78
- < path
79
- d = "M85.333333 256l446.08-256L977.493333 256 981.333333 765.866667 531.413333 1024 85.333333 768V256z m89.088 105.856v202.965333l142.72 79.36v150.016l169.472 97.962667v-352.938667L174.421333 361.856z m714.197334 0l-312.192 177.365333v352.938667l169.472-97.962667V644.266667l142.72-79.402667V361.813333zM219.050667 281.642667l311.594666 176.810666 312.32-178.346666-165.162666-93.738667-145.493334 82.986667-146.346666-83.968L219.008 281.6z"
80
- p-id = "4089"
81
- > </ path >
82
- </ svg >
83
- </ CodeSandbox >
84
- < Codepen { ...codePenOptions } >
85
- < svg viewBox = "0 0 1024 1024" width = "18" height = "18" >
86
- < path
87
- d = "M85.333333 256l446.08-256L977.493333 256 981.333333 765.866667 531.413333 1024 85.333333 768V256z m89.088 105.856v202.965333l142.72 79.36v150.016l169.472 97.962667v-352.938667L174.421333 361.856z m714.197334 0l-312.192 177.365333v352.938667l169.472-97.962667V644.266667l142.72-79.402667V361.813333zM219.050667 281.642667l311.594666 176.810666 312.32-178.346666-165.162666-93.738667-145.493334 82.986667-146.346666-83.968L219.008 281.6z"
88
- p-id = "4089"
89
- > </ path >
90
- </ svg >
91
- </ Codepen >
92
- </ Fragment >
93
- }
94
- >
95
- < Button > 按钮</ Button >
92
+ < CodeLayout bordered = { false } >
93
+ < Preview >
94
+ < Button > 第三方预览按钮</ Button >
95
+ </ Preview >
96
+ < Toolbar
97
+ text = { code }
98
+ extra = {
99
+ < Fragment >
100
+ < CodeSandbox { ...codeSandboxOptions } >
101
+ < svg viewBox = "0 0 1024 1024" width = "18" height = "18" >
102
+ < path
103
+ d = "M85.333333 256l446.08-256L977.493333 256 981.333333 765.866667 531.413333 1024 85.333333 768V256z m89.088 105.856v202.965333l142.72 79.36v150.016l169.472 97.962667v-352.938667L174.421333 361.856z m714.197334 0l-312.192 177.365333v352.938667l169.472-97.962667V644.266667l142.72-79.402667V361.813333zM219.050667 281.642667l311.594666 176.810666 312.32-178.346666-165.162666-93.738667-145.493334 82.986667-146.346666-83.968L219.008 281.6z"
104
+ p-id = "4089"
105
+ > </ path >
106
+ </ svg >
107
+ </ CodeSandbox >
108
+ < Codepen { ...codePenOptions } >
109
+ < svg viewBox = "0 0 1024 1024" width = "18" height = "18" >
110
+ < path
111
+ d = "M85.333333 256l446.08-256L977.493333 256 981.333333 765.866667 531.413333 1024 85.333333 768V256z m89.088 105.856v202.965333l142.72 79.36v150.016l169.472 97.962667v-352.938667L174.421333 361.856z m714.197334 0l-312.192 177.365333v352.938667l169.472-97.962667V644.266667l142.72-79.402667V361.813333zM219.050667 281.642667l311.594666 176.810666 312.32-178.346666-165.162666-93.738667-145.493334 82.986667-146.346666-83.968L219.008 281.6z"
112
+ p-id = "4089"
113
+ > </ path >
114
+ </ svg >
115
+ </ Codepen >
116
+ </ Fragment >
117
+ }
118
+ >
119
+ 示例
120
+ </ Toolbar >
121
+ < Code >
122
+ < pre > { code } </ pre >
123
+ </ Code >
96
124
</ CodeLayout >
97
125
</ fieldset >
98
126
99
127
< fieldset >
100
128
< legend > 自定义操作按钮</ legend >
101
- < CodeLayout
102
- code = { < pre > { code } </ pre > }
103
- text = { code }
104
- toolbarExtra = { < button style = { { marginRight : 30 } } > 操作按钮</ button > }
105
- >
106
- < Button > 按钮</ Button >
129
+ < CodeLayout bordered = { false } >
130
+ < Preview >
131
+ < Button > 无边框</ Button >
132
+ </ Preview >
133
+ < Toolbar text = { code } extra = { < button style = { { marginRight : 30 } } > 操作按钮</ button > } >
134
+ 示例
135
+ </ Toolbar >
136
+ < Code >
137
+ < pre > { code } </ pre >
138
+ </ Code >
107
139
</ CodeLayout >
108
140
</ fieldset >
109
141
110
142
< fieldset >
111
143
< legend > 禁用工具栏</ legend >
112
- < CodeLayout code = { < pre > { code } </ pre > } text = { code } disableToolbar >
113
- < Button > 按钮</ Button >
144
+ < CodeLayout bordered = { false } >
145
+ < Preview >
146
+ < Button > 无边框</ Button >
147
+ </ Preview >
148
+ < Code >
149
+ < pre > { code } </ pre >
150
+ </ Code >
114
151
</ CodeLayout >
115
152
</ fieldset >
116
153
</ React . Fragment >
0 commit comments