Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/angular/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<a routerLink="/docs" routerLinkActive="active" class="nav-link" mat-button>Docs</a>
<a routerLink="/config" routerLinkActive="active" class="nav-link" mat-button>Configure</a>

<button mat-icon-button (click)="toggleDarkMode()" [attr.aria-label]="darkMode ? 'Switch to light mode' : 'Switch to dark mode'" title="{{ darkMode ? 'Light mode' : 'Dark mode' }}">
<mat-icon>{{ darkMode ? 'light_mode' : 'dark_mode' }}</mat-icon>
</button>

<div class="nav-status">
<span class="status-dot" [ngClass]="'status-' + (api.status$ | async)"></span>
<span>{{ api.status$ | async }}</span>
Expand Down
17 changes: 16 additions & 1 deletion web/angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@ import { RouterOutlet, RouterLink, RouterLinkActive } from '@angular/router';
import { AsyncPipe, NgClass } from '@angular/common';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { ApiService } from './api.service';

@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, RouterLink, RouterLinkActive, AsyncPipe, NgClass, MatToolbarModule, MatButtonModule],
imports: [RouterOutlet, RouterLink, RouterLinkActive, AsyncPipe, NgClass, MatToolbarModule, MatButtonModule, MatIconModule],
templateUrl: './app.component.html',
})
export class AppComponent implements OnInit {
darkMode = false;

constructor(public api: ApiService) {}

ngOnInit(): void {
this.api.refreshStatus();
this.darkMode = localStorage.getItem('darkMode') === 'true';
this.applyTheme();
}

toggleDarkMode(): void {
this.darkMode = !this.darkMode;
localStorage.setItem('darkMode', String(this.darkMode));
this.applyTheme();
}

private applyTheme(): void {
document.body.style.colorScheme = this.darkMode ? 'dark' : 'light';
}
}
3 changes: 2 additions & 1 deletion web/angular/src/material-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '@angular/material' as mat;

html {
color-scheme: light dark;
height: 100%;
@include mat.theme((
color: (
Expand Down Expand Up @@ -91,7 +92,7 @@ body {
background: var(--mat-sys-surface-variant);
color: var(--mat-sys-on-surface-variant);

&.feedback-success { background: color-mix(in srgb, #4caf50 15%, transparent); color: #1b5e20; }
&.feedback-success { background: color-mix(in srgb, #4caf50 15%, transparent); color: color-mix(in srgb, #4caf50 80%, var(--mat-sys-on-surface)); }
&.feedback-error { background: color-mix(in srgb, var(--mat-sys-error) 12%, transparent); color: var(--mat-sys-error); }
}

Expand Down