diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-04-30 13:05:06 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-30 13:05:06 +0900 |
commit | 457d954e08923b4accd28a919c72d0b61db1bb98 (patch) | |
tree | 9d198f7c7d37893621d4e2a27749070a435854cd /src/settings/components/form/KeymapsForm.jsx | |
parent | 3d9a251ce293885cda57cd3eebd111f6181132f0 (diff) | |
parent | 037ee5fd40af0117a1eb8d362b4ae97429499f16 (diff) |
Merge pull request #576 from ueokande/move-to-react
Move to React
Diffstat (limited to 'src/settings/components/form/KeymapsForm.jsx')
-rw-r--r-- | src/settings/components/form/KeymapsForm.jsx | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/settings/components/form/KeymapsForm.jsx b/src/settings/components/form/KeymapsForm.jsx new file mode 100644 index 0000000..01acf61 --- /dev/null +++ b/src/settings/components/form/KeymapsForm.jsx @@ -0,0 +1,51 @@ +import './KeymapsForm.scss'; +import React from 'react'; +import PropTypes from 'prop-types'; +import Input from '../ui/Input'; +import keymaps from '../../keymaps'; + +class KeymapsForm extends React.Component { + + render() { + return <div className='form-keymaps-form'> + { + keymaps.fields.map((group, index) => { + return <div key={index} className='form-keymaps-form-field-group'> + { + group.map((field) => { + let name = field[0]; + let label = field[1]; + let value = this.props.value[name] || ''; + return <Input + type='text' id={name} name={name} key={name} + label={label} value={value} + onChange={this.bindValue.bind(this)} + onBlur={this.props.onBlur} + />; + }) + } + </div>; + }) + } + </div>; + } + + bindValue(e) { + let next = { ...this.props.value }; + next[e.target.name] = e.target.value; + + this.props.onChange(next); + } +} + +KeymapsForm.propTypes = { + value: PropTypes.objectOf(PropTypes.string), + onChange: PropTypes.func, +}; + +KeymapsForm.defaultProps = { + value: {}, + onChange: () => {}, +}; + +export default KeymapsForm; |