Switch theme without reload

pull/3094/head
Grandschtroumpf 6 years ago committed by yann300
parent 6d1e5d2b4a
commit 2b6a24d6ef
  1. 6
      src/app/tabs/settings-tab.js
  2. 18
      src/app/ui/styles-guide/theme-chooser.js

@ -142,15 +142,15 @@ module.exports = class SettingsTab {
} }
function onswitch2darkTheme (event) { function onswitch2darkTheme (event) {
styleGuide.switchTheme('dark') styleGuide.switchTheme('dark')
window.location.reload() // window.location.reload()
} }
function onswitch2lightTheme (event) { function onswitch2lightTheme (event) {
styleGuide.switchTheme('light') styleGuide.switchTheme('light')
window.location.reload() // window.location.reload()
} }
function onswitch2cleanTheme (event) { function onswitch2cleanTheme (event) {
styleGuide.switchTheme('clean') styleGuide.switchTheme('clean')
window.location.reload() // window.location.reload()
} }
function onchangePersonal (event) { function onchangePersonal (event) {
self._deps.config.set('settings/personal-mode', !self._deps.config.get('settings/personal-mode')) self._deps.config.set('settings/personal-mode', !self._deps.config.get('settings/personal-mode'))

@ -33,8 +33,10 @@ module.exports = {
switchTheme: function (theme) { switchTheme: function (theme) {
var themeStorage = new Storage('style:') var themeStorage = new Storage('style:')
console.log(document)
themeStorage.set('theme', theme) themeStorage.set('theme', theme)
if (themes[theme]) {
document.getElementById('theme-link').setAttribute('href', themes[theme])
}
// if (theme === 'dark') { // if (theme === 'dark') {
// return styleGuideDark() // return styleGuideDark()
// } else if (theme === 'light') { // } else if (theme === 'light') {
@ -44,19 +46,5 @@ module.exports = {
// } else { // } else {
// return styleGuideLight() // 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'])
// }
} }
} }

Loading…
Cancel
Save