Added untested Dropdown for select fields.

Added some more comments.
This commit is contained in:
Robbie Antenesse 2016-11-15 21:57:10 -07:00
parent 83a75016a6
commit 16193c1bf4
6 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,53 @@
import React from 'react';
import {Input} from './Input';
export class Dropdown extends Input {
constructor(props) {
super(props);
this.state = {
value: props.value || false
, isDisabled: props.isDisabled || false
};
}
// Whenever the input changes, update the value state of this component
handleOnChange(event) {
this.setState({
value: event.target.checked
});
}
parseOptions (optionsString) {
let results = [];
let options = optionsString.split(',');
options.forEach((option) => {
results.push(
<option>
{option.trim()}
</option>
);
});
return results;
}
render() {
return (
<label>
<span>
{this.props.name}
{this.showHelperLink()}
</span>
<select onChange={this.handleOnChange} disabled={(this.state.isDisabled) ? 'disabled' : null}>
{this.parseOptions(this.props.optionsList)}
</select>
</label>
);
}
}
Dropdown.defaultProps = {
doValidate: false
};

View File

@ -5,6 +5,7 @@ import {TextArea} from './TextArea';
import {WordForm} from './WordForm';
// A component that allows you to edit a word
export class EditWordForm extends React.Component {
constructor(props) {
super(props);

View File

@ -2,6 +2,7 @@ import React from 'react';
import {Button} from './Button';
// Creates a page that floats above other elements when a connected button is clicked.
export class FixedPage extends React.Component {
constructor(props) {
super(props);
@ -10,6 +11,7 @@ export class FixedPage extends React.Component {
display: false
};
// Bind each instance to its own show/hide watchers.
this.show = this.show.bind(this);
this.hide = this.hide.bind(this);
}

View File

@ -3,6 +3,7 @@ import marked from 'marked';
import {FixedPage} from './FixedPage';
// A component for the site footer
export class Footer extends React.Component {
constructor(props) {
super(props);

View File

@ -4,6 +4,7 @@ import marked from 'marked';
import {Button} from './Button';
import {FixedPage} from './FixedPage';
// A component for the site header
export class Header extends React.Component {
constructor(props) {
super(props);

View File

@ -7,6 +7,7 @@ import {Button} from './Button';
const saveIcon = <i>&#128190;</i>;
const editIcon = <i>&#128393;</i>;
// A component to show dictionary information in a tabbed interface.
export class InfoDisplay extends React.Component {
constructor(props) {
super(props);