@@ -13,66 +13,16 @@ import TableCell from '@material-ui/core/TableCell';
13
13
import TableHead from '@material-ui/core/TableHead' ;
14
14
import TableRow from '@material-ui/core/TableRow' ;
15
15
import CheckIcon from '@material-ui/icons/Check' ;
16
-
17
- const indexHtml = `
18
- <html>
19
- <head>
20
- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
21
- </head>
22
- <body>
23
- <div id="root"></div>
24
- </body>
25
- </html>
26
- ` ;
27
-
28
- const jsCode = `import React, { Component } from 'react';
29
- import { render } from 'react-dom';
30
- import FormRenderer from '@data-driven-forms/react-form-renderer';
31
- import FormTemplate from '@data-driven-forms/mui-component-mapper/dist/cjs/form-template';
32
- import componentMapper from '@data-driven-forms/mui-component-mapper/dist/cjs/component-mapper';
33
-
34
- import schema from './schema'
35
-
36
- class App extends Component {
37
- render() {
38
- return (
39
- <div style={{margin: 24}}>
40
- <FormRenderer
41
- schema={schema}
42
- FormTemplate={FormTemplate}
43
- componentMapper={componentMapper}
44
- onSubmit={console.log}
45
- />
46
- </div>
47
- );
48
- }
49
- }
50
-
51
- render(<App />, document.getElementById('root'));` ;
52
-
53
- const dependencies = {
54
- react : '^16.12.0' ,
55
- 'react-dom' : '^16.12.0' ,
56
- '@data-driven-forms/react-form-renderer' : 'latest' ,
57
- '@data-driven-forms/mui-component-mapper' : 'latest' ,
58
- '@material-ui/core' : 'latest' ,
59
- '@material-ui/icons' : 'latest' ,
60
- 'prop-types' : 'latest'
61
- } ;
16
+ import { muiCode , muiHtml , muiDependencies } from '../stackblitz-templates/mui-templates' ;
62
17
63
18
const project = {
64
- files : {
65
- 'index.html' : indexHtml ,
66
- 'index.js' : jsCode
67
- } ,
68
19
settings : {
69
20
compile : {
70
21
trigger : 'auto' ,
71
22
action : 'hmr' ,
72
23
clearConsole : false
73
24
}
74
25
} ,
75
- dependencies,
76
26
template : 'javascript'
77
27
} ;
78
28
@@ -88,25 +38,37 @@ const useStyles = makeStyles((theme) => ({
88
38
}
89
39
} ) ) ;
90
40
91
- const ComponentExample = ( { baseStructure, activeMapper, componentMapper, component, ...props } ) => {
41
+ const blitzFiles = {
42
+ mui : {
43
+ 'index.html' : muiHtml ,
44
+ 'index.js' : muiCode
45
+ }
46
+ } ;
47
+
48
+ const blitzDependencies = {
49
+ mui : muiDependencies
50
+ } ;
51
+
52
+ const ComponentExample = ( { baseStructure, activeMapper, componentMapper, component } ) => {
92
53
useEffect ( ( ) => {
93
54
sdk . embedProject (
94
55
'code-target' ,
95
56
{
96
57
...project ,
58
+ dependencies : blitzDependencies [ activeMapper ] ,
97
59
files : {
98
- ...project . files ,
60
+ ...blitzFiles [ activeMapper ] ,
99
61
'schema.js' : `export default ${ JSON . stringify ( baseStructure . value , null , 2 ) } ;`
100
62
}
101
63
} ,
102
- { height : 500 , hideNavigation : true , forceEmbedLayout : true , openFile : 'schema.js' }
64
+ { height : '100%' , hideNavigation : true , forceEmbedLayout : true , openFile : 'schema.js' }
103
65
) ;
104
- } , [ ] ) ;
66
+ } , [ activeMapper , baseStructure . value ] ) ;
105
67
106
68
return (
107
69
< Grid container direction = "row" spacing = { 4 } >
108
70
< Grid item xs = { false } md = { 3 } >
109
- < Card style = { { minHeight : '100%' } } square >
71
+ < Card style = { { minHeight : 500 } } square >
110
72
< CardContent >
111
73
< Typography component = "h3" > Options</ Typography >
112
74
< Table >
0 commit comments