Browse Source

Remember the selected theme

new_auth
Quildra 2 years ago
parent
commit
77f40d9cf8
  1. 7
      packages/bridge-ui/src/app/app.component.ts
  2. 4
      packages/bridge-ui/src/app/services/theme.service.ts

7
packages/bridge-ui/src/app/app.component.ts

@ -19,6 +19,11 @@ export class AppComponent {
constructor (private themeService: ThemeService) {} constructor (private themeService: ThemeService) {}
ngOnInit() { ngOnInit() {
this.themeService.setTheme(this.defaultTheme); const style = localStorage.getItem('style');
if(style != undefined) {
this.themeService.setTheme(style);
} else {
this.themeService.setTheme(this.defaultTheme);
}
} }
} }

4
packages/bridge-ui/src/app/services/theme.service.ts

@ -13,7 +13,8 @@ export class ThemeService {
constructor( constructor(
private httpClient: HttpClient, private httpClient: HttpClient,
private styleManagerService: StyleManagerService) { } private styleManagerService: StyleManagerService) {
}
getThemeOptions(): Observable<Array<ThemeOption>> { getThemeOptions(): Observable<Array<ThemeOption>> {
return this.httpClient.get<Array<ThemeOption>>("assets/theme-options.json"); return this.httpClient.get<Array<ThemeOption>>("assets/theme-options.json");
@ -24,5 +25,6 @@ export class ThemeService {
"theme", "theme",
`${selectedTheme}.css` `${selectedTheme}.css`
) )
localStorage.setItem('style', selectedTheme);
} }
} }

Loading…
Cancel
Save