forked from teslamotors/informed
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
204 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Text from './components/form-fields/Text'; | ||
import Radio from './components/form-fields/Radio'; | ||
import TextArea from './components/form-fields/TextArea'; | ||
import Select from './components/form-fields/Select'; | ||
import Option from './components/form-fields/Option'; | ||
import Checkbox from './components/form-fields/Checkbox'; | ||
import RadioGroup from './components/form-fields/RadioGroup'; | ||
|
||
export default { | ||
select: Select, | ||
input: Text, | ||
textarea: TextArea, | ||
checkbox: Checkbox, | ||
radio: RadioGroup | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# JSON Schema Form | ||
|
||
```jsx | ||
import { Form } from 'informed'; | ||
|
||
const schema = { | ||
properties: { | ||
name: { | ||
type: 'string', | ||
title: 'First name', | ||
'ui:control': 'input' | ||
}, | ||
model: { | ||
type: 'string', | ||
title: 'Model', | ||
'ui:control': 'select', | ||
oneOf: [ | ||
{ | ||
const: '', | ||
title: '- Select -', | ||
'ui:disabled': true | ||
}, | ||
{ const: 'ms', title: 'Model S' }, | ||
{ const: 'm3', title: 'Model 3' }, | ||
{ const: 'mx', title: 'Model X' }, | ||
{ const: 'my', title: 'Model Y' } | ||
] | ||
} | ||
} | ||
}; | ||
|
||
const Schema = () => ( | ||
<Form schema={schema}> | ||
<FormState /> | ||
</Form> | ||
); | ||
``` | ||
|
||
<!-- STORY --> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import withDocs from '../../utils/withDocs'; | ||
import readme from './README.md'; | ||
import FormState from '../../utils/FormState'; | ||
|
||
import { Form } from '../../../src'; | ||
|
||
const schema = { | ||
properties: { | ||
name: { | ||
type: 'string', | ||
title: 'First name', | ||
'ui:control': 'input' | ||
}, | ||
color: { | ||
type: 'string', | ||
title: 'Color', | ||
'ui:control': 'select', | ||
oneOf: [ | ||
{ | ||
const: '', | ||
title: '- Select -', | ||
'ui:disabled': true | ||
}, | ||
{ const: 'red', title: 'Red' }, | ||
{ const: 'black', title: 'Black' }, | ||
{ const: 'white', title: 'White' } | ||
] | ||
}, | ||
model: { | ||
type: 'string', | ||
title: 'Model', | ||
oneOf: [ | ||
{ const: 'ms', title: 'Model S' }, | ||
{ const: 'm3', title: 'Model 3' }, | ||
{ const: 'mx', title: 'Model X' }, | ||
{ const: 'my', title: 'Model Y' } | ||
], | ||
'ui:control': 'radio', | ||
default: null | ||
} | ||
} | ||
}; | ||
|
||
const Schema = () => ( | ||
<Form schema={schema}> | ||
<FormState /> | ||
</Form> | ||
); | ||
|
||
export default withDocs(readme, Schema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters