quick set dark/light mode

This commit is contained in:
hay-kot 2021-05-31 17:39:33 -08:00
commit 3bddb54631
2 changed files with 17 additions and 1 deletions

View file

@ -18,6 +18,9 @@
</div>
<v-spacer></v-spacer>
<v-btn icon class="mr-1" small @click="isDark = !isDark">
<v-icon v-text="isDark ? 'mdi-weather-night' : 'mdi-weather-sunny'"> </v-icon>
</v-btn>
<div v-if="!isMobile" style="width: 350px;">
<SearchBar :show-results="true" @selected="navigateFromSearch" :max-width="isMobile ? '100%' : '450px'" />
</div>
@ -67,12 +70,25 @@ export default {
isMobile() {
return this.$vuetify.breakpoint.name === "xs";
},
isDark: {
get() {
return this.$store.getters.getIsDark;
},
set() {
let setVal = "dark";
if (this.isDark) {
setVal = "light";
}
this.$store.commit("setDarkMode", setVal);
},
},
},
methods: {
navigateFromSearch(slug) {
this.$router.push(`/recipe/${slug}`);
},
openSidebar() {
console.log(this.isDarkMode);
this.$refs.theSidebar.toggleSidebar();
},
},

View file

@ -17,7 +17,7 @@ function inDarkMode(payload) {
const state = {
activeTheme: {},
darkMode: "light",
darkMode: "light", // light, dark, system
isDark: false,
isLoggedIn: false,
token: "",