/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
adev/src/app/features/home/home.component.ts
73 строки
2 KB
Matthieu Riegler
docs(docs-infra): remove explicit OnPush
25 мар 2026, 22:58
25 мар 2026, 22:58
1938054
Код
Авторство
О чём код?
/*! * @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 {Tab, TabContent, TabList, TabPanel, Tabs} from '@angular/aria/tabs'; import {A11yModule} from '@angular/cdk/a11y'; import {afterRenderEffect, Component, ElementRef, inject, signal, viewChild} from '@angular/core'; import {IconComponent, IS_SEARCH_DIALOG_OPEN, TextField} from '@angular/docs'; import {ActivatedRoute, RouterLink} from '@angular/router'; import {ControlFlowExample} from './components/control-flow/control-flow-example'; import {DeferrableViewsExample} from './components/deferrable-views-example/deferrable-views-example'; import {HydrationExample} from './components/hydration-example/hydration-example'; import {SignalsDemo} from './components/signals-demo/signals-demo'; const FEATURE_TAB = { signals: 'signals', controlFlow: 'control-flow', deferrableViews: 'deferrable-views', hydration: 'hydration', } as const; @Component({ selector: 'adev-home', imports: [ RouterLink, TextField, TabList, Tab, Tabs, TabPanel, TabContent, IconComponent, A11yModule, SignalsDemo, ControlFlowExample, DeferrableViewsExample, HydrationExample, ], templateUrl: './home.component.html', styleUrls: ['./home.component.scss'], }) export default class Home { private readonly activatedRoute = inject(ActivatedRoute); protected readonly isUwu = 'uwu' in this.activatedRoute.snapshot.queryParams; protected readonly displaySearchDialog = inject(IS_SEARCH_DIALOG_OPEN); protected readonly FEATURE_TAB = FEATURE_TAB; protected readonly selectedFeatureTab = signal<keyof typeof FEATURE_TAB>(FEATURE_TAB.signals); protected readonly featuresSection = viewChild<ElementRef>('featuresSection'); constructor() { let lastFeatureTab = this.selectedFeatureTab(); afterRenderEffect({ read: () => { const featureTab = this.selectedFeatureTab(); if (lastFeatureTab !== featureTab) { this.featuresSection()?.nativeElement.scrollIntoView(); lastFeatureTab = featureTab; } }, }); } openSearch() { this.displaySearchDialog.set(true); } }