mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-05-13 17:45:43 +00:00
33 lines
766 B
TypeScript
33 lines
766 B
TypeScript
import IStateDarkmode from "../interfaces/IStateDarkmode";
|
|
|
|
const state: IStateDarkmode = {
|
|
darkmodeSupported: false,
|
|
userChoice: undefined
|
|
};
|
|
|
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
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);
|
|
}
|
|
}
|
|
};
|