From 729d1b53098f89ab0111b067f3d1974b55b67f3c Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Mon, 26 Oct 2020 02:47:18 -0700 Subject: [PATCH] feat: adds support for theme_use_dark --- src/App.vue | 4 +++- src/components/DarkMode.vue | 20 +++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/App.vue b/src/App.vue index 93e90f2..3568c35 100644 --- a/src/App.vue +++ b/src/App.vue @@ -28,7 +28,7 @@ :links="config.links" @navbar-toggle="showMenu = !showMenu" > - + 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); }, }, };