diff --git a/src/Pages/Layout.tsx b/src/Pages/Layout.tsx
index 776ff6e1..dffdc48a 100644
--- a/src/Pages/Layout.tsx
+++ b/src/Pages/Layout.tsx
@@ -6,7 +6,7 @@ import { faBell, faMessage } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { RootState } from "State/Store";
-import { init, UserPreferences } from "State/Login";
+import { init, setPreferences, UserPreferences } from "State/Login";
import { HexKey, RawEvent, TaggedRawEvent } from "Nostr";
import { RelaySettings } from "Nostr/Connection";
import { System } from "Nostr/System"
@@ -39,14 +39,26 @@ export default function Layout() {
}
}, [relays]);
- useEffect(() => {
+ function setTheme(theme: "light" | "dark") {
const elm = document.documentElement;
- if (prefs.theme === "light") {
+ if (theme === "light" && !elm.classList.contains("light")) {
elm.classList.add("light");
- } else {
+ } else if (theme === "dark" && elm.classList.contains("light")) {
elm.classList.remove("light");
}
- }, [prefs]);
+ }
+
+ useEffect(() => {
+ let osTheme = window.matchMedia("(prefers-color-scheme: light)");
+ setTheme(prefs.theme === "system" && osTheme.matches ? "light" : prefs.theme === "light" ? "light" : "dark");
+
+ osTheme.onchange = (e) => {
+ if (prefs.theme === "system") {
+ setTheme(e.matches ? "light" : "dark");
+ }
+ }
+ return () => { osTheme.onchange = null; }
+ }, [prefs.theme]);
useEffect(() => {
dispatch(init());
diff --git a/src/Pages/SettingsPage.tsx b/src/Pages/SettingsPage.tsx
index cf78ed44..aa9c89f5 100644
--- a/src/Pages/SettingsPage.tsx
+++ b/src/Pages/SettingsPage.tsx
@@ -8,10 +8,10 @@ export default function SettingsPage() {
const navigate = useNavigate();
return (
-
-
navigate("/settings")}>Settings
+ <>
+ navigate("/settings")} className="pointer">Settings
-
+ >
);
}
diff --git a/src/Pages/settings/Index.css b/src/Pages/settings/Index.css
index 39554bda..afd1bd6a 100644
--- a/src/Pages/settings/Index.css
+++ b/src/Pages/settings/Index.css
@@ -1,3 +1,3 @@
-.settings-nav h3 {
- background-color: var(--note-bg);
+.settings-nav .card {
+ cursor: pointer;
}
\ No newline at end of file
diff --git a/src/Pages/settings/Preferences.tsx b/src/Pages/settings/Preferences.tsx
index 80721600..b1604af4 100644
--- a/src/Pages/settings/Preferences.tsx
+++ b/src/Pages/settings/Preferences.tsx
@@ -16,7 +16,8 @@ const PreferencesPage = () => {
Theme
-