plane/apps/space/store/theme.ts
guru_sainath cd5e5b96da
feat: Mobx integration, List and Kanban boards implementation in plane space (#1844)
* feat: init mobx and issue filter

* feat: Implemented list and kanban views in plane space and integrated mobx.

* feat: updated store type check
2023-08-11 17:18:33 +05:30

34 lines
768 B
TypeScript

// mobx
import { observable, action, computed, makeObservable, runInAction } from "mobx";
// types
import { IThemeStore } from "./types";
class ThemeStore implements IThemeStore {
theme: "light" | "dark" = "light";
// root store
rootStore;
constructor(_rootStore: any | null = null) {
makeObservable(this, {
// observable
theme: observable,
// action
setTheme: action,
// computed
});
this.rootStore = _rootStore;
}
setTheme = async (_theme: "light" | "dark" | string) => {
try {
localStorage.setItem("app_theme", _theme);
this.theme = _theme === "light" ? "light" : "dark";
} catch (error) {
console.error("setting user theme error", error);
}
};
}
export default ThemeStore;