@@ -8,6 +8,7 @@ import ArrayFieldTemplate from '../ArrayFieldTemplate/ArrayFieldTemplate';
8
8
import ArrayFieldItemTemplate from '../ArrayFieldItemTemplate/ArrayFieldItemTemplate' ;
9
9
import FieldErrorTemplate from "../FieldErrorTemplate/FieldErrorTemplate" ;
10
10
import FieldTemplate from "../FieldTemplate/FieldTemplate" ;
11
+ import ObjectFieldTemplate from "../ObjectFieldTemplate/ObjectFieldTemplate" ;
11
12
const qs = require ( 'qs' ) ;
12
13
const { useHistory, useLocation } = require ( '@docusaurus/router' ) ;
13
14
@@ -27,55 +28,46 @@ interface Props {
27
28
} ;
28
29
}
29
30
30
-
31
- /* function ArrayFieldTemplate(props: ArrayFieldTemplateProps) {
32
- * console.log(props);
33
- * const ArrayFieldItemTemplateFromProps
34
- * return (
35
- * <div className="container">
36
- * <div className="row">
37
- * {props.title && <b className="col col--9">{props.title}</b>}
38
- * {
39
- * props.canAdd &&
40
- * <div className="col col--3">
41
- * <button className="button button--block button--outline button--primary" type='button' onClick={props.onAddClick}>+</button>
42
- * </div>
43
- * }
44
- * </div>
45
- *
46
- * <div className="row">
47
- * <div className="col col--12">
48
- * {props.items.map((element) => element.children)}
49
- * </div>
50
- * </div>
51
- * </div>
52
- * );
53
- * } */
54
-
55
31
function AddButton ( props : IconButtonProps ) {
56
32
const { icon, iconType, ...btnProps } = props ;
57
33
return (
58
- < button { ...btnProps } className = { btnProps . className + " button button--outline button-- primary" } type = 'button' > +</ button >
34
+ < button { ...btnProps } className = { btnProps . className + " button button--primary" } type = 'button' > +</ button >
59
35
) ;
60
36
}
61
37
62
38
function RemoveButton ( props : IconButtonProps ) {
63
39
const { icon, iconType, ...btnProps } = props ;
40
+ const style = {
41
+ ...btnProps . style ,
42
+ minWidth : '35px' ,
43
+ maxWidth : '36px' ,
44
+ border : undefined
45
+ } ;
64
46
return (
65
- < button { ...btnProps } className = "button button--outline button--primary" type = 'button' > -</ button >
47
+ < button { ...btnProps } style = { style } className = "button button--outline button--primary" type = 'button' > -</ button >
66
48
) ;
67
49
}
68
50
function MoveUpButton ( props : IconButtonProps ) {
69
51
const { icon, iconType, ...btnProps } = props ;
52
+ const style = {
53
+ ...btnProps . style ,
54
+ minWidth : '35px' ,
55
+ maxWidth : '36px' ,
56
+ } ;
70
57
return (
71
- < button { ...btnProps } className = "button button--outline button--primary" type = 'button' > ▲</ button >
58
+ < button { ...btnProps } style = { style } className = "button button--outline button--primary" type = 'button' > ▲</ button >
72
59
) ;
73
60
}
74
61
75
62
function MoveDownButton ( props : IconButtonProps ) {
76
63
const { icon, iconType, ...btnProps } = props ;
64
+ const style = {
65
+ ...btnProps . style ,
66
+ minWidth : '35px' ,
67
+ maxWidth : '36px' ,
68
+ } ;
77
69
return (
78
- < button { ...btnProps } className = "button button--outline button--primary" type = 'button' > ▼</ button >
70
+ < button { ...btnProps } style = { style } className = "button button--outline button--primary" type = 'button' > ▼</ button >
79
71
) ;
80
72
}
81
73
@@ -110,7 +102,14 @@ const InteractiveMethodParam: React.FC<ParamProps> = (props) => {
110
102
uiSchema = { uiSchema }
111
103
validator = { validator }
112
104
ref = { refref }
113
- templates = { { ArrayFieldItemTemplate, ArrayFieldTemplate, FieldErrorTemplate, FieldTemplate, ButtonTemplates :{ AddButton, RemoveButton, MoveUpButton, MoveDownButton } } }
105
+ templates = { {
106
+ ArrayFieldItemTemplate,
107
+ ArrayFieldTemplate,
108
+ FieldErrorTemplate,
109
+ FieldTemplate,
110
+ ButtonTemplates :{ AddButton, RemoveButton, MoveUpButton, MoveDownButton } ,
111
+ ObjectFieldTemplate
112
+ } }
114
113
onChange = { props . onChange }
115
114
onError = { log ( 'errors' ) }
116
115
liveValidate
@@ -205,53 +204,59 @@ const InteractiveMethod: React.FC<Props> = (props) => {
205
204
const jsCode = `await window.ethereum.request(${ JSON . stringify ( methodCall , null , " " ) } );` ;
206
205
207
206
return (
208
- < >
207
+ < div className = "container" >
209
208
{ method . params . length > 0 &&
210
209
< >
211
- < div >
210
+ < div className = "row" >
212
211
< h3 > Params</ h3 >
213
- { method . params . map ( ( p , i ) => (
214
- < >
215
- < h4 > { ( p as ContentDescriptorObject ) . name } </ h4 >
216
- < InteractiveMethodParam
217
- refref = { formRefs [ i ] }
218
- formData = { requestParams [ ( p as ContentDescriptorObject ) . name ] }
219
- onChange = { ( change ) => handleChange ( change , i ) }
220
- param = { p as ContentDescriptorObject } />
221
- </ >
222
- ) ) }
212
+ < div className = "col col--12" >
213
+ { method . params . map ( ( p , i ) => (
214
+ < >
215
+ < h4 > { ( p as ContentDescriptorObject ) . name } </ h4 >
216
+ < InteractiveMethodParam
217
+ refref = { formRefs [ i ] }
218
+ formData = { requestParams [ ( p as ContentDescriptorObject ) . name ] }
219
+ onChange = { ( change ) => handleChange ( change , i ) }
220
+ param = { p as ContentDescriptorObject } />
221
+ </ >
222
+ ) ) }
223
+ </ div >
223
224
</ div >
224
225
< br />
225
226
</ >
226
227
}
227
- < div >
228
+ < div className = "row" >
228
229
< h3 > Request</ h3 >
229
- { components && components . CodeBlock && < components . CodeBlock className = "language-js" > { jsCode } </ components . CodeBlock > }
230
- { ! components ?. CodeBlock &&
231
- < pre >
232
- < code >
233
- { jsCode }
234
- </ code >
235
- </ pre >
236
- }
230
+ < div className = "col col--12" >
231
+ { components && components . CodeBlock && < components . CodeBlock className = "language-js" > { jsCode } </ components . CodeBlock > }
232
+ { ! components ?. CodeBlock &&
233
+ < pre >
234
+ < code >
235
+ { jsCode }
236
+ </ code >
237
+ </ pre >
238
+ }
239
+ </ div >
237
240
</ div >
238
- { executionResult !== undefined && < div >
241
+ { executionResult !== undefined && < div className = "row" >
239
242
< h3 > Response</ h3 >
240
- { components && components . CodeBlock && < components . CodeBlock className = "language-json" > { JSON . stringify ( executionResult , null , ' ' ) } </ components . CodeBlock > }
241
- { ! components ?. CodeBlock &&
242
- < pre >
243
- < code >
244
- { JSON . stringify ( executionResult , null , ' ' ) }
245
- </ code >
246
- </ pre >
247
- }
243
+ < div className = "col col--12" >
244
+ { components && components . CodeBlock && < components . CodeBlock className = "language-json" > { JSON . stringify ( executionResult , null , ' ' ) } </ components . CodeBlock > }
245
+ { ! components ?. CodeBlock &&
246
+ < pre >
247
+ < code >
248
+ { JSON . stringify ( executionResult , null , ' ' ) }
249
+ </ code >
250
+ </ pre >
251
+ }
252
+ </ div >
248
253
</ div > }
249
- < div >
254
+ < div className = "row" >
250
255
< button className = "button button--primary button--block" onClick = { handleExec } >
251
256
Send Request
252
257
</ button >
253
258
</ div >
254
- </ >
259
+ </ div >
255
260
) ;
256
261
257
262
}
0 commit comments