From b4a9cd9d540d42a61bee9045d41ada392305a8d5 Mon Sep 17 00:00:00 2001 From: Akash Keshav <112591754+domesticchores@users.noreply.github.com> Date: Fri, 4 Apr 2025 14:53:32 -0400 Subject: add light/dark mode toggle, only homepage is fully functional. -ak --- ufund-ui/src/app/app.component.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ufund-ui/src/app/app.component.ts') diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index bc0e71a..635061c 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -49,5 +49,11 @@ export class AppComponent implements OnInit { location.reload() } + toggleColorScheme() { + let newTheme = this.document.body.parentElement!.getAttribute("theme") == "light" ? "dark" : "light"; + this.document.body.parentElement!.setAttribute("theme",newTheme); + console.log(newTheme, this.document.body.parentElement); + } + protected readonly userType = userType; } -- cgit v1.2.3 From 1ac878b4aaa19ab889c7a98b7dab6acd57c778b3 Mon Sep 17 00:00:00 2001 From: Akash Keshav <112591754+domesticchores@users.noreply.github.com> Date: Sat, 5 Apr 2025 22:00:00 -0400 Subject: finish styling basket and list; add persistent theme via localStorage. -ak --- ufund-ui/src/app/app.component.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ufund-ui/src/app/app.component.ts') 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); } -- cgit v1.2.3 From ebeafe0a6a70da064fd97359e38f53406a58bed4 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 7 Apr 2025 16:45:38 -0400 Subject: Added underline to currently selected page --- ufund-ui/src/app/app.component.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ufund-ui/src/app/app.component.ts') diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts index 78fd050..fafffef 100644 --- a/ufund-ui/src/app/app.component.ts +++ b/ufund-ui/src/app/app.component.ts @@ -1,10 +1,10 @@ import {Component, OnInit, Inject, ViewContainerRef} from '@angular/core'; import {BehaviorSubject} from 'rxjs'; -import { DOCUMENT } from '@angular/common'; +import {DOCUMENT, Location} from '@angular/common'; import {AuthService} from './services/auth.service'; import {ToastsService} from './services/toasts.service'; import {User, userType} from './models/User'; -import {ActivatedRoute, Router} from '@angular/router'; +import {Router} from '@angular/router'; import {ModalService} from './services/modal.service'; @Component({ @@ -20,10 +20,10 @@ export class AppComponent implements OnInit { constructor( private authService: AuthService, private router: Router, - private route: ActivatedRoute, protected toastService: ToastsService, private viewContainerRef: ViewContainerRef, protected modalService: ModalService, + protected location: Location, @Inject(DOCUMENT) private document: Document ) {} @@ -41,6 +41,12 @@ export class AppComponent implements OnInit { console.log("Key found", dataParsed.key) } + if (this.location.path() == '/cupboard') { + console.log("work") + } else { + console.log(this.location.path()) + } + let theme = localStorage.getItem("theme") if(!theme) { // if no color scheme is set, get the system settings -- cgit v1.2.3