Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: persist theme and accent

thecodrr501f52e5a387
diff --git a/apps/web/src/common/config.js b/apps/web/src/common/config.js
new file mode 100644
index 000000000..8b3f92ee7
--- /dev/null
+++ b/apps/web/src/common/config.js
@@ -0,0 +1,11 @@
+function set(key, value) {
+ window.localStorage.setItem(key, JSON.stringify(value));
+}
+
+function get(key, def) {
+ const value = window.localStorage.getItem(key);
+ if (!value) return def;
+ return JSON.parse(value);
+}
+
+export default { set, get };
diff --git a/apps/web/src/stores/theme-store.js b/apps/web/src/stores/theme-store.js
index 67c9495cd..526fe1385 100644
--- a/apps/web/src/stores/theme-store.js
+++ b/apps/web/src/stores/theme-store.js
@@ -1,12 +1,14 @@
import createStore from "../common/store";
import BaseStore from "./index";
+import Config from "../common/config";
class ThemeStore extends BaseStore {
- theme = "light";
- accent = "#0560ff";
+ theme = Config.get("theme", "light");
+ accent = Config.get("accent", "#0560ff");
setTheme = (theme) => {
this.set((state) => (state.theme = theme));
+ Config.set("theme", theme);
};
toggleNightMode = () => {
@@ -16,6 +18,7 @@ class ThemeStore extends BaseStore {
setAccent = (accent) => {
this.set((state) => (state.accent = accent));
+ Config.set("accent", accent);
};
}