diff --git a/browser/finder/index.js b/browser/finder/index.js index cda861d4..30ef1403 100644 --- a/browser/finder/index.js +++ b/browser/finder/index.js @@ -9,11 +9,24 @@ import FinderDetail from './FinderDetail' import actions, { selectArticle, searchArticle } from './actions' import _ from 'lodash' import dataStore from 'browser/lib/dataStore' - +import fetchConfig from '../lib/fetchConfig' const electron = require('electron') const { clipboard, ipcRenderer, remote } = electron const path = require('path') +let config = fetchConfig() +applyConfig(config) + +ipcRenderer.on('config-apply', function (e, newConfig) { + config = newConfig + applyConfig(config) +}) + +function applyConfig(){ + let body = document.body + body.setAttribute('data-theme', config['theme-ui']) +} + if (process.env.NODE_ENV !== 'production') { window.addEventListener('keydown', function (e) { if (e.keyCode === 73 && e.metaKey && e.altKey) { diff --git a/browser/lib/fetchConfig.js b/browser/lib/fetchConfig.js index 0a8397df..54b6eaf5 100644 --- a/browser/lib/fetchConfig.js +++ b/browser/lib/fetchConfig.js @@ -14,6 +14,7 @@ const defaultConfig = { 'preview-font-family': 'Lato', 'switch-preview': 'blur', 'disable-direct-write': false, + 'theme-ui': 'light', 'theme-syntax': 'xcode' } diff --git a/browser/main/index.js b/browser/main/index.js index 96cb5edb..59649afb 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -7,11 +7,25 @@ require('../styles/main/index.styl') import { openModal } from 'browser/lib/modal' import OSSAnnounceModal from './modal/OSSAnnounceModal' import activityRecord from 'browser/lib/activityRecord' +import fetchConfig from '../lib/fetchConfig' const electron = require('electron') const ipc = electron.ipcRenderer const path = require('path') const remote = electron.remote +let config = fetchConfig() +applyConfig(config) + +ipc.on('config-apply', function (e, newConfig) { + config = newConfig + applyConfig(config) +}) + +function applyConfig(config) { + let body = document.body + body.setAttribute('data-theme', config['theme-ui']) +} + if (process.env.NODE_ENV !== 'production') { window.addEventListener('keydown', function (e) { if (e.keyCode === 73 && e.metaKey && e.altKey) { diff --git a/browser/main/modal/Preference/AppSettingTab.js b/browser/main/modal/Preference/AppSettingTab.js index 305495a5..fe7665f6 100644 --- a/browser/main/modal/Preference/AppSettingTab.js +++ b/browser/main/modal/Preference/AppSettingTab.js @@ -182,6 +182,13 @@ export default class AppSettingTab extends React.Component { : null }
Theme
+
+ + +