Commit b68094abcbd7db121bfdca8c06131dda2443c8a9
replace insert-css with mutant style element
Matt McKegg committed on 10/25/2017, 11:48:53 PMParent: 9eb189371121ad5ec8de841694d1c3b8e4db1a4d
Files changed
main-window.js | changed |
package.json | changed |
main-window.js | ||
---|---|---|
@@ -5,9 +5,9 @@ | ||
5 | 5 | var when = require('mutant/when') |
6 | 6 | var onceTrue = require('mutant/once-true') |
7 | 7 | var computed = require('mutant/computed') |
8 | 8 | var catchLinks = require('./lib/catch-links') |
9 | -var insertCss = require('insert-css') | |
9 | +var themes = require('./styles') | |
10 | 10 | var nest = require('depnest') |
11 | 11 | var LatestUpdate = require('./lib/latest-update') |
12 | 12 | var ref = require('ssb-ref') |
13 | 13 | var setupContextMenuAndSpellCheck = require('./lib/context-menu-and-spellcheck') |
@@ -71,19 +71,16 @@ | ||
71 | 71 | watch(pendingCount, count => { |
72 | 72 | electron.remote.app.setBadgeCount(count) |
73 | 73 | }) |
74 | 74 | |
75 | + document.head.appendChild( | |
76 | + h('style', { | |
77 | + innerHTML: computed(api.settings.obs.get('patchwork.theme', 'light'), themeName => { | |
78 | + return themes[themeName] || themes['light'] | |
79 | + }) | |
80 | + }) | |
81 | + ) | |
75 | 82 | |
76 | - watch(api.settings.obs.get('patchwork.theme', 'light'), name => { | |
77 | - Array.from(document.head.children) | |
78 | - .filter(c => c.tagName == 'STYLE') | |
79 | - .forEach(c => c.innerText = '') | |
80 | - | |
81 | - var theme = require('./styles')[name] | |
82 | - if (!theme) theme = require('./styles')['light'] | |
83 | - insertCss(theme) | |
84 | - }) | |
85 | - | |
86 | 83 | var container = h(`MainWindow -${process.platform}`, [ |
87 | 84 | h('div.top', [ |
88 | 85 | h('span.history', [ |
89 | 86 | h('a', { |
Built with git-ssb-web