mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-04-25 09:13:35 +00:00
Convert store to typescript w/ matching interfaces
This commit is contained in:
31
src/modules/darkmodeModule.ts
Normal file
31
src/modules/darkmodeModule.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import IStateDarkmode from "../interfaces/IStateDarkmode";
|
||||
|
||||
const state: IStateDarkmode = {
|
||||
darkmodeSupported: false,
|
||||
userChoice: undefined
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters: {
|
||||
darkmodeSupported: (state: IStateDarkmode) => {
|
||||
return state.darkmodeSupported;
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
SET_DARKMODE_SUPPORT: (
|
||||
state: IStateDarkmode,
|
||||
browserSupported: boolean
|
||||
) => {
|
||||
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