-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dropdown component for visualising oneOf
- Loading branch information
Brendan Abbott
committed
Jun 6, 2017
1 parent
7568dcc
commit 6823996
Showing
4 changed files
with
59 additions
and
11 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,38 @@ | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
import './BodySchemaSwitcher.scss' | ||
|
||
export default class BodySchemaSwitcher extends Component { | ||
constructor (props) { | ||
super(props) | ||
|
||
this.handleChange = this.handleChange.bind(this) | ||
} | ||
|
||
handleChange (event) { | ||
if (this.props.onChange) { | ||
this.props.onChange(event.target.value) | ||
} | ||
} | ||
|
||
render () { | ||
const { options } = this.props | ||
|
||
return ( | ||
<form className='body-schema-switcher-form'> | ||
<label>This schema can be fulfilled by multiple options: </label> | ||
<select onChange={this.handleChange}> | ||
{options.map( | ||
(option, i) => <option key={i} value={i}>{`Option ${i + 1}`}</option> | ||
)} | ||
</select> | ||
</form> | ||
) | ||
} | ||
} | ||
|
||
BodySchemaSwitcher.propTypes = { | ||
options: PropTypes.array.isRequired, | ||
onChange: PropTypes.func | ||
} |
Empty file.