From 57fafd3281af7a35f8e650fa9fb2cf5af70995f0 Mon Sep 17 00:00:00 2001 From: Clemens Date: Tue, 16 Aug 2016 11:57:12 +0200 Subject: refactor header_options --- web/src/js/components/Header/OptionMenu.jsx | 6 ++--- web/src/js/components/common/ToggleInputButton.jsx | 28 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'web/src/js/components') diff --git a/web/src/js/components/Header/OptionMenu.jsx b/web/src/js/components/Header/OptionMenu.jsx index a338fed0..a11062f2 100644 --- a/web/src/js/components/Header/OptionMenu.jsx +++ b/web/src/js/components/Header/OptionMenu.jsx @@ -41,17 +41,17 @@ function OptionMenu({ settings, updateSettings }) { /> updateSettings({ stickyauth: !settings.stickyauth ? txt : null })} /> updateSettings({ stickycookie: !settings.stickycookie ? txt : null })} /> updateSettings({ stream: !settings.stream ? txt : null })} /> diff --git a/web/src/js/components/common/ToggleInputButton.jsx b/web/src/js/components/common/ToggleInputButton.jsx index 25d620ae..b019dfa3 100644 --- a/web/src/js/components/common/ToggleInputButton.jsx +++ b/web/src/js/components/common/ToggleInputButton.jsx @@ -7,7 +7,10 @@ export default class ToggleInputButton extends Component { static propTypes = { name: PropTypes.string.isRequired, txt: PropTypes.string.isRequired, - onToggleChanged: PropTypes.func.isRequired + onToggleChanged: PropTypes.func.isRequired, + checked: PropTypes.bool.isRequired, + placeholder: PropTypes.string.isRequired, + inputType: PropTypes.string } constructor(props) { @@ -15,10 +18,6 @@ export default class ToggleInputButton extends Component { this.state = { txt: props.txt } } - onChange(e) { - this.setState({ txt: e.target.value }) - } - onKeyDown(e) { e.stopPropagation() if (e.keyCode === Key.ENTER) { @@ -27,23 +26,24 @@ export default class ToggleInputButton extends Component { } render() { + const {checked, onToggleChanged, name, inputType, placeholder} = this.props return (
this.props.onToggleChanged(this.state.txt)}> -
- + onClick={() => onToggleChanged(this.state.txt)}> +
+   - {this.props.name} + {name}
this.onChange(e)} + placeholder={placeholder} + disabled={checked} + value={this.state.txt || ''} + type={inputType || 'text'} + onChange={e => this.setState({ txt: e.target.value })} onKeyDown={e => this.onKeyDown(e)} />
-- cgit v1.2.3