Browse Source

Toggle theme with HTML class

pull/469/head
goodbyepavlyi 4 years ago
parent
commit
4be1de4412
  1. 17
      src/www/js/app.js

17
src/www/js/app.js

@ -45,6 +45,8 @@ new Vue({
currentRelease: null,
latestRelease: null,
isDark: null,
chartOptions: {
chart: {
background: 'transparent',
@ -239,6 +241,16 @@ new Vue({
.catch(err => alert(err.message || err.toString()))
.finally(() => this.refresh().catch(console.error));
},
toggleTheme() {
if (this.isDark) {
localStorage.theme = "light";
document.documentElement.classList.remove('dark');
} else {
localStorage.theme = "dark";
document.documentElement.classList.add('dark');
}
this.isDark = !this.isDark;
},
},
filters: {
bytes,
@ -247,6 +259,11 @@ new Vue({
},
},
mounted() {
this.isDark = false;
if (localStorage.theme === 'dark') {
this.isDark = true;
}
this.api = new API();
this.api.getSession()
.then(session => {

Loading…
Cancel
Save