import React from 'react'; import PropTypes from 'prop-types'; import FormGroup from 'react-bootstrap/es/FormGroup'; import FormControl from 'react-bootstrap/es/FormControl'; import ControlLabel from 'react-bootstrap/es/ControlLabel'; import Button from 'react-bootstrap/es/Button'; export default class EditorOptionsSelector extends React.Component { constructor(props) { super(props); this.state = { options: this.props.options, } this.availableThemes = [ 'elegant', 'neo', 'mdn-like', 'material', 'monokai', 'twilight' ] this.onChangeTheme = this.onChangeTheme.bind(this); this.onClickStyleActiveLine = this.onClickStyleActiveLine.bind(this); } componentDidMount() { this.init(); } init() { this.themeSelectorInputEl.value = this.state.options.theme || this.availableThemes[0]; } onChangeTheme() { const newValue = this.themeSelectorInputEl.value; const newOpts = Object.assign(this.state.options, {theme: newValue}); this.setState({options: newOpts}); // dispatch event this.dispatchOnChange(); } onClickStyleActiveLine(event) { const newValue = !this.state.options.styleActiveLine; console.log(newValue); const newOpts = Object.assign(this.state.options, {styleActiveLine: newValue}); this.setState({options: newOpts}); // dispatch event this.dispatchOnChange(); } dispatchOnChange() { if (this.props.onChange != null) { this.props.onChange(this.state.options); } } renderThemeSelector() { const optionElems = this.availableThemes.map((theme) => { return ; }); return ( Theme: this.themeSelectorInputEl=el }> {optionElems} ) } renderStyleActiveLineSelector() { const bool = this.state.options.styleActiveLine || false; return ( ) } render() { return {this.renderThemeSelector()} {this.renderStyleActiveLineSelector()} } } EditorOptionsSelector.propTypes = { options: PropTypes.object, onChange: PropTypes.func, };