1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-22 22:59:41 +02:00
mealie/frontend/src/App.vue

112 lines
2.4 KiB
Vue
Raw Normal View History

2020-12-24 16:37:38 -09:00
<template>
<v-app>
<v-app-bar dense app color="primary" dark class="d-print-none">
2021-01-03 19:50:31 -09:00
<v-btn @click="$router.push('/')" icon class="d-flex align-center">
<v-icon size="40">
2020-12-24 16:37:38 -09:00
mdi-silverware-variant
</v-icon>
2021-01-03 19:50:31 -09:00
</v-btn>
<div btn class="pl-2">
<v-toolbar-title @click="$router.push('/')">Mealie</v-toolbar-title>
2020-12-24 16:37:38 -09:00
</div>
<v-spacer></v-spacer>
<v-btn icon @click="toggleSearch">
<v-icon>mdi-magnify</v-icon>
</v-btn>
<Menu />
</v-app-bar>
<v-main>
<v-container>
2021-01-08 17:09:03 -09:00
<AddRecipeFab />
2020-12-24 16:37:38 -09:00
<SnackBar />
<v-expand-transition>
<SearchHeader v-show="search" />
</v-expand-transition>
<router-view></router-view>
</v-container>
</v-main>
</v-app>
</template>
<script>
import Menu from "./components/UI/Menu";
import SearchHeader from "./components/UI/SearchHeader";
2021-01-08 17:09:03 -09:00
import AddRecipeFab from "./components/UI/AddRecipeFab";
2020-12-24 16:37:38 -09:00
import SnackBar from "./components/UI/SnackBar";
import Vuetify from "./plugins/vuetify";
2020-12-24 16:37:38 -09:00
export default {
name: "App",
components: {
Menu,
2021-01-08 17:09:03 -09:00
AddRecipeFab,
2020-12-24 16:37:38 -09:00
SearchHeader,
SnackBar
2020-12-24 16:37:38 -09:00
},
watch: {
$route() {
this.search = false;
}
2020-12-24 16:37:38 -09:00
},
mounted() {
this.$store.dispatch("initTheme");
2020-12-24 16:37:38 -09:00
this.$store.dispatch("requestRecentRecipes");
this.darkModeSystemCheck();
this.darkModeAddEventListener();
2020-12-24 16:37:38 -09:00
},
data: () => ({
search: false
2020-12-24 16:37:38 -09:00
}),
methods: {
/**
* Checks if 'system' is set for dark mode and then sets the corrisponding value for vuetify
*/
darkModeSystemCheck() {
if (this.$store.getters.getDarkMode === "system")
Vuetify.framework.theme.dark = window.matchMedia(
"(prefers-color-scheme: dark)"
).matches;
},
/**
* This will monitor the OS level darkmode and call to update dark mode.
*/
darkModeAddEventListener() {
const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
darkMediaQuery.addEventListener("change", () => {
this.darkModeSystemCheck();
});
},
2020-12-24 16:37:38 -09:00
toggleSearch() {
if (this.search === true) {
this.search = false;
} else {
this.search = true;
}
}
}
2020-12-24 16:37:38 -09:00
};
</script>
<style>
/* Scroll Bar PageSettings */
body::-webkit-scrollbar {
width: 0.25rem;
}
body::-webkit-scrollbar-track {
background: grey;
}
body::-webkit-scrollbar-thumb {
background: black;
}
</style>