Added vuex module for setting if darkmode is supported in users browser

This commit is contained in:
2019-10-05 18:02:16 +02:00
parent 38cec8c31a
commit 585fa5afcf
3 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
export default {
namespaced: true,
state: {
darkmodeSupported: undefined,
userChoice: undefined
},
getters: {
darkmodeSupported: (state) => {
return state.darkmodeSupported
}
},
mutations: {
SET_DARKMODE_SUPPORT: (state, browserSupported) => {
state.darkmodeSupported = browserSupported
}
},
actions: {
findAndSetDarkmodeSupported({ commit }) {
const browserSupported = window.matchMedia('(prefers-color-scheme)').media !== 'not all'
commit('SET_DARKMODE_SUPPORT', browserSupported)
}
}
}