add theme selector to main dashboard

This commit is contained in:
Mononaut
2023-01-02 13:08:25 -06:00
committed by natsoni
parent 4c205eb09d
commit 1ca05a029a
5 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
<div [formGroup]="themeForm" class="text-small text-center ml-2">
<select formControlName="theme" class="custom-select custom-select-sm form-control-secondary form-control mx-auto" style="width: 160px;" (change)="changeTheme()">
<option value="default" i18n="theme.mempool-theme">Mempool Theme</option>
<option value="contrast" i18n="theme.high-contrast">High Contrast</option>
</select>
</div>

View File

@@ -0,0 +1,31 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { ThemeService } from '../../services/theme.service';
@Component({
selector: 'app-theme-selector',
templateUrl: './theme-selector.component.html',
styleUrls: ['./theme-selector.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ThemeSelectorComponent implements OnInit {
themeForm: UntypedFormGroup;
themes = ['default', 'contrast'];
constructor(
private formBuilder: UntypedFormBuilder,
private themeService: ThemeService,
) { }
ngOnInit() {
this.themeForm = this.formBuilder.group({
theme: ['default']
});
this.themeForm.get('theme')?.setValue(this.themeService.theme);
}
changeTheme() {
const newTheme = this.themeForm.get('theme')?.value;
this.themeService.apply(newTheme);
}
}