mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-03-10 19:39:10 +00:00
Added vuex module for setting if darkmode is supported in users browser
This commit is contained in:
23
src/modules/darkmodeModule.js
Normal file
23
src/modules/darkmodeModule.js
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user