diff --git a/frontend/src/App.vue b/frontend/src/App.vue index a5c69bd11082..11b321b41192 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -2,7 +2,7 @@ - + mdi-silverware-variant @@ -44,32 +44,43 @@ export default { Menu, AddRecipe, SearchHeader, - SnackBar, + SnackBar }, watch: { $route() { this.search = false; - }, + } }, mounted() { this.$store.dispatch("initCookies"); this.$store.dispatch("requestRecentRecipes"); + this.darkModeAddEventListener(); }, data: () => ({ - search: false, + search: false }), methods: { + /** + * 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.$store.commit("setDarkMode", "system"); + }); + }, toggleSearch() { if (this.search === true) { this.search = false; } else { this.search = true; } - }, - }, + } + } }; diff --git a/frontend/src/components/Admin/Theme.vue b/frontend/src/components/Admin/Theme.vue index 392f58a9a31f..28f441bbcc8a 100644 --- a/frontend/src/components/Admin/Theme.vue +++ b/frontend/src/components/Admin/Theme.vue @@ -1,69 +1,114 @@