From b68094abcbd7db121bfdca8c06131dda2443c8a9 Mon Sep 17 00:00:00 2001 From: Matt McKegg Date: Thu, 26 Oct 2017 12:48:53 +1300 Subject: [PATCH] replace insert-css with mutant style element --- main-window.js | 19 ++++++++----------- package.json | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/main-window.js b/main-window.js index fd4ee4827..7ed134c91 100644 --- a/main-window.js +++ b/main-window.js @@ -6,7 +6,7 @@ var when = require('mutant/when') var onceTrue = require('mutant/once-true') var computed = require('mutant/computed') var catchLinks = require('./lib/catch-links') -var insertCss = require('insert-css') +var themes = require('./styles') var nest = require('depnest') var LatestUpdate = require('./lib/latest-update') var ref = require('ssb-ref') @@ -72,16 +72,13 @@ module.exports = function (config) { electron.remote.app.setBadgeCount(count) }) - - watch(api.settings.obs.get('patchwork.theme', 'light'), name => { - Array.from(document.head.children) - .filter(c => c.tagName == 'STYLE') - .forEach(c => c.innerText = '') - - var theme = require('./styles')[name] - if (!theme) theme = require('./styles')['light'] - insertCss(theme) - }) + document.head.appendChild( + h('style', { + innerHTML: computed(api.settings.obs.get('patchwork.theme', 'light'), themeName => { + return themes[themeName] || themes['light'] + }) + }) + ) var container = h(`MainWindow -${process.platform}`, [ h('div.top', [ diff --git a/package.json b/package.json index 29e978d77..85af43939 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "hashlru": "^2.2.0", "human-time": "0.0.1", "i18n": "^0.8.3", - "insert-css": "~2.0.0", "level": "~1.7.0", "lrucache": "^1.0.2", "micro-css": "^2.0.1",