import React, { PropTypes } from 'react' import CSSModules from 'browser/lib/CSSModules' import styles from './ConfigTab.styl' import ConfigManager from 'browser/main/lib/ConfigManager' import store from 'browser/main/store' import consts from 'browser/lib/consts' import CheckHighlghtEditor from '../PreferencesModal/CheckHighlightEditor' const OSX = global.process.platform === 'darwin' class UiTab extends React.Component { constructor (props) { super(props) this.state = { config: props.config } } handleUIChange (e) { let { config } = this.state config.ui = { theme: this.refs.uiTheme.value, disableDirectWrite: this.refs.uiD2w != null ? this.refs.uiD2w.checked : false } config.editor = { theme: this.refs.editorTheme.value, fontSize: this.refs.editorFontSize.value, fontFamily: this.refs.editorFontFamily.value, indentType: this.refs.editorIndentType.value, indentSize: this.refs.editorIndentSize.value, switchPreview: this.refs.editorSwitchPreview.value, keyMap: this.refs.editorKeyMap.value } config.preview = { fontSize: this.refs.previewFontSize.value, fontFamily: this.refs.previewFontFamily.value, codeBlockTheme: this.refs.previewCodeBlockTheme.value, lineNumber: this.refs.previewLineNumber.checked } this.setState({ config }) } handleSaveUIClick (e) { const newConfig = { ui: this.state.config.ui, editor: this.state.config.editor, preview: this.state.config.preview } ConfigManager.set(newConfig) store.dispatch({ type: 'SET_UI', config: newConfig }) } render () { const themes = consts.THEMES const { config } = this.state return (