Skip to content

Commit

Permalink
for #15 add light/dark color schema handler
Browse files Browse the repository at this point in the history
  • Loading branch information
moellep committed Jan 16, 2025
1 parent b0c8eef commit 13c579b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, Renderer2 } from '@angular/core';

@Component({
selector: 'app-root',
Expand All @@ -10,4 +10,18 @@ import { Component } from '@angular/core';
styles: [],
})
export class AppComponent {
constructor(private renderer: Renderer2) {
// respond to system color preference changes (light vs dark)
const p = window.matchMedia('(prefers-color-scheme: dark)');
p.addEventListener('change', this.handleColorScheme.bind(this));
this.handleColorScheme(p);
}

handleColorScheme(event: MediaQueryList | MediaQueryListEvent) {
this.renderer.setAttribute(
document.querySelector('html'),
'data-bs-theme',
event.matches ? 'dark' : 'light',
);
}
}
2 changes: 1 addition & 1 deletion ui/src/app/screen/screen.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { FormGroup, FormControl, Validators } from '@angular/forms';
<button [disabled]="! isAcquiring || ! form.value.pv" class="btn btn-danger" type="button" (click)="stopAcquiringImages()">Stop</button>
</div>
<div class="col-sm-4">
<button [disabled]="isAcquiring || ! form.value.pv" class="btn btn-outline-dark" type="button" (click)="getSingleImage()">Single</button>
<button [disabled]="isAcquiring || ! form.value.pv" class="btn btn-outline-info" type="button" (click)="getSingleImage()">Single</button>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Profile Monitor</title>
<title></title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
Expand Down

0 comments on commit 13c579b

Please sign in to comment.