refactor: make modals like widgets

This commit is contained in:
David Ralph
2021-03-20 12:55:20 +00:00
parent 0c71f0ebef
commit ab7681f3d0
44 changed files with 362 additions and 117 deletions

View File

@@ -0,0 +1,31 @@
import React from 'react';
export default class Dropdown extends React.PureComponent {
getLabel() {
return this.props.label ? <label htmlFor={this.props.name}>{this.props.label}</label> : null;
}
componentDidMount() {
document.getElementById(this.props.name).value = localStorage.getItem(this.props.name);
}
onChange = () => {
localStorage.setItem(this.props.name, document.getElementById(this.props.name).value);
if (this.props.onChange) {
this.props.onChange();
}
}
render() {
return (
<React.Fragment>
{this.getLabel()}
<div className='dropdown' style={{ display: 'inline' }}>
<select name={this.props.name} id={this.props.name} onChange={this.onChange}>
{this.props.children}
</select>
</div>
</React.Fragment>
);
}
}