From 2b6a24d6efd3773db96363172e160c6fbb67615e Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Tue, 19 Feb 2019 10:37:06 +0100 Subject: [PATCH] Switch theme without reload --- src/app/tabs/settings-tab.js | 6 +++--- src/app/ui/styles-guide/theme-chooser.js | 18 +++--------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 164741cdd5..619cf06452 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -142,15 +142,15 @@ module.exports = class SettingsTab { } function onswitch2darkTheme (event) { styleGuide.switchTheme('dark') - window.location.reload() + // window.location.reload() } function onswitch2lightTheme (event) { styleGuide.switchTheme('light') - window.location.reload() + // window.location.reload() } function onswitch2cleanTheme (event) { styleGuide.switchTheme('clean') - window.location.reload() + // window.location.reload() } function onchangePersonal (event) { self._deps.config.set('settings/personal-mode', !self._deps.config.get('settings/personal-mode')) diff --git a/src/app/ui/styles-guide/theme-chooser.js b/src/app/ui/styles-guide/theme-chooser.js index efd2e50cfe..25ce70405f 100644 --- a/src/app/ui/styles-guide/theme-chooser.js +++ b/src/app/ui/styles-guide/theme-chooser.js @@ -33,8 +33,10 @@ module.exports = { switchTheme: function (theme) { var themeStorage = new Storage('style:') - console.log(document) themeStorage.set('theme', theme) + if (themes[theme]) { + document.getElementById('theme-link').setAttribute('href', themes[theme]) + } // if (theme === 'dark') { // return styleGuideDark() // } else if (theme === 'light') { @@ -44,19 +46,5 @@ module.exports = { // } else { // return styleGuideLight() // } - // // Boostrap themes - // // TODO : Put it somewhere else - // const themes = { - // dark: 'https://bootstrap.themes.guide/darkster/theme.min.css', - // light: 'https://bootstrap.themes.guide/herbie/theme.min.css', - // clean: 'https://bootstrap.themes.guide/signal/theme.min.css' - // } - - // if (themes[theme]) { - // document.getElementById('theme-link').setAttribute('href', themes[theme]) - // } - // else { - // document.getElementById('theme-link').setProperty('href', themes['light']) - // } } }