-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathindex.jsx
49 lines (43 loc) · 1.37 KB
/
index.jsx
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
import ReactDOM from 'react-dom';
import ContactForm from './components/ContactForm';
import StringField from './components/StringField';
import CheckboxField from './components/CheckboxField';
// If a package dependency: import ReactJsonSchema from 'react-json-schema';
import ReactJsonSchema from '../lib/ReactJsonSchema';
const welcomeSchema = {
'component': 'h2',
'className': 'text-center',
'text': 'Hello World!'
};
const welcomeBanner = new ReactJsonSchema();
ReactDOM.render(welcomeBanner.parseSchema(welcomeSchema), document.getElementById('welcome-banner'));
const formSchema = {
'component': 'ContactForm',
'title': 'Tell us a little about yourself, we\'d appreciate it',
'children': [
{
'component': 'StringField',
'label': 'What\'s your name',
'name': 'fullname',
'help': 'It\'s okay, don\'t be shy :)'
},
{
'component': 'CheckboxField',
'checkboxes': [
{
'label': 'I\'m already checked!',
'defaultChecked': true,
'key': 0
},
{
'label': 'Here\'s another',
'key': 10
}
]
}
]
};
const componentMap = { ContactForm, StringField, CheckboxField };
const contactForm = new ReactJsonSchema();
contactForm.setComponentMap(componentMap);
ReactDOM.render(contactForm.parseSchema(formSchema), document.getElementById('json-react-schema'));