/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
devtools/projects/ng-devtools/src/lib/devtools-tabs/settings/settings.component.ts
55 строк
2 KB
Georgi Serev
feat(devtools): create a new settings menu
02 май 2026, 01:54
Не верифицирован
02 май 2026, 01:54
9d803c5
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Component, inject, output} from '@angular/core'; import {MatIcon} from '@angular/material/icon'; import {ButtonComponent} from '../../shared/button/button.component'; import {SUPPORTED_APIS} from '../../application-providers/supported_apis'; import {Settings} from '../../application-services/settings'; import {ThemePreference} from '../../application-services/theme_types'; @Component({ selector: 'ng-settings', templateUrl: './settings.component.html', styleUrl: './settings.component.scss', imports: [MatIcon, ButtonComponent], host: { '(document:click)': 'onDocClick()', '(click)': 'onHostClick()', }, }) export class SettingsComponent { protected readonly settings = inject(Settings); protected readonly supportedApis = inject(SUPPORTED_APIS); protected readonly close = output<void>(); protected readonly themeOptions: {value: ThemePreference; label: string}[] = [ {value: 'system', label: 'System'}, {value: 'dark', label: 'Dark'}, {value: 'light', label: 'Light'}, ]; private hostClicked = false; onThemeChange(e: Event) { const theme = (e.target as HTMLInputElement).value as ThemePreference; this.settings.theme.set(theme); } onDocClick() { if (this.hostClicked) { this.hostClicked = false; } else { this.close.emit(); } } onHostClick() { this.hostClicked = true; } }