mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-22 17:38:57 +08:00
FEAT: darkmode (#155)
* darkmode fixes * fix: darkmode: empty beats in active/ hovered state * fix: color for empty beats * fix: navbar background color * Update src/assets/vars.scss Co-authored-by: Adam Stachowicz <saibamenppl@gmail.com> * Update src/assets/app.scss Co-authored-by: Adam Stachowicz <saibamenppl@gmail.com> * wip, split dark theme style by .dark and store light theme to normal * add back missing css * working switch theme button and tuning dark theme * finish dark theme Co-authored-by: Adam Stachowicz <saibamenppl@gmail.com> Co-authored-by: LouisLam <louislam@users.noreply.github.com>
This commit is contained in:
@@ -29,7 +29,7 @@ export default {
|
||||
notificationList: [],
|
||||
windowWidth: window.innerWidth,
|
||||
showListMobile: false,
|
||||
connectionErrorMsg: "Cannot connect to the socket server. Reconnecting..."
|
||||
connectionErrorMsg: "Cannot connect to the socket server. Reconnecting...",
|
||||
}
|
||||
},
|
||||
|
||||
|
39
src/mixins/theme.js
Normal file
39
src/mixins/theme.js
Normal file
@@ -0,0 +1,39 @@
|
||||
export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
system: (window.matchMedia("(prefers-color-scheme: dark)")) ? "dark" : "light",
|
||||
userTheme: localStorage.theme,
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// Default Light
|
||||
if (! this.userTheme) {
|
||||
this.userTheme = "light";
|
||||
}
|
||||
|
||||
document.body.classList.add(this.theme);
|
||||
},
|
||||
|
||||
computed: {
|
||||
theme() {
|
||||
if (this.userTheme === "auto") {
|
||||
return this.system;
|
||||
}
|
||||
return this.userTheme;
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
userTheme(to, from) {
|
||||
localStorage.theme = to;
|
||||
},
|
||||
|
||||
theme(to, from) {
|
||||
document.body.classList.remove(from);
|
||||
document.body.classList.add(this.theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user