From 43fb37ab1d6e126026c7757ae7fdc49eb66af707 Mon Sep 17 00:00:00 2001 From: dojineko Date: Sun, 17 Apr 2016 17:44:59 +0900 Subject: [PATCH] Add dark theme and UI theme selector --- browser/finder/index.js | 15 +- browser/lib/fetchConfig.js | 1 + browser/main/index.js | 14 + .../main/modal/Preference/AppSettingTab.js | 7 + browser/styles/finder/index.styl | 1 + browser/styles/main/index.styl | 1 + .../styles/main/modal/CreateNewFolder.styl | 2 +- browser/styles/theme/dark.styl | 396 ++++++++++++++++++ lib/config.js | 1 + 9 files changed, 436 insertions(+), 2 deletions(-) create mode 100644 browser/styles/theme/dark.styl 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
+
+ + +