1
0
mirror of https://github.com/taigrr/homer synced 2025-01-18 04:53:12 -08:00

feat: adds support for theme_use_dark

This commit is contained in:
Tai Groot 2020-10-26 02:47:18 -07:00
parent 1fc60ffe4f
commit 729d1b5309
Signed by: taigrr
GPG Key ID: D00C269A87614812
2 changed files with 12 additions and 12 deletions

View File

@ -28,7 +28,7 @@
:links="config.links"
@navbar-toggle="showMenu = !showMenu"
>
<DarkMode @updated="isDark = $event" />
<DarkMode :isDark="this.isDark" @updated="isDark = $event" />
<LayoutToggle
@updated="vlayout = $event"
@ -159,6 +159,8 @@ export default {
}
this.config = merge(defaults, config);
this.services = this.config.services;
this.isDark = this.config.theme_use_dark;
this.vlayout = this.config.vlayout;
document.title =
this.config.documentTitle ||
`${this.config.title} | ${this.config.subtitle}`;

View File

@ -11,23 +11,21 @@
<script>
export default {
name: "Darkmode",
data: function () {
return {
isDark: null,
};
},
props: ["isDark"],
created: function () {
this.isDark =
var isDark =
"overrideDark" in localStorage
? JSON.parse(localStorage.overrideDark)
: matchMedia("(prefers-color-scheme: dark)").matches;
this.$emit("updated", this.isDark);
: this.isDark === null
? matchMedia("(prefers-color-scheme: dark)").matches
: this.isDark;
this.$emit("updated", isDark);
},
methods: {
toggleTheme: function () {
this.isDark = !this.isDark;
localStorage.overrideDark = this.isDark;
this.$emit("updated", this.isDark);
var isDark = !this.isDark;
localStorage.overrideDark = isDark;
this.$emit("updated", isDark);
},
},
};