forked from github/plane
cd5e5b96da
* feat: init mobx and issue filter * feat: Implemented list and kanban views in plane space and integrated mobx. * feat: updated store type check
34 lines
768 B
TypeScript
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;
|