add theme selector to main dashboard
This commit is contained in:
@@ -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>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user