mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 06:19:44 +00:00
rename frontend to web and update contributing guide (#2509)
* rename frontend to web and update contributing guide * rename this time * fix build * restructure rust code * update documentation * update descriptions * Update CONTRIBUTING.md Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com> --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com>
This commit is contained in:
37
web/projects/ui/src/app/services/theme-switcher.service.ts
Normal file
37
web/projects/ui/src/app/services/theme-switcher.service.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Inject, Injectable } from '@angular/core'
|
||||
import { WINDOW } from '@ng-web-apis/common'
|
||||
import { PatchDB } from 'patch-db-client'
|
||||
import { BehaviorSubject } from 'rxjs'
|
||||
import { ApiService } from './api/embassy-api.service'
|
||||
import { DataModel } from './patch-db/data-model'
|
||||
import { filter, take } from 'rxjs/operators'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ThemeSwitcherService extends BehaviorSubject<string> {
|
||||
constructor(
|
||||
private readonly patch: PatchDB<DataModel>,
|
||||
private readonly embassyApi: ApiService,
|
||||
@Inject(WINDOW) private readonly windowRef: Window,
|
||||
) {
|
||||
super('Dark')
|
||||
|
||||
this.patch
|
||||
.watch$('ui', 'theme')
|
||||
.pipe(take(1), filter(Boolean))
|
||||
.subscribe(theme => {
|
||||
this.updateTheme(theme)
|
||||
})
|
||||
}
|
||||
|
||||
override next(theme: string): void {
|
||||
this.embassyApi.setDbValue(['theme'], theme)
|
||||
this.updateTheme(theme)
|
||||
}
|
||||
|
||||
private updateTheme(theme: string): void {
|
||||
this.windowRef.document.body.setAttribute('data-theme', theme)
|
||||
super.next(theme)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user