aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/app.component.ts
diff options
context:
space:
mode:
authorAkash Keshav <112591754+domesticchores@users.noreply.github.com>2025-04-05 22:00:00 -0400
committerAkash Keshav <112591754+domesticchores@users.noreply.github.com>2025-04-05 22:00:00 -0400
commit1ac878b4aaa19ab889c7a98b7dab6acd57c778b3 (patch)
treee167944a8fd19c6df82fb9153887edf8780129a0 /ufund-ui/src/app/app.component.ts
parentac6fa949a754778f268fb91f0b32464c153191ef (diff)
downloadJellySolutions-1ac878b4aaa19ab889c7a98b7dab6acd57c778b3.tar.gz
JellySolutions-1ac878b4aaa19ab889c7a98b7dab6acd57c778b3.tar.bz2
JellySolutions-1ac878b4aaa19ab889c7a98b7dab6acd57c778b3.zip
finish styling basket and list; add persistent theme via localStorage. -ak
Diffstat (limited to 'ufund-ui/src/app/app.component.ts')
-rw-r--r--ufund-ui/src/app/app.component.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts
index 635061c..2fecc2d 100644
--- a/ufund-ui/src/app/app.component.ts
+++ b/ufund-ui/src/app/app.component.ts
@@ -38,6 +38,15 @@ export class AppComponent implements OnInit {
this.authService.restoreLogin(dataParsed.username, dataParsed.key)
console.log("Key found", dataParsed.key)
}
+
+ let theme = localStorage.getItem("theme")
+ if(!theme) {
+ // if no color scheme is set, get the system settings
+ let preferredTheme = this.document.defaultView?.matchMedia('(prefers-color-scheme: light)').matches ? "light" : "dark";
+ localStorage.setItem("theme",preferredTheme);
+ theme = preferredTheme;
+ }
+ this.document.body.parentElement!.setAttribute("theme",theme);
}
login() {
@@ -50,8 +59,14 @@ export class AppComponent implements OnInit {
}
toggleColorScheme() {
- let newTheme = this.document.body.parentElement!.getAttribute("theme") == "light" ? "dark" : "light";
+ let theme = localStorage.getItem("theme");
+ // fallback
+ if (!theme) {
+ theme = "light";
+ }
+ let newTheme = theme == "light" ? "dark" : "light";
this.document.body.parentElement!.setAttribute("theme",newTheme);
+ localStorage.setItem("theme", newTheme);
console.log(newTheme, this.document.body.parentElement);
}