@@ -13,6 +13,7 @@ import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
13
13
import Paper from '@material-ui/core/Paper' ;
14
14
import clsx from 'clsx' ;
15
15
import grey from '@material-ui/core/colors/grey' ;
16
+ import { getParameters } from 'codesandbox/lib/api/define' ;
16
17
17
18
import GhIcon from './common/gh-svg-icon' ;
18
19
@@ -53,6 +54,44 @@ const useStyles = makeStyles((theme) => ({
53
54
}
54
55
} ) ) ;
55
56
57
+ const payload = getParameters ( {
58
+ files : {
59
+ 'public/index.html' : {
60
+ content :
61
+ '<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta\n name="viewport"\n content="width=device-width, initial-scale=1, shrink-to-fit=no"\n />\n <meta name="theme-color" content="#000000" />\n <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />\n <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />\n <title>Data driven forms example</title>\n\n <!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">-->\n\n <!--<link rel="stylesheet" type="text/css" href="https://unpkg.com/@patternfly/[email protected] /patternfly-base.css"/>-->\n <!--<link rel="stylesheet" type="text/css" href="https://unpkg.com/@patternfly/[email protected] /patternfly-addons.css"/>-->\n </head>\n\n <body>\n <noscript>\n You need to enable JavaScript to run this app.\n </noscript>\n <div id="root"></div>\n </body>\n</html>\n'
62
+ } ,
63
+ 'package.json' : {
64
+ content : {
65
+ name : 'data-driven-forms-example' ,
66
+ version : '1.0.0' ,
67
+ description : '' ,
68
+ keywords : [ ] ,
69
+ main : 'src/index.js' ,
70
+ dependencies : {
71
+ '@data-driven-forms/mui-component-mapper' : '2.1.2' ,
72
+ '@data-driven-forms/pf4-component-mapper' : '2.1.2' ,
73
+ '@data-driven-forms/react-form-renderer' : '2.1.2' ,
74
+ react : '16.12.0' ,
75
+ 'react-dom' : '16.12.0' ,
76
+ 'react-scripts' : '3.0.1'
77
+ } ,
78
+ devDependencies : { typescript : '3.8.3' } ,
79
+ scripts : { start : 'react-scripts start' , build : 'react-scripts build' , test : 'react-scripts test --env=jsdom' , eject : 'react-scripts eject' } ,
80
+ browserslist : [ '>0.2%' , 'not dead' , 'not ie <= 11' , 'not op_mini all' ]
81
+ }
82
+ } ,
83
+ 'src/index.js' : {
84
+ content :
85
+ 'import React from "react";\nimport ReactDOM from "react-dom";\n\nimport App from "./App";\n\nconst rootElement = document.getElementById("root");\nReactDOM.render(\n <React.StrictMode>\n <App />\n </React.StrictMode>,\n rootElement\n);\n'
86
+ } ,
87
+ 'src/App.js' : {
88
+ content : 'import React from "react";\n\nexport default function App() {\n return <div>there will be dragons</div>;\n}\n'
89
+ }
90
+ }
91
+ } ) ;
92
+
93
+ console . log ( payload ) ;
94
+
56
95
const CodeExample = ( { source, mode } ) => {
57
96
const classes = useStyles ( ) ;
58
97
const codeSource = reqSource ( `./${ source } .js` ) . default ;
@@ -67,6 +106,10 @@ const CodeExample = ({ source, mode }) => {
67
106
< ExpansionPanelSummary className = { classes . expansionPanelSummary } expandIcon = { < CodeIcon /> } >
68
107
{ Component && < Typography className = { classes . heading } > { Component . name } </ Typography > }
69
108
< Box display = "flex" >
109
+ < form action = "https://codesandbox.io/api/v1/sandboxes/define" method = "POST" target = "_blank" >
110
+ < input type = "hidden" name = "parameters" value = { payload } />
111
+ < input type = "submit" value = "Open in sandbox" />
112
+ </ form >
70
113
< Link
71
114
href = { `https://github.com/data-driven-forms/react-forms/tree/master/packages/react-renderer-demo/src/app/examples/${ source } .js` }
72
115
target = "_blank"
0 commit comments