_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
angular/adev/shared-docs/components/top-level-banner/BUILD.bazel_0_1091
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") package(default_visibility = ["//visibility:private"]) ng_module( name = "top-level-banner", srcs = [ "top-level-banner.component.ts", ], assets = [ ":top-level-banner.component.css", "top-level-banner.component.html", ], visibility = [ "//adev/shared-docs/components:__pkg__", ], deps = [ "//adev/shared-docs/components/icon", "//adev/shared-docs/directives", "//adev/shared-docs/providers", "//packages/common", "//packages/core", ], ) sass_binary( name = "style", src = "top-level-banner.component.scss", ) ts_library( name = "test_lib", testonly = True, srcs = glob( ["*.spec.ts"], ), deps = [ ":top-level-banner", "//adev/shared-docs/providers", "//packages/core", "//packages/core/testing", ], ) karma_web_test_suite( name = "test", deps = [":test_lib"], )
{ "end_byte": 1091, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/top-level-banner/BUILD.bazel" }
angular/adev/shared-docs/components/text-field/text-field.component.spec.ts_0_862
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {TextField} from './text-field.component'; import {provideExperimentalZonelessChangeDetection} from '@angular/core'; describe('TextField', () => { let component: TextField; let fixture: ComponentFixture<TextField>; beforeEach(() => { TestBed.configureTestingModule({ imports: [TextField], providers: [provideExperimentalZonelessChangeDetection()], }); fixture = TestBed.createComponent(TextField); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });
{ "end_byte": 862, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/text-field/text-field.component.spec.ts" }
angular/adev/shared-docs/components/text-field/text-field.component.html_0_259
@if (!hideIcon) { <docs-icon class="docs-icon_high-contrast">search</docs-icon> } <input #inputRef type="text" [attr.placeholder]="placeholder" [attr.name]="name" [ngModel]="value()" (ngModelChange)="setValue($event)" class="docs-text-field" />
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/text-field/text-field.component.html" }
angular/adev/shared-docs/components/text-field/text-field.component.ts_0_2295
/*! * @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 { ChangeDetectionStrategy, Component, ElementRef, Input, ViewChild, afterNextRender, forwardRef, signal, } from '@angular/core'; import {CommonModule} from '@angular/common'; import {ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR} from '@angular/forms'; import {IconComponent} from '../icon/icon.component'; @Component({ selector: 'docs-text-field', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, FormsModule, IconComponent], templateUrl: './text-field.component.html', styleUrls: ['./text-field.component.scss'], providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => TextField), multi: true, }, ], host: { class: 'docs-form-element', }, }) export class TextField implements ControlValueAccessor { @ViewChild('inputRef') private input?: ElementRef<HTMLInputElement>; @Input() name: string | null = null; @Input() placeholder: string | null = null; @Input() disabled = false; @Input() hideIcon = false; @Input() autofocus = false; // Implemented as part of ControlValueAccessor. private onChange: (value: string) => void = (_: string) => {}; private onTouched: () => void = () => {}; protected readonly value = signal<string | null>(null); constructor() { afterNextRender(() => { if (this.autofocus) { this.input?.nativeElement.focus(); } }); } // Implemented as part of ControlValueAccessor. writeValue(value: string): void { this.value.set(value); } // Implemented as part of ControlValueAccessor. registerOnChange(fn: any): void { this.onChange = fn; } // Implemented as part of ControlValueAccessor. registerOnTouched(fn: any): void { this.onTouched = fn; } // Implemented as part of ControlValueAccessor. setDisabledState?(isDisabled: boolean): void { this.disabled = isDisabled; } setValue(value: string): void { if (this.disabled) { return; } this.value.set(value); this.onChange(value); this.onTouched(); } }
{ "end_byte": 2295, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/text-field/text-field.component.ts" }
angular/adev/shared-docs/components/text-field/text-field.component.scss_0_151
// search field .docs-text-field { font-size: 1.125rem; } // filter field on api reference list docs-icon + .docs-text-field { font-size: 1rem; }
{ "end_byte": 151, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/text-field/text-field.component.scss" }
angular/adev/shared-docs/components/text-field/BUILD.bazel_0_1025
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") package(default_visibility = ["//visibility:private"]) ng_module( name = "text-field", srcs = [ "text-field.component.ts", ], assets = [ ":text-field.component.css", "text-field.component.html", ], visibility = [ "//adev/shared-docs/components:__pkg__", "//adev/shared-docs/components/search-dialog:__pkg__", ], deps = [ "//adev/shared-docs/components/icon", "//packages/common", "//packages/core", "//packages/forms", ], ) sass_binary( name = "style", src = "text-field.component.scss", ) ts_library( name = "test_lib", testonly = True, srcs = glob( ["*.spec.ts"], ), deps = [ ":text-field", "//packages/core", "//packages/core/testing", ], ) karma_web_test_suite( name = "test", deps = [":test_lib"], )
{ "end_byte": 1025, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/text-field/BUILD.bazel" }
angular/adev/shared-docs/components/select/select.component.html_0_220
<select [attr.id]="id" [attr.name]="name" [ngModel]="selectedOption()" (ngModelChange)="setOption($event)"> @for (item of options; track item) { <option [value]="item.value">{{ item.label }}</option> } </select>
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/select/select.component.html" }
angular/adev/shared-docs/components/select/select.component.ts_0_2168
/*! * @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 {ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule} from '@angular/forms'; import {ChangeDetectionStrategy, Component, Input, forwardRef, signal} from '@angular/core'; import {CommonModule} from '@angular/common'; type SelectOptionValue = string | number | boolean; export interface SelectOption { label: string; value: SelectOptionValue; } @Component({ selector: 'docs-select', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, FormsModule], templateUrl: './select.component.html', styleUrls: ['./select.component.scss'], providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => Select), multi: true, }, ], host: { class: 'docs-form-element', }, }) export class Select implements ControlValueAccessor { @Input({required: true, alias: 'selectId'}) id!: string; @Input({required: true}) name!: string; @Input({required: true}) options!: SelectOption[]; @Input() disabled = false; // Implemented as part of ControlValueAccessor. private onChange: (value: SelectOptionValue) => void = (_: SelectOptionValue) => {}; private onTouched: () => void = () => {}; protected readonly selectedOption = signal<SelectOptionValue | null>(null); // Implemented as part of ControlValueAccessor. writeValue(value: SelectOptionValue): void { this.selectedOption.set(value); } // Implemented as part of ControlValueAccessor. registerOnChange(fn: any): void { this.onChange = fn; } // Implemented as part of ControlValueAccessor. registerOnTouched(fn: any): void { this.onTouched = fn; } // Implemented as part of ControlValueAccessor. setDisabledState?(isDisabled: boolean): void { this.disabled = isDisabled; } setOption($event: SelectOptionValue): void { if (this.disabled) { return; } this.selectedOption.set($event); this.onChange($event); this.onTouched(); } }
{ "end_byte": 2168, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/select/select.component.ts" }
angular/adev/shared-docs/components/select/BUILD.bazel_0_892
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") package(default_visibility = ["//visibility:private"]) ng_module( name = "select", srcs = [ "select.component.ts", ], assets = [ ":select.component.css", "select.component.html", ], visibility = [ "//adev/shared-docs/components:__pkg__", ], deps = [ "//packages/common", "//packages/core", "//packages/forms", ], ) sass_binary( name = "style", src = "select.component.scss", ) ts_library( name = "test_lib", testonly = True, srcs = glob( ["*.spec.ts"], ), deps = [ ":select", "//packages/core", "//packages/core/testing", ], ) karma_web_test_suite( name = "test", deps = [":test_lib"], )
{ "end_byte": 892, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/select/BUILD.bazel" }
angular/adev/shared-docs/components/select/select.component.spec.ts_0_840
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {Select} from './select.component'; import {provideExperimentalZonelessChangeDetection} from '@angular/core'; describe('Select', () => { let component: Select; let fixture: ComponentFixture<Select>; beforeEach(() => { TestBed.configureTestingModule({ imports: [Select], providers: [provideExperimentalZonelessChangeDetection()], }); fixture = TestBed.createComponent(Select); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });
{ "end_byte": 840, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/select/select.component.spec.ts" }
angular/adev/shared-docs/components/breadcrumb/breadcrumb.component.spec.ts_0_2534
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {Breadcrumb} from './breadcrumb.component'; import {NavigationState} from '../../services'; import {NavigationItem} from '../../interfaces'; import {By} from '@angular/platform-browser'; import {RouterTestingModule} from '@angular/router/testing'; import {provideExperimentalZonelessChangeDetection} from '@angular/core'; describe('Breadcrumb', () => { let fixture: ComponentFixture<Breadcrumb>; let navigationStateSpy: jasmine.SpyObj<NavigationState>; beforeEach(() => { navigationStateSpy = jasmine.createSpyObj('NavigationState', ['activeNavigationItem']); TestBed.configureTestingModule({ imports: [Breadcrumb, RouterTestingModule], providers: [ provideExperimentalZonelessChangeDetection(), { provide: NavigationState, useValue: navigationStateSpy, }, ], }); fixture = TestBed.createComponent(Breadcrumb); }); it('should display proper breadcrumb structure based on navigation state', () => { navigationStateSpy.activeNavigationItem.and.returnValue(item); fixture.detectChanges(); const breadcrumbs = fixture.debugElement.queryAll(By.css('.docs-breadcrumb span')); expect(breadcrumbs.length).toBe(2); expect(breadcrumbs[0].nativeElement.innerText).toEqual('Grandparent'); expect(breadcrumbs[1].nativeElement.innerText).toEqual('Parent'); }); it('should display breadcrumb links when navigation item has got path', () => { navigationStateSpy.activeNavigationItem.and.returnValue(exampleItemWithPath); fixture.detectChanges(); const breadcrumbs = fixture.debugElement.queryAll(By.css('.docs-breadcrumb a')); expect(breadcrumbs.length).toBe(1); expect(breadcrumbs[0].nativeElement.innerText).toEqual('Parent'); expect(breadcrumbs[0].nativeElement.href).toEqual(`${window.origin}/example`); }); }); const grandparent: NavigationItem = { label: 'Grandparent', }; const parent: NavigationItem = { label: 'Parent', parent: grandparent, }; const item: NavigationItem = { label: 'Active Item', parent: parent, }; const parentWithPath: NavigationItem = { label: 'Parent', path: '/example', }; const exampleItemWithPath: NavigationItem = { label: 'Active Item', parent: parentWithPath, };
{ "end_byte": 2534, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/breadcrumb/breadcrumb.component.spec.ts" }
angular/adev/shared-docs/components/breadcrumb/breadcrumb.component.html_0_390
@for (breadcrumb of breadcrumbItems(); track breadcrumb) { <div class="docs-breadcrumb"> @if (breadcrumb.path) { @if (breadcrumb.isExternal) { <a [href]="breadcrumb.path">{{ breadcrumb.label }}</a> } @else { <a [routerLink]="'/' + breadcrumb.path">{{ breadcrumb.label }}</a> } } @else { <span>{{ breadcrumb.label }}</span> } </div> }
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/breadcrumb/breadcrumb.component.html" }
angular/adev/shared-docs/components/breadcrumb/breadcrumb.component.ts_0_1368
/*! * @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 {ChangeDetectionStrategy, Component, OnInit, inject, signal} from '@angular/core'; import {NavigationState} from '../../services/index'; import {NavigationItem} from '../../interfaces/index'; import {RouterLink} from '@angular/router'; @Component({ selector: 'docs-breadcrumb', standalone: true, imports: [RouterLink], templateUrl: './breadcrumb.component.html', styleUrls: ['./breadcrumb.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) export class Breadcrumb implements OnInit { private readonly navigationState = inject(NavigationState); breadcrumbItems = signal<NavigationItem[]>([]); ngOnInit(): void { this.setBreadcrumbItemsBasedOnNavigationStructure(); } private setBreadcrumbItemsBasedOnNavigationStructure(): void { let breadcrumbs: NavigationItem[] = []; const traverse = (node: NavigationItem | null) => { if (!node) { return; } if (node.parent) { breadcrumbs = [node.parent, ...breadcrumbs]; traverse(node.parent); } }; traverse(this.navigationState.activeNavigationItem()); this.breadcrumbItems.set(breadcrumbs); } }
{ "end_byte": 1368, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/breadcrumb/breadcrumb.component.ts" }
angular/adev/shared-docs/components/breadcrumb/breadcrumb.component.scss_0_432
:host { display: flex; align-items: center; padding-block-end: 1.5rem; } .docs-breadcrumb { span { color: var(--quaternary-contrast); font-size: 0.875rem; display: flex; align-items: center; } &:not(:last-child) { span { &::after { content: 'chevron_right'; font-family: var(--icons); margin-inline: 0.5rem; color: var(--quinary-contrast); } } } }
{ "end_byte": 432, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/breadcrumb/breadcrumb.component.scss" }
angular/adev/shared-docs/components/breadcrumb/BUILD.bazel_0_1239
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") package(default_visibility = ["//visibility:private"]) ng_module( name = "breadcrumb", srcs = [ "breadcrumb.component.ts", ], assets = [ ":breadcrumb.component.css", "breadcrumb.component.html", ], visibility = [ "//adev/shared-docs/components:__pkg__", "//adev/shared-docs/components/viewers:__pkg__", ], deps = [ "//adev/shared-docs/interfaces", "//adev/shared-docs/services", "//packages/common", "//packages/core", "//packages/router", ], ) sass_binary( name = "style", src = "breadcrumb.component.scss", ) ts_library( name = "test_lib", testonly = True, srcs = glob( ["*.spec.ts"], ), deps = [ ":breadcrumb", "//adev/shared-docs/interfaces", "//adev/shared-docs/services", "//packages/core", "//packages/core/testing", "//packages/platform-browser", "//packages/router", "//packages/router/testing", ], ) karma_web_test_suite( name = "test", deps = [":test_lib"], )
{ "end_byte": 1239, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/breadcrumb/BUILD.bazel" }
angular/adev/shared-docs/components/icon/icon.component.ts_0_1447
/*! * @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 {DOCUMENT} from '@angular/common'; import { ChangeDetectionStrategy, Component, afterNextRender, computed, inject, signal, } from '@angular/core'; @Component({ selector: 'docs-icon', standalone: true, templateUrl: './icon.component.html', styleUrl: './icon.component.scss', host: { '[class]': 'MATERIAL_SYMBOLS_OUTLINED', '[style.font-size.px]': 'fontSize()', 'aria-hidden': 'true', 'translate': 'no', }, changeDetection: ChangeDetectionStrategy.OnPush, }) export class IconComponent { fontSize = computed(() => { return IconComponent.isFontLoaded() ? null : 0; }); protected readonly MATERIAL_SYMBOLS_OUTLINED = 'material-symbols-outlined'; private static isFontLoaded = signal(false); /** Share the same promise across different instances of the component */ private static whenFontLoad?: Promise<FontFace[]> | undefined; constructor() { if (IconComponent.isFontLoaded()) { return; } const document = inject(DOCUMENT); afterNextRender(async () => { IconComponent.whenFontLoad ??= document.fonts.load('normal 1px "Material Symbols Outlined"'); await IconComponent.whenFontLoad; IconComponent.isFontLoaded.set(true); }); } }
{ "end_byte": 1447, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/icon/icon.component.ts" }
angular/adev/shared-docs/components/icon/BUILD.bazel_0_927
load("//tools:defaults.bzl", "ng_module") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") package(default_visibility = ["//visibility:private"]) ng_module( name = "icon", srcs = [ "icon.component.ts", ], assets = [ ":icon.component.css", "icon.component.html", ], visibility = [ "//adev/shared-docs/components:__pkg__", "//adev/shared-docs/components/copy-source-code-button:__pkg__", "//adev/shared-docs/components/navigation-list:__pkg__", "//adev/shared-docs/components/table-of-contents:__pkg__", "//adev/shared-docs/components/text-field:__pkg__", "//adev/shared-docs/components/top-level-banner:__pkg__", "//adev/shared-docs/components/viewers:__pkg__", ], deps = [ "//packages/common", "//packages/core", ], ) sass_binary( name = "style", src = "icon.component.scss", )
{ "end_byte": 927, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/icon/BUILD.bazel" }
angular/adev/shared-docs/components/icon/icon.component.html_0_26
<ng-content></ng-content>
{ "end_byte": 26, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/icon/icon.component.html" }
angular/adev/shared-docs/components/icon/icon.component.scss_0_63
.docs-icon_high-contrast { color: var(--primary-contrast); }
{ "end_byte": 63, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/icon/icon.component.scss" }
angular/adev/shared-docs/components/cookie-popup/cookie-popup.component.scss_0_785
:host { position: fixed; bottom: 0.5rem; right: 0.5rem; z-index: var(--z-index-cookie-consent); opacity: 0; visibility: hidden; animation: 1s linear forwards 0.5s fadeIn; } .docs-cookies-popup { padding: 1rem; background-color: var(--page-background); border: 1px solid var(--senary-contrast); border-radius: 0.25rem; font-size: 0.875rem; max-width: 265px; transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease; box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); > div { display: flex; gap: 0.5rem; align-items: center; width: 100%; margin-block-start: 1rem; } p { margin-block: 0; color: var(--primary-contrast); } } @keyframes fadeIn { 100% { opacity: 100%; visibility: visible; } }
{ "end_byte": 785, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/cookie-popup/cookie-popup.component.scss" }
angular/adev/shared-docs/components/cookie-popup/cookie-popup.component.html_0_610
@if (!hasAccepted()) { <div class="docs-cookies-popup docs-invert-mode"> <p>This site uses cookies from Google to deliver its services and to analyze traffic.</p> <div> <a href="https://policies.google.com/technologies/cookies" target="_blank" rel="noopener"> <button class="docs-primary-btn" [attr.text]="'Learn more'" aria-label="Learn More"> Learn more </button> </a> <button type="button" (click)="accept()" class="docs-primary-btn" [attr.text]="'Ok, Got it'" aria-label="Ok, Got it" > Ok, Got it </button> </div> </div> }
{ "end_byte": 610, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/cookie-popup/cookie-popup.component.html" }
angular/adev/shared-docs/components/cookie-popup/cookie-popup.component.spec.ts_0_2130
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {CookiePopup, STORAGE_KEY} from './cookie-popup.component'; import {LOCAL_STORAGE} from '../../providers/index'; import {MockLocalStorage} from '../../testing/index'; import {provideExperimentalZonelessChangeDetection} from '@angular/core'; describe('CookiePopup', () => { let fixture: ComponentFixture<CookiePopup>; let mockLocalStorage = new MockLocalStorage(); beforeEach(() => { TestBed.configureTestingModule({ imports: [CookiePopup], providers: [ provideExperimentalZonelessChangeDetection(), { provide: LOCAL_STORAGE, useValue: mockLocalStorage, }, ], }); }); it('should make the popup visible by default', () => { initComponent(false); expect(getCookiesPopup()).not.toBeNull(); }); it('should hide the cookies popup if the user has already accepted cookies', () => { initComponent(true); expect(getCookiesPopup()).toBeNull(); }); it('should hide the cookies popup', () => { initComponent(false); accept(); fixture.detectChanges(); expect(getCookiesPopup()).toBeNull(); }); it('should store the user confirmation', () => { initComponent(false); expect(mockLocalStorage.getItem(STORAGE_KEY)).toBeNull(); accept(); expect(mockLocalStorage.getItem(STORAGE_KEY)).toBe('true'); }); // Helpers function getCookiesPopup() { return (fixture.nativeElement as HTMLElement).querySelector('.docs-cookies-popup'); } function accept() { (fixture.nativeElement as HTMLElement) .querySelector<HTMLButtonElement>('button[text="Ok, Got it"]') ?.click(); } function initComponent(cookiesAccepted: boolean) { mockLocalStorage.setItem(STORAGE_KEY, cookiesAccepted ? 'true' : null); fixture = TestBed.createComponent(CookiePopup); fixture.detectChanges(); } });
{ "end_byte": 2130, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/cookie-popup/cookie-popup.component.spec.ts" }
angular/adev/shared-docs/components/cookie-popup/cookie-popup.component.ts_0_1573
/*! * @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 {ChangeDetectionStrategy, Component, inject, signal} from '@angular/core'; import {LOCAL_STORAGE} from '../../providers/index'; import {setCookieConsent} from '../../utils'; /** * Decelare gtag as part of the window in this file as gtag is expected to already be loaded. */ declare const window: Window & typeof globalThis & {gtag?: Function}; export const STORAGE_KEY = 'docs-accepts-cookies'; @Component({ selector: 'docs-cookie-popup', standalone: true, templateUrl: './cookie-popup.component.html', styleUrls: ['./cookie-popup.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) export class CookiePopup { private readonly localStorage = inject(LOCAL_STORAGE); /** Whether the user has accepted the cookie disclaimer. */ hasAccepted = signal<boolean>(false); constructor() { // Needs to be in a try/catch, because some browsers will // throw when using `localStorage` in private mode. try { this.hasAccepted.set(this.localStorage?.getItem(STORAGE_KEY) === 'true'); } catch { this.hasAccepted.set(false); } } /** Accepts the cookie disclaimer. */ protected accept(): void { try { this.localStorage?.setItem(STORAGE_KEY, 'true'); } catch {} this.hasAccepted.set(true); // Enable Google Analytics consent properties setCookieConsent('granted'); } }
{ "end_byte": 1573, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/cookie-popup/cookie-popup.component.ts" }
angular/adev/shared-docs/components/cookie-popup/BUILD.bazel_0_1054
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library") load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") package(default_visibility = ["//visibility:private"]) ng_module( name = "cookie-popup", srcs = [ "cookie-popup.component.ts", ], assets = [ ":cookie-popup.component.css", "cookie-popup.component.html", ], visibility = [ "//adev/shared-docs/components:__pkg__", ], deps = [ "//adev/shared-docs/providers", "//adev/shared-docs/utils", "//packages/common", "//packages/core", ], ) sass_binary( name = "style", src = "cookie-popup.component.scss", ) ts_library( name = "test_lib", testonly = True, srcs = glob( ["*.spec.ts"], ), deps = [ ":cookie-popup", "//adev/shared-docs/providers", "//adev/shared-docs/testing", "//packages/core", "//packages/core/testing", ], ) karma_web_test_suite( name = "test", deps = [":test_lib"], )
{ "end_byte": 1054, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/components/cookie-popup/BUILD.bazel" }
angular/adev/shared-docs/icons/chevron.svg_0_239
<svg width="10" height="7" viewBox="0 0 10 7" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M-5.09966e-08 1.83341L1.16667 0.666748L5 4.50008L8.83333 0.666748L10 1.83341L5 6.83341L-5.09966e-08 1.83341Z" fill="#746E7C"/> </svg>
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/icons/chevron.svg" }
angular/adev/shared-docs/icons/github.svg_0_1383
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.59948 19.0428C7.59948 18.8069 7.59118 18.182 7.58656 17.3526C4.89071 17.9526 4.32164 16.0201 4.32164 16.0201C3.88087 14.8718 3.24533 14.5663 3.24533 14.5663C2.36518 13.9492 3.31179 13.9621 3.31179 13.9621C4.28471 14.0323 4.79656 14.9868 4.79656 14.9868C5.66102 16.5052 7.06456 16.0672 7.61748 15.8125C7.70564 15.17 7.95579 14.732 8.23271 14.4837C6.08056 14.2331 3.81764 13.3801 3.81764 9.57199C3.81764 8.48737 4.19564 7.6003 4.81548 6.90522C4.71625 6.65414 4.38302 5.64384 4.91056 4.27537C4.91056 4.27537 5.72471 4.00814 7.57594 5.29399C8.34856 5.07384 9.17795 4.96307 10.0027 4.95937C10.8256 4.96307 11.6546 5.07384 12.429 5.29399C14.2793 4.00814 15.0921 4.27537 15.0921 4.27537C15.621 5.64337 15.2883 6.65368 15.1881 6.90522C15.8093 7.6003 16.1841 8.48737 16.1841 9.57199C16.1841 13.3898 13.9179 14.2298 11.7589 14.4758C12.1073 14.7828 12.4166 15.3892 12.4166 16.3165C12.4166 17.6452 12.4041 18.7174 12.4041 19.0428C12.4041 19.3091 12.579 19.6178 13.071 19.5205C16.9193 18.2041 19.6936 14.4814 19.6936 10.0926C19.6936 4.60353 15.3538 0.154297 10.0009 0.154297C4.64887 0.154297 0.309021 4.60353 0.309021 10.0926C0.309483 14.4828 3.08656 18.2078 6.9381 19.5218C7.42225 19.6128 7.59948 19.3058 7.59948 19.0428Z" fill="#A39FA9"/> </svg>
{ "end_byte": 1383, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/icons/github.svg" }
angular/adev/shared-docs/icons/youtube.svg_0_782
<svg width="20" height="15" viewBox="0 0 20 15" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M18.7556 2.94783C18.5803 1.98018 17.745 1.27549 16.7756 1.05549C15.325 0.747832 12.6403 0.527832 9.73563 0.527832C6.83266 0.527832 4.105 0.747832 2.65266 1.05549C1.685 1.27549 0.847969 1.93549 0.672656 2.94783C0.495625 4.04783 0.320312 5.58783 0.320312 7.56783C0.320312 9.54783 0.495625 11.0878 0.715625 12.1878C0.892656 13.1555 1.72797 13.8602 2.69563 14.0802C4.23563 14.3878 6.87563 14.6078 9.78031 14.6078C12.685 14.6078 15.325 14.3878 16.865 14.0802C17.8327 13.8602 18.668 13.2002 18.845 12.1878C19.0203 11.0878 19.2403 9.50314 19.285 7.56783C19.1956 5.58783 18.9756 4.04783 18.7556 2.94783ZM7.36031 10.6478V4.48783L12.728 7.56783L7.36031 10.6478Z" fill="#A39FA9"/> </svg>
{ "end_byte": 782, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/icons/youtube.svg" }
angular/adev/shared-docs/icons/BUILD.bazel_0_196
package(default_visibility = ["//visibility:private"]) filegroup( name = "icons", srcs = glob([ "*.svg", ]), visibility = [ "//adev/shared-docs:__pkg__", ], )
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/icons/BUILD.bazel" }
angular/adev/shared-docs/icons/twitter.svg_0_367
<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M0.04145 0.04432l6.56351 8.77603L0 15.95564h1.48651l5.78263-6.24705 4.6722 6.24705h5.05865l-6.9328-9.26967L16.21504.04432h-1.48651l-5.32552 5.75341L5.1001.04432H.04145Zm2.18602 1.09497h2.32396l10.26221 13.72122h-2.32396L2.22747 1.13928Z" fill="#A39FA9"/> </svg>
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/icons/twitter.svg" }
angular/adev/shared-docs/services/table-of-contents-loader.service.ts_0_3238
/*! * @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 {DOCUMENT, isPlatformBrowser} from '@angular/common'; import {inject, signal, Injectable, PLATFORM_ID} from '@angular/core'; import {TableOfContentsItem, TableOfContentsLevel} from '../interfaces/index'; /** * Name of an attribute that is set on an element that should be * excluded from the `TableOfContentsLoader` lookup. This is needed * to exempt SSR'ed content of the `TableOfContents` component from * being inspected and accidentally pulling more content into ToC. */ export const TOC_SKIP_CONTENT_MARKER = 'toc-skip-content'; @Injectable({providedIn: 'root'}) export class TableOfContentsLoader { // There are some cases when default browser anchor scrolls a little above the // heading In that cases wrong item was selected. The value found by trial and // error. readonly toleranceThreshold = 40; readonly tableOfContentItems = signal([] as TableOfContentsItem[]); private readonly document = inject(DOCUMENT); private readonly platformId = inject(PLATFORM_ID); buildTableOfContent(docElement: Element): void { const headings = this.getHeadings(docElement); const tocList: TableOfContentsItem[] = headings.map((heading) => ({ id: heading.id, level: heading.tagName.toLowerCase() as TableOfContentsLevel, title: this.getHeadingTitle(heading), top: this.calculateTop(heading), })); this.tableOfContentItems.set(tocList); } // Update top value of heading, it should be executed after window resize updateHeadingsTopValue(element: HTMLElement): void { const headings = this.getHeadings(element); const updatedTopValues = new Map<string, number>(); for (const heading of headings) { const parentTop = heading.parentElement?.offsetTop ?? 0; const top = Math.floor(parentTop + heading.offsetTop - this.toleranceThreshold); updatedTopValues.set(heading.id, top); } this.tableOfContentItems.update((oldItems) => { let newItems = [...oldItems]; for (const item of newItems) { item.top = updatedTopValues.get(item.id) ?? 0; } return newItems; }); } private getHeadingTitle(heading: HTMLHeadingElement): string { const div: HTMLDivElement = this.document.createElement('div'); div.innerHTML = heading.innerHTML; return (div.textContent || '').trim(); } // Get all headings (h2 and h3) with ids, which are not children of the // docs-example-viewer component. private getHeadings(element: Element): HTMLHeadingElement[] { return Array.from( element.querySelectorAll<HTMLHeadingElement>( `h2[id]:not(docs-example-viewer h2):not([${TOC_SKIP_CONTENT_MARKER}]),` + `h3[id]:not(docs-example-viewer h3):not([${TOC_SKIP_CONTENT_MARKER}])`, ), ); } private calculateTop(heading: HTMLHeadingElement): number { if (!isPlatformBrowser(this.platformId)) return 0; return ( Math.floor(heading.offsetTop > 0 ? heading.offsetTop : heading.getClientRects()[0]?.top) - this.toleranceThreshold ); } }
{ "end_byte": 3238, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/table-of-contents-loader.service.ts" }
angular/adev/shared-docs/services/table-of-contents-loader.service.spec.ts_0_4242
/*! * @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 {TestBed} from '@angular/core/testing'; import {TOC_SKIP_CONTENT_MARKER, TableOfContentsLoader} from './table-of-contents-loader.service'; describe('TableOfContentsLoader', () => { let service: TableOfContentsLoader; beforeEach(() => { TestBed.configureTestingModule({ providers: [TableOfContentsLoader], }); service = TestBed.inject(TableOfContentsLoader); }); it('should be created', () => { expect(service).toBeTruthy(); }); it('should create empty table of content list when there is no headings in content', () => { const element = createElement('element-without-headings'); service.buildTableOfContent(element); expect(service.tableOfContentItems()).toEqual([]); }); it('should create empty table of content list when there is only h1 elements', () => { const element = createElement('element-with-only-h1'); service.buildTableOfContent(element); expect(service.tableOfContentItems()).toEqual([]); }); it('should create table of content list with h2 and h3 when h2 and h3 headings exists', () => { const element = createElement('element-with-h1-h2-h3-h4'); service.buildTableOfContent(element); expect(service.tableOfContentItems().length).toEqual(5); expect(service.tableOfContentItems()[0].id).toBe('item-2'); expect(service.tableOfContentItems()[1].id).toBe('item-3'); expect(service.tableOfContentItems()[2].id).toBe('item-5'); expect(service.tableOfContentItems()[3].id).toBe('item-6'); expect(service.tableOfContentItems()[4].id).toBe('item-7'); expect(service.tableOfContentItems()[0].level).toBe('h2'); expect(service.tableOfContentItems()[1].level).toBe('h3'); expect(service.tableOfContentItems()[2].level).toBe('h3'); expect(service.tableOfContentItems()[3].level).toBe('h2'); expect(service.tableOfContentItems()[4].level).toBe('h3'); expect(service.tableOfContentItems()[0].title).toBe('H2 - first'); expect(service.tableOfContentItems()[1].title).toBe('H3 - first'); expect(service.tableOfContentItems()[2].title).toBe('H3 - second'); expect(service.tableOfContentItems()[3].title).toBe('H2 - second'); expect(service.tableOfContentItems()[4].title).toBe('H3 - third'); }); it('should not display in ToC h2,h3 without ids', () => { const element = createElement('element-with-h2-h3-without-id'); service.buildTableOfContent(element); expect(service.tableOfContentItems().length).toBe(0); }); it('should not display in ToC h2,h3 which are childrens of docs-example-viewer', () => { const element = createElement('headings-inside-docs-example-viewer'); service.buildTableOfContent(element); expect(service.tableOfContentItems().length).toBe(0); }); it(`should not display in ToC heading with ${TOC_SKIP_CONTENT_MARKER} attr`, () => { const element = createElement('headings-inside-toc-skip-content'); service.buildTableOfContent(element); expect(service.tableOfContentItems().length).toBe(1); expect(service.tableOfContentItems()[0].id).toBe('item-1'); }); }); function createElement(id: string): HTMLElement { const div = document.createElement('div'); div.innerHTML = fakeElementHtml[id]; return div; } const fakeHeadings = `<h1 id="item-1">H1</h1> <h2 id="item-2">H2 - first</h2> <h3 id="item-3">H3 - first</h3> <h4 id="item-4">H4</h4> <h3 id="item-5">H3 - second</h3> <h2 id="item-6">H2 - second</h2> <h3 id="item-7">H3 - third</h3>`; const fakeElementHtml: Record<string, string> = { 'element-without-headings': `<div>content</div>`, 'element-with-only-h1': `<div><h1>heading</h1></div>`, 'element-with-h1-h2-h3-h4': `<div> ${fakeHeadings} </div> `, 'element-with-h2-h3-without-id': `<div><h2>heading</h2><h3>heading</h3></div>`, 'headings-inside-docs-example-viewer': `<docs-example-viewer>${fakeHeadings}</docs-example-viewer>`, 'headings-inside-toc-skip-content': `<div><h2 id="item-1">heading</h2><h3 id="item-2" toc-skip-content>skip heading</h3></div>`, };
{ "end_byte": 4242, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/table-of-contents-loader.service.spec.ts" }
angular/adev/shared-docs/services/navigation-state.service.ts_0_3875
/*! * @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 {Injectable, inject, signal} from '@angular/core'; import {NavigationItem} from '../interfaces/index'; import {Router} from '@angular/router'; @Injectable({ providedIn: 'root', }) export class NavigationState { private readonly router = inject(Router); private readonly _activeNavigationItem = signal<NavigationItem | null>(null); private readonly _expandedItems = signal<NavigationItem[]>([]); private readonly _isMobileNavVisible = signal<boolean>(false); primaryActiveRouteItem = signal<string | null>(null); activeNavigationItem = this._activeNavigationItem.asReadonly(); expandedItems = this._expandedItems.asReadonly(); isMobileNavVisible = this._isMobileNavVisible.asReadonly(); async toggleItem(item: NavigationItem): Promise<void> { if (!item.children) { return; } if (item.isExpanded) { this.collapse(item); } else if (item.children && item.children.length > 0 && item.children[0].path) { // It resolves false, when the user has displayed the page, then changed the slide to a secondary navigation component // and wants to reopen the slide, where the first item is the currently displayed page const navigationSucceeds = await this.navigateToFirstPageOfTheCategory(item.children[0].path); if (!navigationSucceeds) { this.expand(item); } } } cleanExpandedState(): void { this._expandedItems.set([]); } expandItemHierarchy( item: NavigationItem, shouldExpand: (item: NavigationItem) => boolean, skipExpandPredicateFn?: (item: NavigationItem) => boolean, ): void { if (skipExpandPredicateFn && skipExpandPredicateFn(item)) { // When `skipExpandPredicateFn` returns `true` then we should trigger `cleanExpandedState` // to be sure that first navigation slide will be displayed. this.cleanExpandedState(); return; } // Returns item when parent node was already expanded const parentItem = this._expandedItems().find( (expandedItem) => item.parent?.label === expandedItem.label && item.parent?.path === expandedItem.path, ); if (parentItem) { // If the parent item is expanded, then we should display all expanded items up to the active item level. // This provides us with an appropriate list of expanded elements also when the user navigates using browser buttons. this._expandedItems.update((expandedItems) => expandedItems.filter( (item) => item.level !== undefined && parentItem.level !== undefined && item.level <= parentItem.level, ), ); } else { let itemsToExpand: NavigationItem[] = []; let node = item.parent; while (node && shouldExpand(node)) { itemsToExpand.push({...node, isExpanded: true}); node = node.parent; } this._expandedItems.set(itemsToExpand.reverse()); } } setActiveNavigationItem(item: NavigationItem | null): void { this._activeNavigationItem.set(item); } setMobileNavigationListVisibility(isVisible: boolean): void { this._isMobileNavVisible.set(isVisible); } private expand(item: NavigationItem): void { // Add item to the expanded items list this._expandedItems.update((expandedItems) => { return [...(expandedItems ?? []), {...item, isExpanded: true}]; }); } private collapse(item: NavigationItem): void { item.isExpanded = false; this._expandedItems.update((expandedItems) => expandedItems.slice(0, -1)); } private async navigateToFirstPageOfTheCategory(path: string): Promise<boolean> { return this.router.navigateByUrl(path); } }
{ "end_byte": 3875, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/navigation-state.service.ts" }
angular/adev/shared-docs/services/search.service.ts_0_4306
/*! * @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 {Injectable, afterNextRender, inject, signal} from '@angular/core'; import {ENVIRONMENT} from '../providers/index'; import {SearchResult} from '../interfaces/index'; import {toObservable} from '@angular/core/rxjs-interop'; import {debounceTime, filter, from, of, switchMap} from 'rxjs'; import {liteClient as algoliasearch} from 'algoliasearch/lite'; import {NavigationEnd, Router} from '@angular/router'; export const SEARCH_DELAY = 200; // Maximum number of facet values to return for each facet during a regular search. export const MAX_VALUE_PER_FACET = 5; @Injectable({ providedIn: 'root', }) export class Search { private readonly _searchQuery = signal(''); private readonly _searchResults = signal<undefined | SearchResult[]>(undefined); private readonly router = inject(Router); private readonly config = inject(ENVIRONMENT); private readonly client = algoliasearch(this.config.algolia.appId, this.config.algolia.apiKey); searchQuery = this._searchQuery.asReadonly(); searchResults = this._searchResults.asReadonly(); searchResults$ = toObservable(this.searchQuery).pipe( debounceTime(SEARCH_DELAY), switchMap((query) => { return !!query ? from( this.client.search([ { indexName: this.config.algolia.indexName, params: { query: query, maxValuesPerFacet: MAX_VALUE_PER_FACET, attributesToRetrieve: [ 'hierarchy.lvl0', 'hierarchy.lvl1', 'hierarchy.lvl2', 'hierarchy.lvl3', 'hierarchy.lvl4', 'hierarchy.lvl5', 'hierarchy.lvl6', 'content', 'type', 'url', ], hitsPerPage: 20, snippetEllipsisText: '…', highlightPreTag: '<ɵ>', highlightPostTag: '</ɵ>', attributesToHighlight: [], attributesToSnippet: [ 'hierarchy.lvl1:10', 'hierarchy.lvl2:10', 'hierarchy.lvl3:10', 'hierarchy.lvl4:10', 'hierarchy.lvl5:10', 'hierarchy.lvl6:10', 'content:10', ], }, type: 'default', }, ]), ) : of(undefined); }), ); constructor() { afterNextRender(() => { this.listenToSearchResults(); this.resetSearchQueryOnNavigationEnd(); }); } updateSearchQuery(query: string): void { this._searchQuery.set(query); } private listenToSearchResults(): void { this.searchResults$.subscribe((response: any) => { this._searchResults.set( response ? this.getUniqueSearchResultItems(response.results[0].hits) : undefined, ); }); } private getUniqueSearchResultItems(items: SearchResult[]): SearchResult[] { const uniqueUrls = new Set<string>(); return items.filter((item) => { if (item.type === 'content' && !item._snippetResult.content) { return false; } // Ensure that this result actually matched on the type. // If not, this is going to be a duplicate. There should be another result in // the list that already matched on its type. // A lvl2 match will also return all its lvl3 results as well, even if those // values don't also match the query. if ( item.type.indexOf('lvl') === 0 && item._snippetResult.hierarchy?.[item.type as 'lvl1']?.matchLevel === 'none' ) { return false; } if (item.url && !uniqueUrls.has(item.url)) { uniqueUrls.add(item.url); return true; } return false; }); } private resetSearchQueryOnNavigationEnd(): void { this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(() => { this.updateSearchQuery(''); }); } }
{ "end_byte": 4306, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/search.service.ts" }
angular/adev/shared-docs/services/inject-async.service.ts_0_2464
/*! * @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 { DestroyRef, ENVIRONMENT_INITIALIZER, EnvironmentInjector, Injectable, Injector, Provider, ProviderToken, Type, createEnvironmentInjector, inject, } from '@angular/core'; /** * Convience method for lazy loading an injection token. */ export async function injectAsync<T>( injector: Injector, providerLoader: () => Promise<ProviderToken<T>>, ): Promise<T> { const injectImpl = injector.get(InjectAsyncImpl); return injectImpl.get(injector, providerLoader); } @Injectable({providedIn: 'root'}) class InjectAsyncImpl<T> { private overrides = new WeakMap(); // no need to cleanup override<T>(type: Type<T>, mock: Type<unknown>) { this.overrides.set(type, mock); } async get(injector: Injector, providerLoader: () => Promise<ProviderToken<T>>): Promise<T> { const type = await providerLoader(); // Check if we have overrides, O(1), low overhead if (this.overrides.has(type)) { const override = this.overrides.get(type); return new override(); } if (!(injector instanceof EnvironmentInjector)) { // this is the DestroyRef of the component const destroyRef = injector.get(DestroyRef); // This is the parent injector of the injector we're creating const environmentInjector = injector.get(EnvironmentInjector); // Creating an environment injector to destroy it afterwards const newInjector = createEnvironmentInjector([type as Provider], environmentInjector); // Destroy the injector to trigger DestroyRef.onDestroy on our service destroyRef.onDestroy(() => { newInjector.destroy(); }); // We want to create the new instance of our service with our new injector injector = newInjector; } return injector.get(type)!; } } /** * Helper function to mock the lazy loaded module in `injectAsync` * * @usage * TestBed.configureTestingModule({ * providers: [ * mockAsyncProvider(SandboxService, fakeSandboxService) * ] * }); */ export function mockAsyncProvider<T>(type: Type<T>, mock: Type<unknown>) { return [ { provide: ENVIRONMENT_INITIALIZER, multi: true, useValue: () => { inject(InjectAsyncImpl).override(type, mock); }, }, ]; }
{ "end_byte": 2464, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/inject-async.service.ts" }
angular/adev/shared-docs/services/BUILD.bazel_0_1229
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library") package(default_visibility = ["//visibility:private"]) ts_library( name = "services", srcs = [ "index.ts", ], visibility = ["//adev/shared-docs:__subpackages__"], deps = [ ":lib", ], ) ng_module( name = "lib", srcs = glob( [ "**/*.ts", ], exclude = [ "index.ts", "**/*.spec.ts", ], ), deps = [ "//adev/shared-docs/constants", "//adev/shared-docs/interfaces", "//adev/shared-docs/providers", "//adev/shared-docs/utils", "//packages/common", "//packages/core", "//packages/core/rxjs-interop", "//packages/router", "@npm//algoliasearch", "@npm//rxjs", ], ) ts_library( name = "test_lib", testonly = True, srcs = glob( ["*.spec.ts"], ), deps = [ ":lib", "//adev/shared-docs/interfaces", "//adev/shared-docs/providers", "//packages/common", "//packages/core", "//packages/core/testing", ], ) karma_web_test_suite( name = "test", deps = [":test_lib"], )
{ "end_byte": 1229, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/BUILD.bazel" }
angular/adev/shared-docs/services/index.ts_0_502
/*! * @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 */ export * from './navigation-state.service'; export {TOC_SKIP_CONTENT_MARKER, TableOfContentsLoader} from './table-of-contents-loader.service'; export {TableOfContentsScrollSpy} from './table-of-contents-scroll-spy.service'; export * from './search.service'; export * from './inject-async.service';
{ "end_byte": 502, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/index.ts" }
angular/adev/shared-docs/services/table-of-contents-scroll-spy.service.spec.ts_0_4188
/*! * @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 {DestroyRef} from '@angular/core'; import {DOCUMENT, ViewportScroller} from '@angular/common'; import {TestBed, discardPeriodicTasks, fakeAsync, tick} from '@angular/core/testing'; import {WINDOW} from '../providers'; import {TableOfContentsLoader} from './table-of-contents-loader.service'; import {SCROLL_EVENT_DELAY, TableOfContentsScrollSpy} from './table-of-contents-scroll-spy.service'; import {TableOfContentsLevel} from '../interfaces'; describe('TableOfContentsScrollSpy', () => { let service: TableOfContentsScrollSpy; let destroyRef: DestroyRef; const fakeWindow = { addEventListener: () => {}, removeEventListener: () => {}, scrollY: 0, }; const fakeToCItems = [ { id: 'h2', level: TableOfContentsLevel.H2, title: 'h2', top: 100, }, { id: 'first', level: TableOfContentsLevel.H3, title: 'first', top: 400, }, { id: 'second', level: TableOfContentsLevel.H3, title: 'second', top: 900, }, { id: 'third', level: TableOfContentsLevel.H3, title: 'third', top: 1200, }, { id: 'fourth', level: TableOfContentsLevel.H3, title: 'fourth', top: 1900, }, ]; beforeEach(() => { TestBed.configureTestingModule({ providers: [ TableOfContentsScrollSpy, { provide: WINDOW, useValue: fakeWindow, }, ], }); const tableOfContentsLoaderSpy = TestBed.inject(TableOfContentsLoader); tableOfContentsLoaderSpy.tableOfContentItems.set(fakeToCItems); service = TestBed.inject(TableOfContentsScrollSpy); destroyRef = TestBed.inject(DestroyRef); }); it('should be created', () => { expect(service).toBeTruthy(); }); it('should activeItemId be null by default', () => { expect(service.activeItemId()).toBeNull(); }); it('should call scrollToPosition([0, 0]) once scrollToTop was invoked', () => { const scrollToPositionSpy = spyOn<ViewportScroller>( service['viewportScroller'], 'scrollToPosition', ); service.scrollToTop(); expect(scrollToPositionSpy).toHaveBeenCalledOnceWith([0, 0]); }); it(`should only fire setActiveItemId every ${SCROLL_EVENT_DELAY}ms when scrolling`, fakeAsync(() => { const doc = TestBed.inject(DOCUMENT); const scrollableContainer = doc; const setActiveItemIdSpy = spyOn(service as any, 'setActiveItemId'); service.startListeningToScroll(doc.querySelector('fake-selector'), destroyRef); scrollableContainer.dispatchEvent(new Event('scroll')); tick(SCROLL_EVENT_DELAY - 2); expect(setActiveItemIdSpy).not.toHaveBeenCalled(); scrollableContainer.dispatchEvent(new Event('scroll')); tick(1); expect(setActiveItemIdSpy).not.toHaveBeenCalled(); scrollableContainer.dispatchEvent(new Event('scroll')); tick(1); expect(setActiveItemIdSpy).toHaveBeenCalled(); discardPeriodicTasks(); })); it(`should set active item when window scrollY is greater than calculated section top value`, fakeAsync(() => { const doc = TestBed.inject(DOCUMENT); const scrollableContainer = doc; service.startListeningToScroll(doc.querySelector('fake-selector'), destroyRef); fakeWindow.scrollY = 1238; scrollableContainer.dispatchEvent(new Event('scroll')); tick(SCROLL_EVENT_DELAY); expect(service.activeItemId()).toEqual('third'); discardPeriodicTasks(); })); it(`should set null as active item when window scrollY is lesser than the top value of the first section`, fakeAsync(() => { const doc = TestBed.inject(DOCUMENT); const scrollableContainer = doc; service.startListeningToScroll(doc.querySelector('fake-selector'), destroyRef); fakeWindow.scrollY = 99; scrollableContainer.dispatchEvent(new Event('scroll')); tick(SCROLL_EVENT_DELAY); expect(service.activeItemId()).toEqual(null); discardPeriodicTasks(); })); });
{ "end_byte": 4188, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/table-of-contents-scroll-spy.service.spec.ts" }
angular/adev/shared-docs/services/table-of-contents-scroll-spy.service.ts_0_6347
/*! * @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 {DOCUMENT, ViewportScroller} from '@angular/common'; import { DestroyRef, EnvironmentInjector, Injectable, afterNextRender, inject, signal, } from '@angular/core'; import {RESIZE_EVENT_DELAY} from '../constants/index'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import {auditTime, debounceTime, fromEvent, startWith} from 'rxjs'; import {WINDOW} from '../providers/index'; import {shouldReduceMotion} from '../utils/index'; import {TableOfContentsLoader} from './table-of-contents-loader.service'; export const SCROLL_EVENT_DELAY = 20; export const SCROLL_FINISH_DELAY = SCROLL_EVENT_DELAY * 2; @Injectable({providedIn: 'root'}) // The service is responsible for listening for scrolling and resizing, // thanks to which it sets the active item in the Table of contents export class TableOfContentsScrollSpy { private readonly tableOfContentsLoader = inject(TableOfContentsLoader); private readonly document = inject(DOCUMENT); private readonly window = inject(WINDOW); private readonly viewportScroller = inject(ViewportScroller); private readonly injector = inject(EnvironmentInjector); private contentSourceElement: HTMLElement | null = null; private lastContentWidth = 0; activeItemId = signal<string | null>(null); scrollbarThumbOnTop = signal<boolean>(true); startListeningToScroll( contentSourceElement: HTMLElement | null, // `destroyRef` is required because the caller may invoke `startListeningToScroll` // multiple times. Without it, previous event listeners would not be disposed of, // leading to the accumulation of new event listeners. destroyRef: DestroyRef, ) { this.contentSourceElement = contentSourceElement; this.lastContentWidth = this.getContentWidth(); this.setScrollEventHandlers(destroyRef); this.setResizeEventHandlers(destroyRef); destroyRef.onDestroy(() => { // We also need to clean up the source element once the view that calls // `startListeningToScroll` is destroyed, as this will keep a reference // to an element that has been removed from the DOM. this.contentSourceElement = null; }); } scrollToTop(): void { this.viewportScroller.scrollToPosition([0, 0]); } scrollToSection(id: string): void { if (shouldReduceMotion()) { this.offsetToSection(id); } else { const section = this.document.getElementById(id); section?.scrollIntoView({behavior: 'smooth', block: 'start'}); // We don't want to set the active item here, it would mess up the animation // The scroll event handler will handle it for us } } private offsetToSection(id: string): void { const section = this.document.getElementById(id); section?.scrollIntoView({block: 'start'}); // Here we need to set the active item manually because scroll events might not be fired this.activeItemId.set(id); } // After window resize, we should update top value of each table content item private setResizeEventHandlers(destroyRef: DestroyRef) { fromEvent(this.window, 'resize') .pipe(debounceTime(RESIZE_EVENT_DELAY), takeUntilDestroyed(destroyRef), startWith()) .subscribe(() => { this.updateHeadingsTopAfterResize(); }); // We need to observe the height of the docs-viewer because it may change after the // assets (fonts, images) are loaded. They can (and will) change the y-position of the headings. const docsViewer = this.document.querySelector('docs-viewer'); if (docsViewer) { const ref = afterNextRender( () => { const resizeObserver = new ResizeObserver(() => this.updateHeadingsTopAfterResize()); resizeObserver.observe(docsViewer); destroyRef.onDestroy(() => resizeObserver.disconnect()); }, {injector: this.injector, manualCleanup: true}, ); destroyRef.onDestroy(() => ref.destroy()); } } private updateHeadingsTopAfterResize(): void { this.lastContentWidth = this.getContentWidth(); const contentElement = this.contentSourceElement; if (contentElement) { this.tableOfContentsLoader.updateHeadingsTopValue(contentElement); this.setActiveItemId(); } } private setScrollEventHandlers(destroyRef: DestroyRef): void { const scroll$ = fromEvent(this.document, 'scroll').pipe( auditTime(SCROLL_EVENT_DELAY), takeUntilDestroyed(destroyRef), ); scroll$.subscribe(() => this.setActiveItemId()); } private setActiveItemId(): void { const tableOfContentItems = this.tableOfContentsLoader.tableOfContentItems(); if (tableOfContentItems.length === 0) return; // Resize could emit scroll event, in that case we could stop setting active item until resize will be finished if (this.lastContentWidth !== this.getContentWidth()) { return; } const scrollOffset = this.getScrollOffset(); if (scrollOffset === null) return; for (const [i, currentLink] of tableOfContentItems.entries()) { const nextLink = tableOfContentItems[i + 1]; // A link is considered active if the page is scrolled past the // anchor without also being scrolled passed the next link. const isActive = scrollOffset >= currentLink.top && (!nextLink || nextLink.top >= scrollOffset); // When active item was changed then trigger change detection if (isActive && this.activeItemId() !== currentLink.id) { this.activeItemId.set(currentLink.id); return; } } if (scrollOffset < tableOfContentItems[0].top && this.activeItemId() !== null) { this.activeItemId.set(null); } const scrollOffsetZero = scrollOffset === 0; if (scrollOffsetZero !== this.scrollbarThumbOnTop()) { // we want to trigger change detection only when the value changes this.scrollbarThumbOnTop.set(scrollOffsetZero); } } // Gets the scroll offset of the scroll container private getScrollOffset(): number { return this.window.scrollY; } private getContentWidth(): number { return this.document.body.clientWidth || Number.MAX_SAFE_INTEGER; } }
{ "end_byte": 6347, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/services/table-of-contents-scroll-spy.service.ts" }
angular/adev/shared-docs/interfaces/code-example.ts_0_1229
/*! * @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 {Type} from '@angular/core'; /** * Map of the examples, values are functions which returns the promise of the component type, which will be displayed as preview in the ExampleViewer component */ export interface CodeExamplesMap { [id: string]: () => Promise<Type<unknown>>; } export interface Snippet { /** Title of the code snippet */ title?: string; /** Name of the file. */ name: string; /** Content of code snippet */ content: string; /** Text in following format `start-end`. Start and end are numbers, based on them provided range of lines will be displayed in collapsed mode */ visibleLinesRange?: string; } export interface ExampleMetadata { /** Numeric id of example, used to generate unique link to the example */ id: number; /** Title of the example. */ title?: string; /** Path to the preview component */ path?: string; /** List of files which are part of the example. */ files: Snippet[]; /** True when ExampleViewer should have preview */ preview: boolean; }
{ "end_byte": 1229, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/code-example.ts" }
angular/adev/shared-docs/interfaces/table-of-contents-item.ts_0_599
/*! * @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 */ export enum TableOfContentsLevel { H2 = 'h2', H3 = 'h3', } /** Represents a table of content item. */ export interface TableOfContentsItem { /** The url fragment of specific section */ id: string; /** The level of the item. */ level: TableOfContentsLevel; /** The unique title for this document page. */ title: string; /** The top offset px of the heading */ top: number; }
{ "end_byte": 599, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/table-of-contents-item.ts" }
angular/adev/shared-docs/interfaces/navigation-item.ts_0_423
/*! * @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 */ export interface NavigationItem { label?: string; path?: string; children?: NavigationItem[]; isExternal?: boolean; isExpanded?: boolean; level?: number; parent?: NavigationItem; contentPath?: string; }
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/navigation-item.ts" }
angular/adev/shared-docs/interfaces/environment.ts_0_364
/*! * @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 {AlgoliaConfig} from './algolia-config'; export interface Environment { production: boolean; algolia: AlgoliaConfig; googleAnalyticsId: string; }
{ "end_byte": 364, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/environment.ts" }
angular/adev/shared-docs/interfaces/search-results.ts_0_1585
/*! * @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 */ export interface SnippetResult { value: string; matchLevel: 'none' | 'full' | string; } /* The interface represents Algolia search result item. */ export interface SearchResult { /* The url link to the search result page */ url: string; /* The hierarchy of the item */ hierarchy: Hierarchy; /* The unique id of the search result item */ objectID: string; /** * The type of the result. A content result will have * matched the content. A result of type 'lvl#' may have i * matched a lvl above it. For example, a type 'lvl3' may be * included in results because its 'lvl2' header matched the query. */ type: string; /** Documentation content (not headers) */ content: string | null; /** Snippets of the matched text */ _snippetResult: { hierarchy?: { lvl0?: SnippetResult; lvl1?: SnippetResult; lvl2?: SnippetResult; lvl3?: SnippetResult; lvl4?: SnippetResult; }; content?: SnippetResult; }; } /* The hierarchy of the item */ export interface Hierarchy { /* It's kind of the page i.e `Docs`, `Tutorials`, `Reference` etc. */ lvl0: string | null; /* Typicaly it's the content of H1 of the page */ lvl1: string | null; /* Typicaly it's the content of H2 of the page */ lvl2: string | null; lvl3: string | null; lvl4: string | null; lvl5: string | null; lvl6: string | null; }
{ "end_byte": 1585, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/search-results.ts" }
angular/adev/shared-docs/interfaces/algolia-config.ts_0_295
/*! * @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 */ export interface AlgoliaConfig { apiKey: string; appId: string; indexName: string; }
{ "end_byte": 295, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/algolia-config.ts" }
angular/adev/shared-docs/interfaces/example-viewer-content-loader.ts_0_493
/*! * @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 {Type} from '@angular/core'; /** The service responsible for fetching the type of Component to display in the preview */ export interface ExampleViewerContentLoader { /** Returns type of Component to display in the preview */ loadPreview(id: string): Promise<Type<unknown>>; }
{ "end_byte": 493, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/example-viewer-content-loader.ts" }
angular/adev/shared-docs/interfaces/docs-content-loader.ts_0_421
/*! * @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 {DocContent} from './doc-content'; /** The service responsible for fetching static content for docs pages */ export interface DocsContentLoader { getContent(path: string): Promise<DocContent | undefined>; }
{ "end_byte": 421, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/docs-content-loader.ts" }
angular/adev/shared-docs/interfaces/BUILD.bazel_0_567
load("//tools:defaults.bzl", "ts_library") package(default_visibility = ["//visibility:private"]) ts_library( name = "interfaces", srcs = [ "index.ts", ], visibility = ["//adev/shared-docs:__subpackages__"], deps = [ ":lib", ], ) ts_library( name = "lib", srcs = glob( [ "**/*.ts", ], exclude = [ "index.ts", "**/*.spec.ts", ], ), deps = [ "//packages/core", "@npm//@types/node", "@npm//@webcontainer/api", ], )
{ "end_byte": 567, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/BUILD.bazel" }
angular/adev/shared-docs/interfaces/index.ts_0_525
/*! * @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 */ export * from './code-example'; export * from './doc-content'; export * from './docs-content-loader'; export * from './example-viewer-content-loader'; export * from './environment'; export * from './navigation-item'; export * from './table-of-contents-item'; export * from './search-results'; export * from './tutorial';
{ "end_byte": 525, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/index.ts" }
angular/adev/shared-docs/interfaces/tutorial.ts_0_4525
/*! * @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 type {FileSystemTree} from '@webcontainer/api'; import {NavigationItem} from './navigation-item'; /** the step is used only in this function to sort the nav items */ export type TutorialNavigationItemWithStep = TutorialNavigationItem & { tutorialData: TutorialNavigationData & { step: TutorialStep['step']; }; }; /** * Represents the contents of the tutorial files to be generated by the build script */ export type TutorialFiles = { sourceCode?: FileSystemTree; metadata?: TutorialMetadata; sourceCodeZip?: Uint8Array; route?: Omit<TutorialNavigationItemWithStep, 'path'>; }; export type PlaygroundFiles = { sourceCode?: FileSystemTree; metadata?: TutorialMetadata; sourceCodeZip?: undefined; route?: PlaygroundRouteData; }; /** Represents the contents of the tutorial config file */ export type TutorialMetadata = { type: TutorialConfig['type']; /** a record of all tutorials filenames and its contents */ tutorialFiles: FileAndContentRecord; /** a record of filenames and contents for the tutorial answer */ answerFiles?: FileAndContentRecord; /** files that are part of the project but are not visible in the code editor */ hiddenFiles: string[]; /** * All files in the project, used to find the difference between new and old projects * when changing projects */ allFiles: string[]; openFiles: NonNullable<TutorialConfig['openFiles']>; /** whether a package.json exists */ dependencies?: Record<string, string>; }; export type TutorialStep = { step: number; name: string; path: string; url: string; nextStep?: TutorialStep['url']; previousStep?: TutorialStep['url']; nextTutorial?: string; }; export type TutorialConfig = | EditorTutorialConfig | LocalTutorialConfig | CliTutorialConfig | EditorOnlyTutorialConfig; export interface TutorialConfigBase { type: TutorialType; /** The tutorial title */ title: string; /** The name of the tutorial folder that will be started after the current one ends. */ nextTutorial?: string; /** The path to the tutorial src folder when it's external to the tutorial */ src?: string; /** The path to the tutorial answer folder when it's external to the tutorial */ answerSrc?: string; /** An array of files to be open in the editor */ openFiles?: string[]; } /** Represents a tutorial config with all the embedded editor components enabled */ export interface EditorTutorialConfig extends TutorialConfigBase { type: TutorialType.EDITOR; } /** Represents a tutorial config that won't use the embedded editor */ export interface LocalTutorialConfig extends TutorialConfigBase { type: TutorialType.LOCAL; // fields that must be undefined for local app tutorials openFiles?: undefined; src?: undefined; answerSrc?: undefined; } /** Represents a tutorial config that supports only the interactive terminal for the Angular CLI */ export type CliTutorialConfig = Omit<LocalTutorialConfig, 'type'> & { type: TutorialType.CLI; }; export type EditorOnlyTutorialConfig = Omit<EditorTutorialConfig, 'type'> & { type: TutorialType.EDITOR_ONLY; }; export type FileAndContent = { path: string; content: string | Uint8Array; }; export type FileAndContentRecord = Record<FileAndContent['path'], FileAndContent['content']>; export type TutorialNavigationItem = { path: NonNullable<NavigationItem['path']>; label: NonNullable<NavigationItem['label']>; children?: TutorialNavigationItem[]; parent?: TutorialNavigationItem; contentPath?: string; tutorialData: TutorialNavigationData; }; export type TutorialNavigationData = { type: TutorialConfig['type']; title: TutorialConfig['title']; nextStep?: string; previousStep?: string; nextTutorial?: string; sourceCodeZipPath?: string; }; export type PlaygroundRouteData = { templates: PlaygroundTemplate[]; defaultTemplate?: PlaygroundTemplate; starterTemplate?: PlaygroundTemplate; }; export type PlaygroundTemplate = Required<Pick<NavigationItem, 'path' | 'label'>>; // Note: only the fields being used are defined in this type export interface PackageJson { dependencies: Record<string, string>; devDependencies: Record<string, string>; } export const enum TutorialType { CLI = 'cli', LOCAL = 'local', EDITOR = 'editor', EDITOR_ONLY = 'editor-only', }
{ "end_byte": 4525, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/tutorial.ts" }
angular/adev/shared-docs/interfaces/doc-content.ts_0_481
/*! * @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 */ /** Represents a documentation page data. */ export interface DocContent { /** The unique identifier for this document. */ id: string; /** The HTML to display in the doc viewer. */ contents: string; /** The unique title for this document page. */ title?: string; }
{ "end_byte": 481, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/shared-docs/interfaces/doc-content.ts" }
angular/adev/scripts/update-cli-help/README.md_0_218
# Generating data for `angular.dev/cli` This script updates the Angular CLI help JSON files stored in `adev/src/content/cli/help`. This files are used to generate the [angular.dev CLI](https://angular.dev/cli) pages.
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/scripts/update-cli-help/README.md" }
angular/adev/scripts/update-cli-help/index.mjs_0_4729
import {execSync} from 'node:child_process'; import {readFile, writeFile, readdir, mkdtemp, realpath, copyFile, unlink} from 'node:fs/promises'; import {tmpdir} from 'node:os'; import {get} from 'node:https'; import {dirname, resolve as resolvePath, posix, join} from 'node:path'; import {fileURLToPath} from 'node:url'; import {existsSync, constants as fsConstants} from 'node:fs'; const GITHUB_API = 'https://api.github.com/repos/'; const CLI_BUILDS_REPO = 'angular/cli-builds'; const GITHUB_API_CLI_BUILDS = posix.join(GITHUB_API, CLI_BUILDS_REPO); const scriptDir = dirname(fileURLToPath(import.meta.url)); const CLI_HELP_CONTENT_PATH = resolvePath(scriptDir, '../../src/content/cli/help'); const CLI_SHA_PATH = join(CLI_HELP_CONTENT_PATH, 'build-info.json'); async function main() { if (!existsSync(CLI_SHA_PATH)) { throw new Error(`${CLI_SHA_PATH} does not exist.`); } const branch = process.env.GITHUB_REF; const {sha: currentSha} = JSON.parse(await readFile(CLI_SHA_PATH, 'utf-8')); const latestSha = await getShaFromCliBuilds(branch); console.log(`Comparing ${currentSha}...${latestSha}.`); const affectedFiles = await getAffectedFiles(currentSha, latestSha); const changedHelpFiles = affectedFiles.filter((file) => file.startsWith('help/')); if (changedHelpFiles.length === 0) { console.log(`No 'help/**' files changed between ${currentSha} and ${latestSha}.`); return; } console.log( `The below help files changed between ${currentSha} and ${latestSha}:\n` + changedHelpFiles.map((f) => '* ' + f).join('\n'), ); const temporaryDir = await realpath(await mkdtemp(join(tmpdir(), 'cli-src-'))); const execOptions = {cwd: temporaryDir, stdio: 'inherit'}; execSync('git init', execOptions); execSync('git remote add origin https://github.com/angular/cli-builds.git', execOptions); // fetch a commit execSync(`git fetch origin ${latestSha}`, execOptions); // reset this repository's main branch to the commit of interest execSync('git reset --hard FETCH_HEAD', execOptions); // get sha when files where changed const shaWhenFilesChanged = execSync(`git rev-list -1 ${latestSha} "help/"`, { encoding: 'utf8', cwd: temporaryDir, stdio: ['ignore', 'pipe', 'ignore'], }).trim(); // Delete existing JSON help files. const helpFilesUnlink = (await readdir(CLI_HELP_CONTENT_PATH)) .filter((f) => f.endsWith('.json')) .map((f) => unlink(join(CLI_HELP_CONTENT_PATH, f))); await Promise.allSettled(helpFilesUnlink); // Copy new help files const tempHelpDir = join(temporaryDir, 'help'); const helpFilesCopy = (await readdir(tempHelpDir)).map((f) => { const src = join(tempHelpDir, f); const dest = join(CLI_HELP_CONTENT_PATH, f); return copyFile(src, dest, fsConstants.COPYFILE_FICLONE); }); await Promise.allSettled(helpFilesCopy); // Write SHA to file. await writeFile( CLI_SHA_PATH, JSON.stringify( { branchName: branch, sha: shaWhenFilesChanged, }, undefined, 2, ), ); console.log('\nChanges: '); execSync(`git status --porcelain`, {stdio: 'inherit'}); console.log(`Successfully updated help files in '${CLI_HELP_CONTENT_PATH}'.\n`); } /** * Get SHA of a branch. * * @param {string} branch * @param {string} headSha * @returns Promise<string> */ async function getShaFromCliBuilds(branch) { const sha = await httpGet(`${GITHUB_API_CLI_BUILDS}/commits/${branch}`, { headers: {Accept: 'application/vnd.github.VERSION.sha'}, }); if (!sha) { throw new Error(`Unable to extract the SHA for '${branch}'.`); } return sha; } /** * Get the affected files. * * @param {string} baseSha * @param {string} headSha * @returns Promise<string[]> */ async function getAffectedFiles(baseSha, headSha) { const {files} = JSON.parse( await httpGet(`${GITHUB_API_CLI_BUILDS}/compare/${baseSha}...${headSha}`), ); return files.map((f) => f.filename); } function httpGet(url, options = {}) { options.headers ??= {}; options.headers[ 'Authorization' ] = `token ${process.env.ANGULAR_CLI_BUILDS_READONLY_GITHUB_TOKEN}`; // User agent is required // https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#user-agent-required options.headers['User-Agent'] = `ADEV_Angular_CLI_Sources_Update`; return new Promise((resolve, reject) => { get(url, options, (res) => { let data = ''; res .on('data', (chunk) => { data += chunk; }) .on('end', () => { resolve(data); }); }).on('error', (e) => { reject(e); }); }); } main().catch((err) => { console.error(err); process.exit(1); });
{ "end_byte": 4729, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/scripts/update-cli-help/index.mjs" }
angular/adev/src/index.html_0_4215
<!doctype html> <!-- We set all theme classes to allow critters to inline the theme styles and prevent flickering --> <html lang="en" class="docs-dark-mode docs-light-mode"> <head> <script> // This logic must execute early, so that we set the necessary // CSS classes to the document node and avoid unstyled content // from appearing on the page. const THEME_PREFERENCE_LOCAL_STORAGE_KEY = 'themePreference'; const DARK_MODE_CLASS_NAME = 'docs-dark-mode'; const LIGHT_MODE_CLASS_NAME = 'docs-light-mode'; const PREFERS_COLOR_SCHEME_DARK = '(prefers-color-scheme: dark)'; const theme = localStorage.getItem(THEME_PREFERENCE_LOCAL_STORAGE_KEY) ?? 'auto'; const prefersDark = window.matchMedia && window.matchMedia(PREFERS_COLOR_SCHEME_DARK).matches; const documentClassList = this.document.documentElement.classList; // clearing classes before setting them. this.document.documentElement.className = ''; if (theme === 'dark' || (theme === 'auto' && prefersDark)) { documentClassList.add(DARK_MODE_CLASS_NAME); } else { documentClassList.add(LIGHT_MODE_CLASS_NAME); } if(location.search.includes('uwu')) { documentClassList.add('uwu'); } </script> <style> .uwu-logo { display: none; } html.uwu .angular-logo { display: none; } html.uwu .uwu-logo { display: block !important; } </style> <meta charset="utf-8" /> <title>Angular</title> <base href="/" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!-- Primary Meta Tags --> <meta name="title" content="Angular" /> <meta name="description" content="The web development framework for building modern apps." /> <!-- Favicons --> <link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png" /> <link rel="icon" type="image/png" sizes="48x48" href="/assets/icons/favicon-48x48.png" /> <link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png" /> <link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png" /> <link rel="manifest" href="/assets/icons/site.webmanifest" /> <link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#e90464" /> <link rel="shortcut icon" href="/assets/icons/favicon.ico" /> <link rel="canonical" href="https://angular.dev"> <meta name="apple-mobile-web-app-title" content="Angular" /> <meta name="application-name" content="Angular" /> <meta name="msapplication-TileColor" content="#e90464" /> <meta name="msapplication-config" content="/assets/icons/browserconfig.xml" /> <meta name="theme-color" content="#ffffff" /> <!-- Open Graph / Facebook --> <meta property="og:type" content="website" /> <meta property="og:url" content="https://angular.dev/" /> <meta property="og:title" content="Angular" /> <meta property="og:description" content="The web development framework for building modern apps." /> <meta property="og:image" content="https://angular.dev/assets/images/ng-image.jpg" /> <!-- Twitter --> <meta property="twitter:card" content="summary_large_image" /> <meta property="twitter:url" content="https://angular.dev/" /> <meta property="twitter:title" content="Angular" /> <meta property="twitter:description" content="The web development framework for building modern apps." /> <meta property="twitter:image" content="https://angular.dev/assets/images/ng-image.jpg" /> <!-- Fonts --> <link href="https://fonts.googleapis.com/css2?family=Inter+Tight:wght@500;600&family=Inter:wght@400;500;600&family=DM+Mono:ital@0;1&display=swap" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" rel="stylesheet" /> <link rel="preload" href="/assets/textures/gradient.jpg" as="image" /> </head> <body class="mat-typography docs-scroll-track-transparent-large"> <adev-root></adev-root> </body> </html>
{ "end_byte": 4215, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/index.html" }
angular/adev/src/main.ts_0_445
/*! * @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 {bootstrapApplication} from '@angular/platform-browser'; import {appConfig} from './app/app.config'; import {AppComponent} from './app/app.component'; bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/main.ts" }
angular/adev/src/main.server.ts_0_462
/*! * @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 {bootstrapApplication} from '@angular/platform-browser'; import {AppComponent} from './app/app.component'; import {config} from './app/app.config.server'; const bootstrap = () => bootstrapApplication(AppComponent, config); export default bootstrap;
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/main.server.ts" }
angular/adev/src/local-styles.scss_0_26
@import './styles/xterm';
{ "end_byte": 26, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/local-styles.scss" }
angular/adev/src/robots.txt_0_88
# Allow all URLs (see https://www.robotstxt.org/robotstxt.html) User-agent: * Disallow:
{ "end_byte": 88, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/robots.txt" }
angular/adev/src/app/app.component.html_0_923
@defer (when isBrowser) { <adev-progress-bar /> <docs-top-level-banner expiry="2024-09-27" id="ng-survey-2024" link="https://goo.gle/angular-survey-2024" text="Take the 2024 Angular Developer Survey today!" /> } <button (click)="focusFirstHeading()" class="adev-skip">Skip to main content</button> <div class="adev-nav"></div> @if (displaySecondaryNav()) { <adev-secondary-navigation /> } <div class="docs-app-main-content"> <!-- Avoid rendering cookies popup on the server, since there is no benefit of doing this and it requires additional state management. --> @defer (when isBrowser) { <docs-cookie-popup /> @defer (when displaySearchDialog(); prefetch on idle) { @if (displaySearchDialog()) { <docs-search-dialog (onClose)="displaySearchDialog.set(false)" /> } } } <router-outlet /> @if (displayFooter()) { <footer adev-footer></footer> } </div>
{ "end_byte": 923, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/app.component.html" }
angular/adev/src/app/routes.ts_0_6391
/*! * @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 {contentResolver, flatNavigationData, mapNavigationItemsToRoutes} from '@angular/docs'; import {Route} from '@angular/router'; import {DefaultPage, PagePrefix} from './core/enums/pages'; import {SUB_NAVIGATION_DATA} from './sub-navigation-data'; import {mapApiManifestToRoutes} from './features/references/helpers/manifest.helper'; // Docs navigation data contains routes which navigates to /tutorials pages, in // that case we should load Tutorial component export const DOCS_ROUTES = mapNavigationItemsToRoutes( flatNavigationData(SUB_NAVIGATION_DATA.docs).filter( (route) => !route.path?.startsWith(PagePrefix.TUTORIALS) && route.path !== PagePrefix.PLAYGROUND, ), { loadComponent: () => import('./features/docs/docs.component'), data: { displaySecondaryNav: true, }, }, ); const referenceNavigationItems = flatNavigationData(SUB_NAVIGATION_DATA.reference); const commonReferenceRouteData = { displaySecondaryNav: true, }; const referencePageRoutes = mapNavigationItemsToRoutes( referenceNavigationItems.filter((r) => r.path === DefaultPage.REFERENCE), { loadComponent: () => import('./features/references/api-reference-list/api-reference-list.component'), data: commonReferenceRouteData, }, ); const updateGuidePageRoute: Route = { path: referenceNavigationItems.find((r) => r.path === DefaultPage.UPDATE)!.path, loadComponent: () => import('./features/update/update.component'), data: commonReferenceRouteData, }; const cliReferencePageRoutes = mapNavigationItemsToRoutes( referenceNavigationItems.filter((r) => r.path?.startsWith(`${PagePrefix.CLI}/`)), { loadComponent: () => import( './features/references/cli-reference-details-page/cli-reference-details-page.component' ), data: commonReferenceRouteData, }, ).map((route) => ({ ...route, resolve: { docContent: contentResolver(`${route.path}.html`), }, })); const docsReferencePageRoutes = mapNavigationItemsToRoutes( referenceNavigationItems.filter( (r) => r.path !== DefaultPage.REFERENCE && r.path !== DefaultPage.UPDATE && !r.path?.startsWith(`${PagePrefix.API}/`) && !r.path?.startsWith(`${PagePrefix.CLI}/`), ), { loadComponent: () => import('./features/docs/docs.component'), data: { ...commonReferenceRouteData, }, }, ); export const REFERENCE_ROUTES = [ ...referencePageRoutes, ...docsReferencePageRoutes, ...cliReferencePageRoutes, ]; const tutorialsNavigationItems = flatNavigationData(SUB_NAVIGATION_DATA.tutorials); const commonTutorialRouteData = { hideFooter: true, }; const docsTutorialsRoutes = mapNavigationItemsToRoutes( tutorialsNavigationItems.filter((route) => route.path === DefaultPage.TUTORIALS), { loadComponent: () => import('./features/docs/docs.component'), data: { ...commonTutorialRouteData, }, }, ); const tutorialComponentRoutes = mapNavigationItemsToRoutes( tutorialsNavigationItems.filter((route) => route.path !== DefaultPage.TUTORIALS), { loadComponent: () => import('./features/tutorial/tutorial.component'), data: {...commonTutorialRouteData}, }, ); export const TUTORIALS_ROUTES = [...docsTutorialsRoutes, ...tutorialComponentRoutes]; // Based on SUB_NAVIGATION_DATA structure, we need to build the routing table // for content pages. export const SUB_NAVIGATION_ROUTES: Route[] = [ ...DOCS_ROUTES, ...REFERENCE_ROUTES, ...TUTORIALS_ROUTES, ]; const FOOTER_ROUTES: Route[] = mapNavigationItemsToRoutes( flatNavigationData(SUB_NAVIGATION_DATA.footer), {loadComponent: () => import('./features/docs/docs.component')}, ); const API_REFERENCE_ROUTES: Route[] = mapApiManifestToRoutes(); const REDIRECT_ROUTES: Route[] = [ { path: 'guide/templates/attribute-binding', redirectTo: 'guide/templates/binding#binding-dynamic-properties-and-attributes', }, { path: 'guide/templates/interpolation', redirectTo: 'guide/templates/binding#render-dynamic-text-with-text-interpolation', }, { path: 'guide/templates/class-binding', redirectTo: 'guide/templates/binding#css-class-and-style-property-bindings', }, { path: 'guide/templates/event-binding', redirectTo: 'guide/templates/event-listeners', }, { path: 'guide/templates/let-template-variables', redirectTo: 'guide/templates/variables#local-template-variables-with-let', }, { path: 'guide/templates/property-binding', redirectTo: 'guide/templates/binding#binding-dynamic-properties-and-attributes', }, { path: 'guide/templates/property-binding-best-practices', redirectTo: 'guide/templates/binding#binding-dynamic-properties-and-attributes', }, { path: 'guide/templates/reference-variables', redirectTo: 'guide/templates/variables#template-reference-variables', }, { path: 'guide/templates/svg-in-templates', redirectTo: 'guide/templates/binding', }, { path: 'guide/templates/template-statements', redirectTo: 'guide/templates/event-listeners', }, { path: 'guide', children: [ { path: 'pipes', redirectTo: '/guide/templates/pipes', }, ], }, ]; export const routes: Route[] = [ { path: '', children: [ { path: '', loadComponent: () => import('./features/home/home.component'), data: {label: 'Home'}, }, { path: PagePrefix.DOCS, redirectTo: DefaultPage.DOCS, }, { path: PagePrefix.TUTORIALS, redirectTo: DefaultPage.TUTORIALS, }, { path: PagePrefix.REFERENCE, redirectTo: DefaultPage.REFERENCE, }, { path: PagePrefix.PLAYGROUND, loadComponent: () => import('./features/playground/playground.component'), data: {...commonTutorialRouteData, label: 'Playground'}, }, ...SUB_NAVIGATION_ROUTES, ...API_REFERENCE_ROUTES, ...FOOTER_ROUTES, updateGuidePageRoute, ...REDIRECT_ROUTES, ], }, // Error page { path: '**', loadComponent: () => import('./features/docs/docs.component'), resolve: {'docContent': contentResolver('error')}, }, ];
{ "end_byte": 6391, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/routes.ts" }
angular/adev/src/app/sub-navigation-data.ts_0_2943
/*! * @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 {NavigationItem} from '@angular/docs'; // These 2 imports are expected to be red because they are generated a build time import FIRST_APP_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/first-app/routes.json'; import LEARN_ANGULAR_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/learn-angular/routes.json'; import DEFERRABLE_VIEWS_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/deferrable-views/routes.json'; import {DefaultPage} from './core/enums/pages'; import {getApiNavigationItems} from './features/references/helpers/manifest.helper'; interface SubNavigationData { docs: NavigationItem[]; reference: NavigationItem[]; tutorials: NavigationItem[]; footer: NavigationItem[]; } const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [ { label: 'Introduction', children: [ { label: 'What is Angular?', path: 'overview', contentPath: 'introduction/what-is-angular', }, { label: 'Installation', path: 'installation', contentPath: 'introduction/installation', }, { label: 'Essentials', children: [ { label: 'Overview', path: 'essentials', contentPath: 'introduction/essentials/overview', }, { label: 'Composing with Components', path: 'essentials/components', contentPath: 'introduction/essentials/components', }, { label: 'Managing Dynamic Data', path: 'essentials/managing-dynamic-data', contentPath: 'introduction/essentials/managing-dynamic-data', }, { label: 'Rendering Dynamic Templates', path: 'essentials/rendering-dynamic-templates', contentPath: 'introduction/essentials/rendering-dynamic-templates', }, { label: 'Conditionals and Loops', path: 'essentials/conditionals-and-loops', contentPath: 'introduction/essentials/conditionals-and-loops', }, { label: 'Handling User Interaction', path: 'essentials/handling-user-interaction', contentPath: 'introduction/essentials/handling-user-interaction', }, { label: 'Sharing Logic', path: 'essentials/sharing-logic', contentPath: 'introduction/essentials/sharing-logic', }, { label: 'Next Steps', path: 'essentials/next-steps', contentPath: 'introduction/essentials/next-steps', }, ], }, { label: 'Start coding! 🚀', path: 'tutorials/learn-angular', }, ], },
{ "end_byte": 2943, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/sub-navigation-data.ts" }
angular/adev/src/app/sub-navigation-data.ts_2946_12432
label: 'In-depth Guides', children: [ { label: 'Components', children: [ { label: 'Anatomy of components', path: 'guide/components', contentPath: 'guide/components/anatomy-of-components', }, { label: 'Importing and using components', path: 'guide/components/importing', contentPath: 'guide/components/importing', }, { label: 'Selectors', path: 'guide/components/selectors', contentPath: 'guide/components/selectors', }, { label: 'Styling', path: 'guide/components/styling', contentPath: 'guide/components/styling', }, { label: 'Accepting data with input properties', path: 'guide/components/inputs', contentPath: 'guide/components/inputs', }, { label: 'Custom events with outputs', path: 'guide/components/outputs', contentPath: 'guide/components/outputs', }, { label: 'output() function', path: 'guide/components/output-fn', contentPath: 'guide/components/output-function', }, { label: 'Content projection with ng-content', path: 'guide/components/content-projection', contentPath: 'guide/components/content-projection', }, { label: 'Host elements', path: 'guide/components/host-elements', contentPath: 'guide/components/host-elements', }, { label: 'Lifecycle', path: 'guide/components/lifecycle', contentPath: 'guide/components/lifecycle', }, { label: 'Referencing component children with queries', path: 'guide/components/queries', contentPath: 'guide/components/queries', }, { label: 'Using DOM APIs', path: 'guide/components/dom-apis', contentPath: 'guide/components/dom-apis', }, { label: 'Inheritance', path: 'guide/components/inheritance', contentPath: 'guide/components/inheritance', }, { label: 'Programmatically rendering components', path: 'guide/components/programmatic-rendering', contentPath: 'guide/components/programmatic-rendering', }, { label: 'Advanced configuration', path: 'guide/components/advanced-configuration', contentPath: 'guide/components/advanced-configuration', }, { label: 'Custom Elements', path: 'guide/elements', contentPath: 'guide/elements', }, ], }, { label: 'Templates', children: [ { label: 'Overview', path: 'guide/templates', contentPath: 'guide/templates/overview', }, { label: 'Binding dynamic text, properties and attributes', path: 'guide/templates/binding', contentPath: 'guide/templates/binding', }, { label: 'Adding event listeners', path: 'guide/templates/event-listeners', contentPath: 'guide/templates/event-listeners', }, { label: 'Two-way binding', path: 'guide/templates/two-way-binding', contentPath: 'guide/templates/two-way-binding', }, { label: 'Control flow', path: 'guide/templates/control-flow', contentPath: 'guide/templates/control-flow', }, { label: 'Pipes', path: 'guide/templates/pipes', contentPath: 'guide/templates/pipes', }, { label: 'Slotting child content with ng-content', path: 'guide/templates/ng-content', contentPath: 'guide/templates/ng-content', }, { label: 'Create template fragments with ng-template', path: 'guide/templates/ng-template', contentPath: 'guide/templates/ng-template', }, { label: 'Grouping elements with ng-container', path: 'guide/templates/ng-container', contentPath: 'guide/templates/ng-container', }, { label: 'Variables in templates', path: 'guide/templates/variables', contentPath: 'guide/templates/variables', }, { label: 'Deferred loading with @defer', path: 'guide/templates/defer', contentPath: 'guide/templates/defer', }, { label: 'Expression syntax', path: 'guide/templates/expression-syntax', contentPath: 'guide/templates/expression-syntax', }, { label: 'Whitespace in templates', path: 'guide/templates/whitespace', contentPath: 'guide/templates/whitespace', }, ], }, { label: 'Directives', children: [ { label: 'Overview', path: 'guide/directives', contentPath: 'guide/directives/overview', }, { label: 'Attribute directives', path: 'guide/directives/attribute-directives', contentPath: 'guide/directives/attribute-directives', }, { label: 'Structural directives', path: 'guide/directives/structural-directives', contentPath: 'guide/directives/structural-directives', }, { label: 'Directive composition API', path: 'guide/directives/directive-composition-api', contentPath: 'guide/directives/directive-composition-api', }, ], }, { label: 'Dependency Injection', children: [ { label: 'Overview', path: 'guide/di', contentPath: 'guide/di/overview', }, { label: 'Understanding dependency injection', path: 'guide/di/dependency-injection', contentPath: 'guide/di/dependency-injection', }, { label: 'Creating an injectable service', path: 'guide/di/creating-injectable-service', contentPath: 'guide/di/creating-injectable-service', }, { label: 'Defining dependency providers', path: 'guide/di/dependency-injection-providers', contentPath: 'guide/di/dependency-injection-providers', }, { label: 'Injection context', path: 'guide/di/dependency-injection-context', contentPath: 'guide/di/dependency-injection-context', }, { label: 'Hierarchical injectors', path: 'guide/di/hierarchical-dependency-injection', contentPath: 'guide/di/hierarchical-dependency-injection', }, { label: 'Optimizing injection tokens', path: 'guide/di/lightweight-injection-tokens', contentPath: 'guide/di/lightweight-injection-tokens', }, { label: 'DI in action', path: 'guide/di/di-in-action', contentPath: 'guide/di/di-in-action', }, ], }, { label: 'Signals', children: [ { label: 'Overview', path: 'guide/signals', contentPath: 'guide/signals/overview', }, { label: 'RxJS Interop', path: 'guide/signals/rxjs-interop', contentPath: 'guide/signals/rxjs-interop', }, { label: 'Inputs as signals', path: 'guide/signals/inputs', contentPath: 'guide/signals/inputs', }, { label: 'Model inputs', path: 'guide/signals/model', contentPath: 'guide/signals/model', }, { label: 'Queries as signals', path: 'guide/signals/queries', contentPath: 'guide/signals/queries', }, ], }, { label: 'Routing', children: [ { label: 'Overview', path: 'guide/routing', contentPath: 'guide/routing/overview', }, { label: 'Common routing tasks', path: 'guide/routing/common-router-tasks', contentPath: 'guide/routing/common-router-tasks', }, { label: 'Routing in single-page applications', path: 'guide/routing/router-tutorial', contentPath: 'guide/routing/router-tutorial', }, { label: 'Creating custom route matches', path: 'guide/routing/routing-with-urlmatcher', contentPath: 'guide/routing/routing-with-urlmatcher', }, { label: 'Router reference', path: 'guide/routing/router-reference', contentPath: 'guide/routing/router-reference', }, ], },
{ "end_byte": 12432, "start_byte": 2946, "url": "https://github.com/angular/angular/blob/main/adev/src/app/sub-navigation-data.ts" }
angular/adev/src/app/sub-navigation-data.ts_12439_20082
label: 'Forms', children: [ { label: 'Overview', path: 'guide/forms', contentPath: 'guide/forms/overview', }, { label: 'Reactive forms', path: 'guide/forms/reactive-forms', contentPath: 'guide/forms/reactive-forms', }, { label: 'Strictly typed reactive forms', path: 'guide/forms/typed-forms', contentPath: 'guide/forms/typed-forms', }, { label: 'Template-driven forms', path: 'guide/forms/template-driven-forms', contentPath: 'guide/forms/template-driven-forms', }, { label: 'Validate form input', path: 'guide/forms/form-validation', contentPath: 'guide/forms/form-validation', }, { label: 'Building dynamic forms', path: 'guide/forms/dynamic-forms', contentPath: 'guide/forms/dynamic-forms', }, ], }, { label: 'HTTP Client', children: [ { label: 'Overview', path: 'guide/http', contentPath: 'guide/http/overview', }, { label: 'Setting up HttpClient', path: 'guide/http/setup', contentPath: 'guide/http/setup', }, { label: 'Making requests', path: 'guide/http/making-requests', contentPath: 'guide/http/making-requests', }, { label: 'Intercepting requests and responses', path: 'guide/http/interceptors', contentPath: 'guide/http/interceptors', }, { label: 'Testing', path: 'guide/http/testing', contentPath: 'guide/http/testing', }, ], }, { label: 'Performance', children: [ { label: 'Overview', path: 'guide/performance', contentPath: 'guide/performance/overview', }, { label: 'Deferrable views', path: 'guide/defer', contentPath: 'guide/defer', }, { label: 'Image Optimization', path: 'guide/image-optimization', contentPath: 'guide/image-optimization', }, { label: 'Server-side Rendering', path: 'guide/ssr', contentPath: 'guide/ssr', }, { label: 'Build-time prerendering', path: 'guide/prerendering', contentPath: 'guide/prerendering', }, { label: 'Hydration', path: 'guide/hydration', contentPath: 'guide/hydration', }, ], }, { label: 'Testing', children: [ { label: 'Overview', path: 'guide/testing', contentPath: 'guide/testing/overview', }, { label: 'Code coverage', path: 'guide/testing/code-coverage', contentPath: 'guide/testing/code-coverage', }, { label: 'Testing services', path: 'guide/testing/services', contentPath: 'guide/testing/services', }, { label: 'Basics of testing components', path: 'guide/testing/components-basics', contentPath: 'guide/testing/components-basics', }, { label: 'Component testing scenarios', path: 'guide/testing/components-scenarios', contentPath: 'guide/testing/components-scenarios', }, { label: 'Testing attribute directives', path: 'guide/testing/attribute-directives', contentPath: 'guide/testing/attribute-directives', }, { label: 'Testing pipes', path: 'guide/testing/pipes', contentPath: 'guide/testing/pipes', }, { label: 'Debugging tests', path: 'guide/testing/debugging', contentPath: 'guide/testing/debugging', }, { label: 'Testing utility APIs', path: 'guide/testing/utility-apis', contentPath: 'guide/testing/utility-apis', }, ], }, { label: 'Internationalization', children: [ { label: 'Overview', path: 'guide/i18n', contentPath: 'guide/i18n/overview', }, { label: 'Add the localize package', path: 'guide/i18n/add-package', contentPath: 'guide/i18n/add-package', }, { label: 'Refer to locales by ID', path: 'guide/i18n/locale-id', contentPath: 'guide/i18n/locale-id', }, { label: 'Format data based on locale', path: 'guide/i18n/format-data-locale', contentPath: 'guide/i18n/format-data-locale', }, { label: 'Prepare component for translation', path: 'guide/i18n/prepare', contentPath: 'guide/i18n/prepare', }, { label: 'Work with translation files', path: 'guide/i18n/translation-files', contentPath: 'guide/i18n/translation-files', }, { label: 'Merge translations into the app', path: 'guide/i18n/merge', contentPath: 'guide/i18n/merge', }, { label: 'Deploy multiple locales', path: 'guide/i18n/deploy', contentPath: 'guide/i18n/deploy', }, { label: 'Import global variants of the locale data', path: 'guide/i18n/import-global-variants', contentPath: 'guide/i18n/import-global-variants', }, { label: 'Manage marked text with custom IDs', path: 'guide/i18n/manage-marked-text', contentPath: 'guide/i18n/manage-marked-text', }, { label: 'Example Angular application', path: 'guide/i18n/example', contentPath: 'guide/i18n/example', }, ], }, { label: 'Animations', children: [ { label: 'Overview', path: 'guide/animations', contentPath: 'guide/animations/overview', }, { label: 'Transition and Triggers', path: 'guide/animations/transition-and-triggers', contentPath: 'guide/animations/transition-and-triggers', }, { label: 'Complex Sequences', path: 'guide/animations/complex-sequences', contentPath: 'guide/animations/complex-sequences', }, { label: 'Reusable Animations', path: 'guide/animations/reusable-animations', contentPath: 'guide/animations/reusable-animations', }, { label: 'Route transition animations', path: 'guide/animations/route-animations', contentPath: 'guide/animations/route-animations', }, ], }, { label: 'Experimental features', children: [ {label: 'Zoneless', path: 'guide/experimental/zoneless', contentPath: 'guide/zoneless'}, ], }, ], },
{ "end_byte": 20082, "start_byte": 12439, "url": "https://github.com/angular/angular/blob/main/adev/src/app/sub-navigation-data.ts" }
angular/adev/src/app/sub-navigation-data.ts_20085_27829
label: 'Developer Tools', children: [ { label: 'Angular CLI', children: [ { label: 'Overview', path: 'tools/cli', contentPath: 'tools/cli/overview', }, { label: 'Local set-up', path: 'tools/cli/setup-local', contentPath: 'tools/cli/setup-local', }, { label: 'Building Angular apps', path: 'tools/cli/build', contentPath: 'tools/cli/build', }, { label: 'Serving Angular apps for development', path: 'tools/cli/serve', contentPath: 'tools/cli/serve', }, { label: 'Deployment', path: 'tools/cli/deployment', contentPath: 'tools/cli/deployment', }, { label: 'End-to-End Testing', path: 'tools/cli/end-to-end', contentPath: 'tools/cli/end-to-end', }, { label: 'Migrating to new build system', path: 'tools/cli/build-system-migration', contentPath: 'tools/cli/build-system-migration', }, { label: 'Build environments', path: 'tools/cli/environments', contentPath: 'tools/cli/environments', }, { label: 'Angular CLI builders', path: 'tools/cli/cli-builder', contentPath: 'tools/cli/cli-builder', }, { label: 'Generating code using schematics', path: 'tools/cli/schematics', contentPath: 'tools/cli/schematics', }, { label: 'Authoring schematics', path: 'tools/cli/schematics-authoring', contentPath: 'tools/cli/schematics-authoring', }, { label: 'Schematics for libraries', path: 'tools/cli/schematics-for-libraries', contentPath: 'tools/cli/schematics-for-libraries', }, { label: 'Template type checking', path: 'tools/cli/template-typecheck', contentPath: 'tools/cli/template-typecheck', }, { label: 'Ahead-of-time (AOT) compilation', path: 'tools/cli/aot-compiler', contentPath: 'tools/cli/aot-compiler', }, { label: 'AOT metadata errors', path: 'tools/cli/aot-metadata-errors', contentPath: 'tools/cli/aot-metadata-errors', }, ], }, { label: 'Libraries', children: [ { label: 'Overview', path: 'tools/libraries', contentPath: 'tools/libraries/overview', }, { label: 'Creating Libraries', path: 'tools/libraries/creating-libraries', contentPath: 'tools/libraries/creating-libraries', }, { label: 'Using Libraries', path: 'tools/libraries/using-libraries', contentPath: 'tools/libraries/using-libraries', }, { label: 'Angular Package Format', path: 'tools/libraries/angular-package-format', contentPath: 'tools/libraries/angular-package-format', }, ], }, { label: 'DevTools', path: 'tools/devtools', contentPath: 'tools/devtools', }, { label: 'Language Service', path: 'tools/language-service', contentPath: 'tools/language-service', }, ], }, { label: 'Best Practices', children: [ { label: 'Style Guide', path: 'style-guide', contentPath: 'best-practices/style-guide', }, { label: 'Security', path: 'best-practices/security', contentPath: 'guide/security', // Have not refactored due to build issues }, { label: 'Accessibility', path: 'best-practices/a11y', contentPath: 'best-practices/a11y', }, { label: 'Performance', children: [ { label: 'Overview', path: 'best-practices/runtime-performance', contentPath: 'best-practices/runtime-performance/overview', }, { label: 'Zone pollution', path: 'best-practices/zone-pollution', contentPath: 'best-practices/runtime-performance/zone-pollution', }, { label: 'Slow computations', path: 'best-practices/slow-computations', contentPath: 'best-practices/runtime-performance/slow-computations', }, { label: 'Skipping component subtrees', path: 'best-practices/skipping-subtrees', contentPath: 'best-practices/runtime-performance/skipping-subtrees', }, ], }, { label: 'Keeping up-to-date', path: 'update', contentPath: 'best-practices/update', }, ], }, { label: 'Extended Ecosystem', children: [ { label: 'Service Workers & PWAs', children: [ { label: 'Overview', path: 'ecosystem/service-workers', contentPath: 'ecosystem/service-workers/overview', }, { label: 'Getting started', path: 'ecosystem/service-workers/getting-started', contentPath: 'ecosystem/service-workers/getting-started', }, { label: 'Configuration file', path: 'ecosystem/service-workers/config', contentPath: 'ecosystem/service-workers/config', }, { label: 'Communicating with the service worker', path: 'ecosystem/service-workers/communications', contentPath: 'ecosystem/service-workers/communications', }, { label: 'Push notifications', path: 'ecosystem/service-workers/push-notifications', contentPath: 'ecosystem/service-workers/push-notifications', }, { label: 'Service worker devops', path: 'ecosystem/service-workers/devops', contentPath: 'ecosystem/service-workers/devops', }, { label: 'App shell pattern', path: 'ecosystem/service-workers/app-shell', contentPath: 'ecosystem/service-workers/app-shell', }, ], }, { label: 'Web workers', path: 'ecosystem/web-workers', contentPath: 'ecosystem/web-workers', }, { label: 'Angular Fire', path: 'https://github.com/angular/angularfire#readme', }, { label: 'Google Maps', path: 'https://github.com/angular/components/tree/main/src/google-maps#readme', }, { label: 'Google Pay', path: 'https://github.com/google-pay/google-pay-button#angular', }, { label: 'YouTube player', path: 'https://github.com/angular/components/blob/main/src/youtube-player/README.md', }, { label: 'Angular CDK', path: 'https://material.angular.io/cdk/categories', }, { label: 'Angular Material', path: 'https://material.angular.io/', }, ], }, ]; export const TUTORIALS_SUB_NAVIGATION_DATA: NavigationItem[] = [ FIRST_APP_TUTORIAL_NAV_DATA, LEARN_ANGULAR_TUTORIAL_NAV_DATA, DEFERRABLE_VIEWS_TUTORIAL_NAV_DATA, { path: DefaultPage.TUTORIALS, contentPath: 'tutorials/home', label: 'Tutorials', }, ]; c
{ "end_byte": 27829, "start_byte": 20085, "url": "https://github.com/angular/angular/blob/main/adev/src/app/sub-navigation-data.ts" }
angular/adev/src/app/sub-navigation-data.ts_27831_32638
st REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [ { label: 'Roadmap', path: 'roadmap', contentPath: 'reference/roadmap', }, { label: 'Get involved', path: 'https://github.com/angular/angular/blob/main/CONTRIBUTING.md', }, { label: 'API Reference', children: [ { label: 'Overview', path: 'api', }, ...getApiNavigationItems(), ], }, { label: 'CLI Reference', children: [ { label: 'Overview', path: 'cli', contentPath: 'reference/cli', }, { label: 'ng add', path: 'cli/add', }, { label: 'ng analytics', children: [ { label: 'Overview', path: 'cli/analytics', }, { label: 'disable', path: 'cli/analytics/disable', }, { label: 'enable', path: 'cli/analytics/enable', }, { label: 'info', path: 'cli/analytics/info', }, { label: 'prompt', path: 'cli/analytics/prompt', }, ], }, { label: 'ng build', path: 'cli/build', }, { label: 'ng cache', children: [ { label: 'Overview', path: 'cli/cache', }, { label: 'clear', path: 'cli/cache/clean', }, { label: 'disable', path: 'cli/cache/disable', }, { label: 'enable', path: 'cli/cache/enable', }, { label: 'info', path: 'cli/cache/info', }, ], }, { label: 'ng completion', children: [ { label: 'Overview', path: 'cli/completion', }, { label: 'script', path: 'cli/completion/script', }, ], }, { label: 'ng config', path: 'cli/config', }, { label: 'ng deploy', path: 'cli/deploy', }, { label: 'ng e2e', path: 'cli/e2e', }, { label: 'ng extract-i18n', path: 'cli/extract-i18n', }, { label: 'ng generate', children: [ { label: 'Overview', path: 'cli/generate', }, { label: 'app-shell', path: 'cli/generate/app-shell', }, { label: 'application', path: 'cli/generate/application', }, { label: 'class', path: 'cli/generate/class', }, { label: 'component', path: 'cli/generate/component', }, { label: 'config', path: 'cli/generate/config', }, { label: 'directive', path: 'cli/generate/directive', }, { label: 'enum', path: 'cli/generate/enum', }, { label: 'environments', path: 'cli/generate/environments', }, { label: 'guard', path: 'cli/generate/guard', }, { label: 'interceptor', path: 'cli/generate/interceptor', }, { label: 'interface', path: 'cli/generate/interface', }, { label: 'library', path: 'cli/generate/library', }, { label: 'module', path: 'cli/generate/module', }, { label: 'pipe', path: 'cli/generate/pipe', }, { label: 'resolver', path: 'cli/generate/resolver', }, { label: 'service-worker', path: 'cli/generate/service-worker', }, { label: 'service', path: 'cli/generate/service', }, { label: 'web-worker', path: 'cli/generate/web-worker', }, ], }, { label: 'ng lint', path: 'cli/lint', }, { label: 'ng new', path: 'cli/new', }, { label: 'ng run', path: 'cli/run', }, { label: 'ng serve', path: 'cli/serve', }, { label: 'ng test', path: 'cli/test', }, { label: 'ng update', path: 'cli/update', }, { label: 'ng version', path: 'cli/version', }, ], },
{ "end_byte": 32638, "start_byte": 27831, "url": "https://github.com/angular/angular/blob/main/adev/src/app/sub-navigation-data.ts" }
angular/adev/src/app/sub-navigation-data.ts_32641_38918
label: 'Error Encyclopedia', children: [ { label: 'Overview', path: 'errors', contentPath: 'reference/errors/overview', }, { label: 'NG0100: Expression Changed After Checked', path: 'errors/NG0100', contentPath: 'reference/errors/NG0100', }, { label: 'NG01101: Wrong Async Validator Return Type', path: 'errors/NG01101', contentPath: 'reference/errors/NG01101', }, { label: 'NG01203: Missing value accessor', path: 'errors/NG01203', contentPath: 'reference/errors/NG01203', }, { label: 'NG0200: Circular Dependency in DI', path: 'errors/NG0200', contentPath: 'reference/errors/NG0200', }, { label: 'NG0201: No Provider Found', path: 'errors/NG0201', contentPath: 'reference/errors/NG0201', }, { label: 'NG0203: `inject()` must be called from an injection context', path: 'errors/NG0203', contentPath: 'reference/errors/NG0203', }, { label: 'NG0209: Invalid multi provider', path: 'errors/NG0209', contentPath: 'reference/errors/NG0209', }, { label: 'NG02200: Missing Iterable Differ', path: 'errors/NG02200', contentPath: 'reference/errors/NG02200', }, { label: 'NG02800: JSONP support in HttpClient configuration', path: 'errors/NG02800', contentPath: 'reference/errors/NG02800', }, { label: 'NG0300: Selector Collision', path: 'errors/NG0300', contentPath: 'reference/errors/NG0300', }, { label: 'NG0301: Export Not Found', path: 'errors/NG0301', contentPath: 'reference/errors/NG0301', }, { label: 'NG0302: Pipe Not Found', path: 'errors/NG0302', contentPath: 'reference/errors/NG0302', }, { label: `NG0403: Bootstrapped NgModule doesn't specify which component to initialize`, path: 'errors/NG0403', contentPath: 'reference/errors/NG0403', }, { label: 'NG0500: Hydration Node Mismatch', path: 'errors/NG0500', contentPath: 'reference/errors/NG0500', }, { label: 'NG0501: Hydration Missing Siblings', path: 'errors/NG0501', contentPath: 'reference/errors/NG0501', }, { label: 'NG0502: Hydration Missing Node', path: 'errors/NG0502', contentPath: 'reference/errors/NG0502', }, { label: 'NG0503: Hydration Unsupported Projection of DOM Nodes', path: 'errors/NG0503', contentPath: 'reference/errors/NG0503', }, { label: 'NG0504: Skip hydration flag is applied to an invalid node', path: 'errors/NG0504', contentPath: 'reference/errors/NG0504', }, { label: 'NG0505: No hydration info in server response', path: 'errors/NG0505', contentPath: 'reference/errors/NG0505', }, { label: 'NG0506: NgZone remains unstable', path: 'errors/NG0506', contentPath: 'reference/errors/NG0506', }, { label: 'NG0507: HTML content was altered after server-side rendering', path: 'errors/NG0507', contentPath: 'reference/errors/NG0507', }, { label: 'NG0602: Disallowed function call inside reactive context', path: 'errors/NG0602', contentPath: 'reference/errors/NG0602', }, { label: 'NG05104: Root element was not found', path: 'errors/NG05104', contentPath: 'reference/errors/NG05104', }, { label: 'NG0910: Unsafe bindings on an iframe element', path: 'errors/NG0910', contentPath: 'reference/errors/NG0910', }, { label: 'NG0912: Component ID generation collision', path: 'errors/NG0912', contentPath: 'reference/errors/NG0912', }, { label: 'NG0913: Runtime Performance Warnings', path: 'errors/NG0913', contentPath: 'reference/errors/NG0913', }, { label: 'NG0950: Required input is accessed before a value is set.', path: 'errors/NG0950', contentPath: 'reference/errors/NG0950', }, { label: 'NG0951: Child query result is required but no value is available.', path: 'errors/NG0951', contentPath: 'reference/errors/NG0951', }, { label: 'NG0955: Track expression resulted in duplicated keys for a given collection', path: 'errors/NG0955', contentPath: 'reference/errors/NG0955', }, { label: 'NG0956: Tracking expression caused re-creation of the DOM structure', path: 'errors/NG0956', contentPath: 'reference/errors/NG0956', }, { label: 'NG1001: Argument Not Literal', path: 'errors/NG1001', contentPath: 'reference/errors/NG1001', }, { label: 'NG2003: Missing Token', path: 'errors/NG2003', contentPath: 'reference/errors/NG2003', }, { label: 'NG2009: Invalid Shadow DOM selector', path: 'errors/NG2009', contentPath: 'reference/errors/NG2009', }, { label: 'NG3003: Import Cycle Detected', path: 'errors/NG3003', contentPath: 'reference/errors/NG3003', }, { label: 'NG05000: Hydration with unsupported Zone.js instance.', path: 'errors/NG05000', contentPath: 'reference/errors/NG05000', }, { label: 'NG6100: NgModule.id Set to module.id anti-pattern', path: 'errors/NG6100', contentPath: 'reference/errors/NG6100', }, { label: 'NG8001: Invalid Element', path: 'errors/NG8001', contentPath: 'reference/errors/NG8001', }, { label: 'NG8002: Invalid Attribute', path: 'errors/NG8002', contentPath: 'reference/errors/NG8002', }, { label: 'NG8003: Missing Reference Target', path: 'errors/NG8003', contentPath: 'reference/errors/NG8003', }, ], },
{ "end_byte": 38918, "start_byte": 32641, "url": "https://github.com/angular/angular/blob/main/adev/src/app/sub-navigation-data.ts" }
angular/adev/src/app/sub-navigation-data.ts_38921_46264
label: 'Extended Diagnostics', children: [ { label: 'Overview', path: 'extended-diagnostics', contentPath: 'reference/extended-diagnostics/overview', }, { label: 'NG8101: Invalid Banana-in-Box', path: 'extended-diagnostics/NG8101', contentPath: 'reference/extended-diagnostics/NG8101', }, { label: 'NG8102: Nullish coalescing not nullable', path: 'extended-diagnostics/NG8102', contentPath: 'reference/extended-diagnostics/NG8102', }, { label: 'NG8103: Missing control flow directive', path: 'extended-diagnostics/NG8103', contentPath: 'reference/extended-diagnostics/NG8103', }, { label: 'NG8104: Text attribute not binding', path: 'extended-diagnostics/NG8104', contentPath: 'reference/extended-diagnostics/NG8104', }, { label: 'NG8105: Missing `let` keyword in an *ngFor expression', path: 'extended-diagnostics/NG8105', contentPath: 'reference/extended-diagnostics/NG8105', }, { label: 'NG8106: Suffix not supported', path: 'extended-diagnostics/NG8106', contentPath: 'reference/extended-diagnostics/NG8106', }, { label: 'NG8107: Optional chain not nullable', path: 'extended-diagnostics/NG8107', contentPath: 'reference/extended-diagnostics/NG8107', }, { label: 'NG8108: ngSkipHydration should be a static attribute', path: 'extended-diagnostics/NG8108', contentPath: 'reference/extended-diagnostics/NG8108', }, { label: 'NG8109: Signals must be invoked in template interpolations', path: 'extended-diagnostics/NG8109', contentPath: 'reference/extended-diagnostics/NG8109', }, { label: 'NG8111: Functions must be invoked in event bindings', path: 'extended-diagnostics/NG8111', contentPath: 'reference/extended-diagnostics/NG8111', }, { label: 'NG8113: Unused Standalone Imports', path: 'extended-diagnostics/NG8113', contentPath: 'reference/extended-diagnostics/NG8113', }, ], }, { label: 'Versioning and releases', path: 'reference/releases', contentPath: 'reference/releases', }, { label: 'Version compatibility', path: 'reference/versions', contentPath: 'reference/versions', }, { label: 'Update guide', path: 'update-guide', }, { label: 'Configurations', children: [ { label: 'File structure', path: 'reference/configs/file-structure', contentPath: 'reference/configs/file-structure', }, { label: 'Workspace configuration', path: 'reference/configs/workspace-config', contentPath: 'reference/configs/workspace-config', }, { label: 'Angular compiler options', path: 'reference/configs/angular-compiler-options', contentPath: 'reference/configs/angular-compiler-options', }, { label: 'npm dependencies', path: 'reference/configs/npm-packages', contentPath: 'reference/configs/npm-packages', }, ], }, { label: 'Migrations', children: [ { label: 'Overview', path: 'reference/migrations', contentPath: 'reference/migrations/overview', }, { label: 'Standalone', path: 'reference/migrations/standalone', contentPath: 'reference/migrations/standalone', }, { label: 'Control Flow Syntax', path: 'reference/migrations/control-flow', contentPath: 'reference/migrations/control-flow', }, { label: 'inject() Function', path: 'reference/migrations/inject-function', contentPath: 'reference/migrations/inject-function', }, { label: 'Lazy-loaded routes', path: 'reference/migrations/route-lazy-loading', contentPath: 'reference/migrations/route-lazy-loading', }, { label: 'Signal inputs', path: 'reference/migrations/signal-inputs', contentPath: 'reference/migrations/signal-inputs', }, { label: 'Signal queries', path: 'reference/migrations/signal-queries', contentPath: 'reference/migrations/signal-queries', }, ], }, { label: 'Concepts', children: [ { label: 'Overview', path: 'reference/concepts', contentPath: 'reference/concepts/overview', }, { label: 'NgModule', children: [ { label: 'Overview', path: 'guide/ngmodules', contentPath: 'guide/ngmodules/overview', }, { label: 'JS Modules vs NgModules', path: 'guide/ngmodules/vs-jsmodule', contentPath: 'guide/ngmodules/vs-jsmodule', }, { label: 'Launching your app with a root module', path: 'guide/ngmodules/bootstrapping', contentPath: 'guide/ngmodules/bootstrapping', }, { label: 'Sharing NgModules', path: 'guide/ngmodules/sharing', contentPath: 'guide/ngmodules/sharing', }, { label: 'Frequently used NgModules', path: 'guide/ngmodules/frequent', contentPath: 'guide/ngmodules/frequent', }, { label: 'Feature modules', path: 'guide/ngmodules/feature-modules', contentPath: 'guide/ngmodules/feature-modules', }, { label: 'Types of feature modules', path: 'guide/ngmodules/module-types', contentPath: 'guide/ngmodules/module-types', }, { label: 'Providing dependencies', path: 'guide/ngmodules/providers', contentPath: 'guide/ngmodules/providers', }, { label: 'Singleton services', path: 'guide/ngmodules/singleton-services', contentPath: 'guide/ngmodules/singleton-services', }, { label: 'Lazy-loading feature modules', path: 'guide/ngmodules/lazy-loading', contentPath: 'guide/ngmodules/lazy-loading', }, { label: 'NgModule API', path: 'guide/ngmodules/api', contentPath: 'guide/ngmodules/api', }, { label: 'NgModule FAQs', path: 'guide/ngmodules/faq', contentPath: 'guide/ngmodules/faq', }, ], }, ], }, ]; const FOOTER_NAVIGATION_DATA: NavigationItem[] = [ { label: 'Press Kit', path: 'press-kit', contentPath: 'reference/press-kit', }, { label: 'License', path: 'license', contentPath: 'reference/license', }, ]; // Docs navigation data structure, it's used to display structure in // navigation-list component And build the routing table for content pages. export const SUB_NAVIGATION_DATA: SubNavigationData = { docs: DOCS_SUB_NAVIGATION_DATA, reference: REFERENCE_SUB_NAVIGATION_DATA, tutorials: TUTORIALS_SUB_NAVIGATION_DATA, footer: FOOTER_NAVIGATION_DATA, };
{ "end_byte": 46264, "start_byte": 38921, "url": "https://github.com/angular/angular/blob/main/adev/src/app/sub-navigation-data.ts" }
angular/adev/src/app/app.config.server.ts_0_699
/*! * @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 {mergeApplicationConfig, ApplicationConfig} from '@angular/core'; import {provideServerRendering} from '@angular/platform-server'; import {provideServerRoutesConfig, RenderMode} from '@angular/ssr'; import {appConfig} from './app.config'; const serverConfig: ApplicationConfig = { providers: [ provideServerRendering(), provideServerRoutesConfig([{path: '**', renderMode: RenderMode.Prerender}]), ], }; export const config = mergeApplicationConfig(appConfig, serverConfig);
{ "end_byte": 699, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/app.config.server.ts" }
angular/adev/src/app/app.component.scss_0_2466
@use '@angular/docs/styles/media-queries' as mq; :host { max-width: 2560px; margin-inline: auto; display: flex; flex-direction: row; align-items: flex-start; min-height: 100vh; // Display top level banner below the navigation. docs-top-level-banner { @include mq.for-tablet { top: 4.6875rem; } @include mq.for-phone-only { top: 3.75rem; transform: translateY(0); transition: transform 0.3s ease-out 0.6s; } } // Case: If secondary navigation exists, display banner below secondary navigation for tablets. &:has(adev-secondary-navigation) { docs-top-level-banner { @include mq.for-tablet { top: 8.125rem; } } } // Case: If primary navigation is opened, display banner at the top of the page. &:has(.adev-nav-primary--open) { docs-top-level-banner { @include mq.for-phone-only { transform: translateY(-3.75rem); transition: transform 0.3s ease-in; } } } @include mq.for-tablet-landscape-down { flex-direction: column; } // If navs are open, render a blurry background over content &:has(.docs-nav-secondary--open), &:has(.adev-nav-primary--open) { .docs-app-main-content { &::after { visibility: visible; opacity: 1; } } } &:has(.adev-home) { .adev-nav { width: 0; height: 0; } @include mq.for-tablet-landscape-up { footer { margin-left: var(--primary-nav-width); } } } } .adev-skip { position: absolute; top: 0.5rem; left: 0.5rem; z-index: 1000; background: var(--primary-contrast); color: var(--page-background); border: 1px solid var(--vivid-pink); border-radius: 0.25rem; padding: 0.5rem; font-size: 0.875rem; transform: translateY(-150%); transition: transform 0.3s ease-out; &:focus { transform: translateY(0); } } .docs-app-main-content { display: flex; flex-direction: column; min-height: 100vh; width: 100%; // If navs are open, render a blurry background over content ::after { content: ''; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; backdrop-filter: blur(2px); background-color: color-mix(in srgb, var(--gray-1000) 5%, transparent); z-index: 50; visibility: hidden; opacity: 0; transition: opacity 0.3s ease; } @include mq.for-tablet { width: 100%; } } footer { margin-top: auto; }
{ "end_byte": 2466, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/app.component.scss" }
angular/adev/src/app/environment.ts_0_582
/*! * @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 */ export default { production: true, // Those values are publicly visible in the search request headers, and presents search-only keys. // https://www.algolia.com/doc/guides/security/api-keys/#search-only-api-key algolia: { appId: 'L1XWT2UJ7F', apiKey: 'dfca7ed184db27927a512e5c6668b968', indexName: 'angular_v17', }, googleAnalyticsId: 'G-XB6NEVW32B', };
{ "end_byte": 582, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/environment.ts" }
angular/adev/src/app/app.component.spec.ts_0_1205
/*! * @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 {TestBed} from '@angular/core/testing'; import {AppComponent} from './app.component'; import {provideRouter} from '@angular/router'; import {routes} from './routes'; import {Search, WINDOW} from '@angular/docs'; import {CURRENT_MAJOR_VERSION} from './core/providers/current-version'; describe('AppComponent', () => { const fakeSearch = {}; const fakeWindow = {location: {hostname: 'angular.dev'}}; const fakeCurrentMajorVersion = 19; it('should create the app', () => { TestBed.configureTestingModule({ providers: [ provideRouter(routes), { provide: WINDOW, useValue: fakeWindow, }, { provide: Search, useValue: fakeSearch, }, { provide: CURRENT_MAJOR_VERSION, useValue: fakeCurrentMajorVersion, }, ], }); const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; expect(app).toBeTruthy(); }); });
{ "end_byte": 1205, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/app.component.spec.ts" }
angular/adev/src/app/app.component.ts_0_3655
/*! * @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 {DOCUMENT, isPlatformBrowser} from '@angular/common'; import { ChangeDetectionStrategy, Component, inject, OnInit, PLATFORM_ID, signal, WritableSignal, } from '@angular/core'; import {NavigationEnd, NavigationSkipped, Router, RouterLink, RouterOutlet} from '@angular/router'; import {filter, map, skip} from 'rxjs/operators'; import { CookiePopup, getActivatedRouteSnapshotFromRouter, IS_SEARCH_DIALOG_OPEN, SearchDialog, TopLevelBannerComponent, } from '@angular/docs'; import {Footer} from './core/layout/footer/footer.component'; import {Navigation} from './core/layout/navigation/navigation.component'; import {SecondaryNavigation} from './core/layout/secondary-navigation/secondary-navigation.component'; import {ProgressBarComponent} from './core/layout/progress-bar/progress-bar.component'; import {ESCAPE, SEARCH_TRIGGER_KEY} from './core/constants/keys'; import {HeaderService} from './core/services/header.service'; @Component({ selector: 'adev-root', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [ CookiePopup, Navigation, Footer, SecondaryNavigation, RouterOutlet, SearchDialog, ProgressBarComponent, TopLevelBannerComponent, ], templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], host: { '(window:keydown)': 'setSearchDialogVisibilityOnKeyPress($event)', }, }) export class AppComponent implements OnInit { private readonly document = inject(DOCUMENT); private readonly router = inject(Router); private readonly headerService = inject(HeaderService); currentUrl = signal(''); displayFooter = signal(false); displaySecondaryNav = signal(false); displaySearchDialog: WritableSignal<boolean> = inject(IS_SEARCH_DIALOG_OPEN); isBrowser = isPlatformBrowser(inject(PLATFORM_ID)); ngOnInit(): void { this.closeSearchDialogOnNavigationSkipped(); this.router.events .pipe( filter((e): e is NavigationEnd => e instanceof NavigationEnd), map((event) => event.urlAfterRedirects), ) .subscribe((url) => { this.currentUrl.set(url); this.setComponentsVisibility(); this.displaySearchDialog.set(false); this.updateCanonicalLink(url); }); } focusFirstHeading(): void { if (!this.isBrowser) { return; } const h1 = this.document.querySelector<HTMLHeadingElement>('h1'); h1?.focus(); } private updateCanonicalLink(absoluteUrl: string) { this.headerService.setCanonical(absoluteUrl); } private setComponentsVisibility(): void { const activatedRoute = getActivatedRouteSnapshotFromRouter(this.router as any); this.displaySecondaryNav.set(activatedRoute.data['displaySecondaryNav']); this.displayFooter.set(!activatedRoute.data['hideFooter']); } private setSearchDialogVisibilityOnKeyPress(event: KeyboardEvent): void { if (event.key === SEARCH_TRIGGER_KEY && (event.metaKey || event.ctrlKey)) { event.preventDefault(); this.displaySearchDialog.update((display) => !display); } if (event.key === ESCAPE && this.displaySearchDialog()) { event.preventDefault(); this.displaySearchDialog.set(false); } } private closeSearchDialogOnNavigationSkipped(): void { this.router.events.pipe(filter((event) => event instanceof NavigationSkipped)).subscribe(() => { this.displaySearchDialog.set(false); }); } }
{ "end_byte": 3655, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/app.component.ts" }
angular/adev/src/app/app.config.ts_0_3553
/*! * @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 {DOCUMENT} from '@angular/common'; import {provideHttpClient, withFetch} from '@angular/common/http'; import { ApplicationConfig, ENVIRONMENT_INITIALIZER, ErrorHandler, VERSION, inject, provideExperimentalZonelessChangeDetection, } from '@angular/core'; import { DOCS_CONTENT_LOADER, ENVIRONMENT, EXAMPLE_VIEWER_CONTENT_LOADER, PREVIEWS_COMPONENTS, WINDOW, windowProvider, } from '@angular/docs'; import {provideClientHydration} from '@angular/platform-browser'; import {provideAnimationsAsync} from '@angular/platform-browser/animations/async'; import { RouteReuseStrategy, Router, TitleStrategy, createUrlTreeFromSnapshot, provideRouter, withComponentInputBinding, withInMemoryScrolling, withViewTransitions, } from '@angular/router'; import environment from './environment'; import {PREVIEWS_COMPONENTS_MAP} from './../assets/previews/previews'; import {ADevTitleStrategy} from './core/services/a-dev-title-strategy'; import {AnalyticsService} from './core/services/analytics/analytics.service'; import {ContentLoader} from './core/services/content-loader.service'; import {CustomErrorHandler} from './core/services/errors-handling/error-handler'; import {ExampleContentLoader} from './core/services/example-content-loader.service'; import {ReuseTutorialsRouteStrategy} from './features/tutorial/tutorials-route-reuse-strategy'; import {routes} from './routes'; import {CURRENT_MAJOR_VERSION} from './core/providers/current-version'; import {AppScroller} from './app-scroller'; export const appConfig: ApplicationConfig = { providers: [ provideRouter( routes, withInMemoryScrolling(), withViewTransitions({ onViewTransitionCreated: ({transition, to}) => { const router = inject(Router); const toTree = createUrlTreeFromSnapshot(to, []); // Skip the transition if the only thing changing is the fragment and queryParams if ( router.isActive(toTree, { paths: 'exact', matrixParams: 'exact', fragment: 'ignored', queryParams: 'ignored', }) ) { transition.skipTransition(); } }, }), withComponentInputBinding(), ), provideExperimentalZonelessChangeDetection(), provideClientHydration(), provideHttpClient(withFetch()), provideAnimationsAsync(), { provide: CURRENT_MAJOR_VERSION, useValue: Number(VERSION.major), }, {provide: ENVIRONMENT, useValue: environment}, { provide: ENVIRONMENT_INITIALIZER, multi: true, useValue: () => inject(AppScroller), }, { provide: ENVIRONMENT_INITIALIZER, multi: true, useValue: () => inject(AnalyticsService), }, {provide: ErrorHandler, useClass: CustomErrorHandler}, {provide: PREVIEWS_COMPONENTS, useValue: PREVIEWS_COMPONENTS_MAP}, {provide: DOCS_CONTENT_LOADER, useClass: ContentLoader}, {provide: EXAMPLE_VIEWER_CONTENT_LOADER, useClass: ExampleContentLoader}, { provide: RouteReuseStrategy, useClass: ReuseTutorialsRouteStrategy, }, { provide: WINDOW, useFactory: (document: Document) => windowProvider(document), deps: [DOCUMENT], }, {provide: TitleStrategy, useClass: ADevTitleStrategy}, ], };
{ "end_byte": 3553, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/app.config.ts" }
angular/adev/src/app/app-scroller.ts_0_2563
/*! * @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 {ViewportScroller} from '@angular/common'; import { Injectable, inject, ApplicationRef, afterNextRender, EnvironmentInjector, } from '@angular/core'; import {Scroll, Router} from '@angular/router'; import {filter, firstValueFrom, map, switchMap, tap} from 'rxjs'; @Injectable({providedIn: 'root'}) export class AppScroller { private readonly router = inject(Router); private readonly viewportScroller = inject(ViewportScroller); private readonly appRef = inject(ApplicationRef); private readonly injector = inject(EnvironmentInjector); disableScrolling = false; private _lastScrollEvent?: Scroll; private canScroll = false; private cancelScroll?: () => void; get lastScrollEvent(): Scroll | undefined { return this._lastScrollEvent; } constructor() { this.viewportScroller.setHistoryScrollRestoration('manual'); this.router.events .pipe( filter((e): e is Scroll => e instanceof Scroll), tap((e) => { this.cancelScroll?.(); this.canScroll = true; this._lastScrollEvent = e; }), filter(() => !this.disableScrolling), filter(() => { const info = this.router.lastSuccessfulNavigation?.extras.info as Record< 'disableScrolling', boolean >; return !info?.['disableScrolling']; }), switchMap((e) => { return firstValueFrom( this.appRef.isStable.pipe( filter((stable) => stable), map(() => e), ), ); }), ) .subscribe(() => { this.scroll(); }); } scroll() { if (!this._lastScrollEvent || !this.canScroll) { return; } // Prevent double scrolling on the same event this.canScroll = false; const {anchor, position} = this._lastScrollEvent; // Don't scroll during rendering const ref = afterNextRender( { write: () => { if (position) { this.viewportScroller.scrollToPosition(position); } else if (anchor) { this.viewportScroller.scrollToAnchor(anchor); } else { this.viewportScroller.scrollToPosition([0, 0]); } }, }, {injector: this.injector}, ); this.cancelScroll = () => { ref.destroy(); }; } }
{ "end_byte": 2563, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/app-scroller.ts" }
angular/adev/src/app/core/layout/footer/footer.component.ts_0_800
/*! * @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 {ChangeDetectionStrategy, Component} from '@angular/core'; import {ExternalLink} from '@angular/docs'; import {RouterLink} from '@angular/router'; import {GITHUB, X, MEDIUM, YOUTUBE} from './../../constants/links'; @Component({ selector: 'footer[adev-footer]', standalone: true, imports: [ExternalLink, RouterLink], templateUrl: './footer.component.html', styleUrls: ['./footer.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) export class Footer { readonly GITHUB = GITHUB; readonly X = X; readonly YOUTUBE = YOUTUBE; readonly MEDIUM = MEDIUM; }
{ "end_byte": 800, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/footer/footer.component.ts" }
angular/adev/src/app/core/layout/footer/footer.component.spec.ts_0_1012
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {WINDOW} from '@angular/docs'; import {RouterTestingModule} from '@angular/router/testing'; import {Footer} from './footer.component'; describe('Footer', () => { let component: Footer; let fixture: ComponentFixture<Footer>; const fakeWindow = { location: { origin: 'example-origin', }, }; beforeEach(() => { TestBed.configureTestingModule({ imports: [Footer, RouterTestingModule], providers: [ { provide: WINDOW, useValue: fakeWindow, }, ], }); fixture = TestBed.createComponent(Footer); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });
{ "end_byte": 1012, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/footer/footer.component.spec.ts" }
angular/adev/src/app/core/layout/footer/footer.component.scss_0_1269
.adev-footer-columns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2rem; @container footer (max-width: 600px) { grid-template-columns: repeat(2, 1fr) !important; } } .adev-footer-container { container: footer / inline-size; position: relative; justify-content: center; padding: var(--layout-padding); padding-inline-end: 1rem; background-color: var(--page-background); transition: background-color 0.3s ease; // this accounts for absolutely positioned TOC on the right @media only screen and (min-width: 1430px) { width: calc(100% - 195px - var(--layout-padding) * 3); } h2 { font-size: 0.875rem; font-weight: 600; margin-block-end: 1.75rem; letter-spacing: -0.00875rem; } ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.95rem; li { font-size: 0.8125rem; } } a { color: var(--quaternary-contrast); font-weight: 300; transition: color 0.3s ease; &:hover { color: var(--primary-contrast); } } p.docs-license { transition: color 0.3s ease; color: var(--quaternary-contrast); font-weight: 300; grid-column: span 4; font-size: 0.75rem; margin-block-start: 2rem; } }
{ "end_byte": 1269, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/footer/footer.component.scss" }
angular/adev/src/app/core/layout/footer/footer.component.html_0_3518
<div class="adev-footer-container"> <div class="adev-footer-columns"> <div> <h2>Social Media</h2> <ul> <li> <a [href]="MEDIUM" title="Angular blog">Blog</a> </li> <li> <a [href]="X" title="X (formerly Twitter)">X (formerly Twitter)</a> </li> <li> <a [href]="YOUTUBE" title="YouTube">YouTube</a> </li> <li> <a href="https://discord.gg/angular" title="Join the discussions at Angular Community Discord server." > Discord </a> </li> <li> <a [href]="GITHUB" title="GitHub">GitHub</a> </li> <li> <a href="https://stackoverflow.com/questions/tagged/angular" title="Stack Overflow: where the community answers your technical Angular questions." > Stack Overflow </a> </li> </ul> </div> <div> <h2>Community</h2> <ul> <li> <a href="https://github.com/angular/angular/blob/main/CONTRIBUTING.md" title="Contribute to Angular" > Contribute </a> </li> <li> <a href="https://github.com/angular/code-of-conduct/blob/main/CODE_OF_CONDUCT.md" title="Treating each other with respect." > Code of Conduct </a> </li> <li> <a href="https://github.com/angular/angular/issues" title="Post issues and suggestions on github." > Report Issues </a> </li> <li> <a href="https://devlibrary.withgoogle.com/products/angular?sort=updated" title="Google's DevLibrary" > Google's DevLibrary </a> </li> <li> <a href="https://developers.google.com/community/experts/directory?specialization=angular" title="Angular Google Developer Experts" > Angular Google Developer Experts </a> </li> </ul> </div> <div> <h2>Resources</h2> <ul> <li> <a routerLink="/press-kit" title="Press contacts, logos, and branding.">Press Kit</a> </li> <li> <a routerLink="/roadmap" title="Roadmap">Roadmap</a> </li> </ul> </div> <div> <h2>Languages</h2> <ul> <li> <a href="https://angular.cn/" title="简体中文版">简体中文版</a> </li> <li> <a href="https://angular.tw/" title="正體中文版">正體中文版</a> </li> <li> <a href="https://angular.jp/" title="日本語版">日本語版</a> </li> <li> <a href="https://angular.kr/" title="한국어">한국어</a> </li> <li> <a href="https://angular-gr.web.app" title="&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;ά" > &Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;ά </a> </li> </ul> </div> </div> <p class="docs-license"> Super-powered by Google ©2010-2024. Code licensed under an <a routerLink="/license" title="License text">MIT-style License</a> . Documentation licensed under <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a> . </p> </div>
{ "end_byte": 3518, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/footer/footer.component.html" }
angular/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.ts_0_7615
/*! * @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 { ChangeDetectionStrategy, Component, DestroyRef, OnInit, PLATFORM_ID, computed, inject, signal, } from '@angular/core'; import {takeUntilDestroyed, toObservable} from '@angular/core/rxjs-interop'; import { ClickOutside, NavigationItem, NavigationList, NavigationState, WINDOW, findNavigationItem, getBaseUrlAfterRedirects, getNavigationItemsTree, markExternalLinks, shouldReduceMotion, } from '@angular/docs'; import {distinctUntilChanged, filter, map, skip, startWith} from 'rxjs/operators'; import {SUB_NAVIGATION_DATA} from '../../../sub-navigation-data'; import {PagePrefix} from '../../enums/pages'; import {ActivatedRouteSnapshot, NavigationEnd, Router, RouterStateSnapshot} from '@angular/router'; import {isPlatformBrowser} from '@angular/common'; import {trigger, transition, style, animate} from '@angular/animations'; import {PRIMARY_NAV_ID, SECONDARY_NAV_ID} from '../../constants/element-ids'; export const ANIMATION_DURATION = 500; @Component({ selector: 'adev-secondary-navigation', standalone: true, imports: [NavigationList, ClickOutside], templateUrl: './secondary-navigation.component.html', styleUrls: ['./secondary-navigation.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, animations: [ trigger('leaveAnimation', [ transition(':leave', [ style({transform: 'translateX(0%)'}), animate( `${ANIMATION_DURATION}ms ${ANIMATION_DURATION}ms ease-out`, style({transform: 'translateX(100%)'}), ), ]), ]), ], }) export class SecondaryNavigation implements OnInit { private readonly destroyRef = inject(DestroyRef); private readonly navigationState = inject(NavigationState); private readonly platformId = inject(PLATFORM_ID); private readonly router = inject(Router); private readonly window = inject(WINDOW); readonly isSecondaryNavVisible = this.navigationState.isMobileNavVisible; readonly primaryActiveRouteItem = this.navigationState.primaryActiveRouteItem; readonly maxVisibleLevelsOnSecondaryNav = computed(() => this.primaryActiveRouteItem() === PagePrefix.REFERENCE ? 1 : 2, ); readonly navigationItemsSlides = this.navigationState.expandedItems; navigationItems: NavigationItem[] | undefined; translateX = computed(() => { const level = this.navigationState.expandedItems()?.length ?? 0; return `translateX(${-level * 100}%)`; }); transition = signal('0ms'); readonly PRIMARY_NAV_ID = PRIMARY_NAV_ID; readonly SECONDARY_NAV_ID = SECONDARY_NAV_ID; private readonly routeMap: Record<string, NavigationItem[]> = { [PagePrefix.REFERENCE]: getNavigationItemsTree(SUB_NAVIGATION_DATA.reference, (tree) => markExternalLinks(tree, this.window.origin), ), [PagePrefix.DOCS]: getNavigationItemsTree(SUB_NAVIGATION_DATA.docs, (tree) => markExternalLinks(tree, this.window.origin), ), }; private readonly primaryActiveRouteChanged$ = toObservable(this.primaryActiveRouteItem).pipe( distinctUntilChanged(), takeUntilDestroyed(this.destroyRef), ); private readonly urlAfterRedirects$ = this.router.events.pipe( filter((event) => event instanceof NavigationEnd), map((event) => (event as NavigationEnd).urlAfterRedirects), filter((url): url is string => url !== undefined), startWith(this.getInitialPath(this.router.routerState.snapshot)), takeUntilDestroyed(this.destroyRef), ); ngOnInit(): void { this.navigationState.cleanExpandedState(); this.listenToPrimaryRouteChange(); this.setActiveRouteOnNavigationEnd(); if (isPlatformBrowser(this.platformId)) { this.initSlideAnimation(); } } close(): void { this.navigationState.setMobileNavigationListVisibility(false); } private setActiveRouteOnNavigationEnd(): void { this.urlAfterRedirects$.subscribe((url) => { const activeNavigationItem = this.getActiveNavigationItem(url); if ( activeNavigationItem?.level && activeNavigationItem.level <= this.maxVisibleLevelsOnSecondaryNav() ) { this.navigationState.cleanExpandedState(); } else if (activeNavigationItem) { /** * For the `Docs`, we don't expand the "level === 1" items because they are already displayed in the main navigation list. * Example: * In-depth Guides (level == 0) * Components (level == 1) -> Selectors, Styling, etc (level == 2) * Template Syntax (level == 1) -> Text interpolation, etc (level == 2) * * For the `Tutorials`, we display the navigation in the dropdown and it has flat structure (all items are displayed as items with level === 0). * * For the `Reference` we would like to give possibility to expand the "level === 1" items cause they are not visible in the first slide of navigation list. * Example: * API Reference (level == 0) -> Overview, Animations, common, etc (level == 1) -> API Package exports (level == 2) */ const shouldExpandItem = (node: NavigationItem): boolean => !!node.level && (this.primaryActiveRouteItem() === PagePrefix.REFERENCE ? node.level > 0 : node.level > 1); // Skip expand when active item is API Reference homepage - `/api`. // It protect us from displaying second level of the navigation when user clicks on `Reference`, // Because in this situation we want to display the first level, which contains, in addition to the API Reference, also the CLI Reference, Error Encyclopedia etc. const skipExpandPredicateFn = (node: NavigationItem): boolean => node.path === PagePrefix.API; this.navigationState.expandItemHierarchy( activeNavigationItem, shouldExpandItem, skipExpandPredicateFn, ); } }); } private getActiveNavigationItem(url: string): NavigationItem | null { // set visible navigation items if not present this.setVisibleNavigationItems(); const activeNavigationItem = findNavigationItem( this.navigationItems!, (item) => !!item.path && getBaseUrlAfterRedirects(item.path, this.router) === getBaseUrlAfterRedirects(url, this.router), ); this.navigationState.setActiveNavigationItem(activeNavigationItem); return activeNavigationItem; } private initSlideAnimation(): void { if (shouldReduceMotion()) { return; } setTimeout(() => { this.transition.set(`${ANIMATION_DURATION}ms`); }, ANIMATION_DURATION); } private setVisibleNavigationItems(): void { const routeMap = this.routeMap[this.primaryActiveRouteItem()!]; this.navigationItems = routeMap ? getNavigationItemsTree(routeMap, (item) => { item.isExpanded = this.primaryActiveRouteItem() === PagePrefix.DOCS && item.level === 1; }) : []; } private listenToPrimaryRouteChange(): void { // Fix: flicker of sub-navigation on init this.primaryActiveRouteChanged$.pipe(skip(1)).subscribe(() => { this.navigationState.cleanExpandedState(); }); } private getInitialPath(routerState: RouterStateSnapshot): string { let route: ActivatedRouteSnapshot = routerState.root; while (route.firstChild) { route = route.firstChild; } return route.routeConfig?.path ?? ''; } }
{ "end_byte": 7615, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.ts" }
angular/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.spec.ts_0_1023
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {SecondaryNavigation} from './secondary-navigation.component'; import {WINDOW} from '@angular/docs'; describe('SecondaryNavigation', () => { let component: SecondaryNavigation; let fixture: ComponentFixture<SecondaryNavigation>; const fakeWindow = { location: { origin: 'example-origin', }, }; beforeEach(() => { TestBed.configureTestingModule({ imports: [SecondaryNavigation], providers: [ { provide: WINDOW, useValue: fakeWindow, }, ], }); fixture = TestBed.createComponent(SecondaryNavigation); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });
{ "end_byte": 1023, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.spec.ts" }
angular/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.html_0_1168
<div [attr.id]="SECONDARY_NAV_ID" class="adev-secondary-nav-mask" [class.docs-nav-secondary--open]="isSecondaryNavVisible()" (docsClickOutside)="close()" [docsClickOutsideIgnore]="[PRIMARY_NAV_ID]"> <div class="docs-nav-secondary docs-scroll-track-transparent" [style.transform]="translateX()" [style.transition]="transition()"> <!-- Secondary Nav --> @if (navigationItems && navigationItems.length > 0) { <docs-navigation-list [navigationItems]="navigationItems" [displayItemsToLevel]="maxVisibleLevelsOnSecondaryNav()" [expandableLevel]="maxVisibleLevelsOnSecondaryNav()" (linkClicked)="close()" /> } <!-- Third, fourth and next levels of navigation --> @for (item of navigationItemsSlides(); track item; let level = $index) { <docs-navigation-list [@leaveAnimation] [collapsableLevel]="level + maxVisibleLevelsOnSecondaryNav()" [expandableLevel]="level + maxVisibleLevelsOnSecondaryNav() + 1" [navigationItems]="[item]" [displayItemsToLevel]="level + maxVisibleLevelsOnSecondaryNav() + 1" (linkClicked)="close()" /> } </div> </div>
{ "end_byte": 1168, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.html" }
angular/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.scss_0_1654
@use '@angular/docs/styles/media-queries' as mq; :host { z-index: 100; @include mq.for-tablet-landscape-up { position: sticky; top: 0; } @include mq.for-tablet-landscape-down { position: fixed; } @include mq.for-phone-only { transform: translateX(0); transition: transform 0.3s ease; &:has(.docs-nav-secondary--open) { transform: translateX(82px); transition: transform 0.3s ease-in 0.3s; } } } // .adev-secondary-nav-mask stays in the same place during nav animation, as a mask .adev-secondary-nav-mask { position: sticky; @include mq.for-tablet-landscape-down { position: absolute; } top: 0; overflow-x: hidden; min-width: var(--secondary-nav-width); border-inline-end: 1px solid var(--septenary-contrast); background-color: var(--page-background); z-index: var(--z-index-nav); transition: transform 0.45s ease; @media (prefers-reduced-motion: no-preference) { transition: transform 0.45s ease, background-color 0.3s ease, border-color 0.3s ease; } @include mq.for-tablet-landscape-down { transform: translateX(-100%); &.docs-nav-secondary--open { transform: translateX(0); } } @include mq.for-phone-only { transform: translateX(-100%); // exit immediately transition: transform 0.45s ease-in; &.docs-nav-secondary--open { transform: translateX(0); // enter delayed transition: transform 0.45s ease-out 0.2s; } } } // secondary nav - translated on x to display levels .docs-nav-secondary { display: flex; flex-direction: row; max-width: var(--secondary-nav-width); }
{ "end_byte": 1654, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/secondary-navigation/secondary-navigation.component.scss" }
angular/adev/src/app/core/layout/progress-bar/progress-bar.component.spec.ts_0_1261
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {PROGRESS_BAR_DELAY, ProgressBarComponent} from './progress-bar.component'; import {RouterTestingHarness, RouterTestingModule} from '@angular/router/testing'; describe('ProgressBarComponent', () => { let component: ProgressBarComponent; let fixture: ComponentFixture<ProgressBarComponent>; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [ProgressBarComponent, RouterTestingModule], }).compileComponents(); fixture = TestBed.createComponent(ProgressBarComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should call progressBar.complete() on route change', async () => { const progressBarCompleteSpy = spyOn(component.progressBar, 'complete'); const harness = await RouterTestingHarness.create(); await harness.navigateByUrl('/'); await new Promise((resolve) => setTimeout(resolve, PROGRESS_BAR_DELAY)); expect(progressBarCompleteSpy).toHaveBeenCalled(); }); });
{ "end_byte": 1261, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/progress-bar/progress-bar.component.spec.ts" }
angular/adev/src/app/core/layout/progress-bar/progress-bar.component.ts_0_2592
/*! * @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 { ChangeDetectionStrategy, Component, inject, OnInit, PLATFORM_ID, ViewChild, } from '@angular/core'; import {isPlatformBrowser} from '@angular/common'; import {NgProgressbar} from 'ngx-progressbar'; import { NavigationCancel, NavigationEnd, NavigationError, NavigationSkipped, NavigationStart, Router, } from '@angular/router'; import {filter, map, switchMap, take} from 'rxjs/operators'; /** Time to wait after navigation starts before showing the progress bar. This delay allows a small amount of time to skip showing the progress bar when a navigation is effectively immediate. 30ms is approximately the amount of time we can wait before a delay is perceptible.*/ export const PROGRESS_BAR_DELAY = 30; @Component({ selector: 'adev-progress-bar', standalone: true, imports: [NgProgressbar], template: ` <ng-progress aria-label="Page load progress" /> `, changeDetection: ChangeDetectionStrategy.OnPush, }) export class ProgressBarComponent implements OnInit { private readonly router = inject(Router); @ViewChild(NgProgressbar, {static: true}) progressBar!: NgProgressbar; isBrowser = isPlatformBrowser(inject(PLATFORM_ID)); ngOnInit() { this.setupPageNavigationDimming(); } /** * Dims the main router-outlet content when navigating to a new page. */ private setupPageNavigationDimming() { if (!this.isBrowser) { return; } this.router.events .pipe( filter((e) => e instanceof NavigationStart), map(() => { // Only apply set the property if the navigation is not "immediate" return setTimeout(() => { this.progressBar.start(); }, PROGRESS_BAR_DELAY); }), switchMap((timeoutId) => { return this.router.events.pipe( filter((e) => { return ( e instanceof NavigationEnd || e instanceof NavigationCancel || e instanceof NavigationSkipped || e instanceof NavigationError ); }), take(1), map(() => timeoutId), ); }), ) .subscribe((timeoutId) => { // When the navigation finishes, prevent the navigating class from being applied in the timeout. clearTimeout(timeoutId); this.progressBar.complete(); }); } }
{ "end_byte": 2592, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/progress-bar/progress-bar.component.ts" }
angular/adev/src/app/core/layout/navigation/navigation.component.ts_0_8153
/*! * @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 {CdkMenu, CdkMenuItem, CdkMenuTrigger} from '@angular/cdk/menu'; import {DOCUMENT, Location, isPlatformBrowser} from '@angular/common'; import { ChangeDetectionStrategy, Component, DestroyRef, OnInit, PLATFORM_ID, inject, } from '@angular/core'; import {takeUntilDestroyed, toObservable} from '@angular/core/rxjs-interop'; import { ClickOutside, NavigationState, WINDOW, IconComponent, getBaseUrlAfterRedirects, isApple, IS_SEARCH_DIALOG_OPEN, } from '@angular/docs'; import {NavigationEnd, Router, RouterLink} from '@angular/router'; import {filter, map, startWith} from 'rxjs/operators'; import {DOCS_ROUTES, REFERENCE_ROUTES, TUTORIALS_ROUTES} from '../../../routes'; import {GITHUB, MEDIUM, X, YOUTUBE, DISCORD} from '../../constants/links'; import {PagePrefix} from '../../enums/pages'; import {Theme, ThemeManager} from '../../services/theme-manager.service'; import {VersionManager} from '../../services/version-manager.service'; import {PRIMARY_NAV_ID, SECONDARY_NAV_ID} from '../../constants/element-ids'; import {ConnectionPositionPair} from '@angular/cdk/overlay'; import {COMMAND, CONTROL, SEARCH_TRIGGER_KEY} from '../../constants/keys'; type MenuType = 'social' | 'theme-picker' | 'version-picker'; @Component({ selector: 'div.adev-nav', standalone: true, imports: [RouterLink, ClickOutside, CdkMenu, CdkMenuItem, CdkMenuTrigger, IconComponent], templateUrl: './navigation.component.html', styleUrls: ['./navigation.component.scss', './mini-menu.scss', './nav-item.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) export class Navigation implements OnInit { private readonly destroyRef = inject(DestroyRef); private readonly document = inject(DOCUMENT); private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID)); private readonly navigationState = inject(NavigationState); private readonly router = inject(Router); private readonly location = inject(Location); private readonly themeManager = inject(ThemeManager); private readonly isSearchDialogOpen = inject(IS_SEARCH_DIALOG_OPEN); private readonly window = inject(WINDOW); private readonly versionManager = inject(VersionManager); readonly DOCS_ROUTE = PagePrefix.DOCS; readonly HOME_ROUTE = PagePrefix.HOME; readonly PLAYGROUND_ROUTE = PagePrefix.PLAYGROUND; readonly REFERENCE_ROUTE = PagePrefix.REFERENCE; readonly TUTORIALS_ROUTE = PagePrefix.TUTORIALS; readonly GITHUB = GITHUB; readonly X = X; readonly MEDIUM = MEDIUM; readonly YOUTUBE = YOUTUBE; readonly DISCORD = DISCORD; readonly PRIMARY_NAV_ID = PRIMARY_NAV_ID; readonly SECONDARY_NAV_ID = SECONDARY_NAV_ID; // We can't use the ActivatedRouter queryParams as we're outside the router outlet readonly isUwu = 'location' in globalThis ? location.search.includes('uwu') : false; miniMenuPositions = [ new ConnectionPositionPair( {originX: 'end', originY: 'center'}, {overlayX: 'start', overlayY: 'center'}, ), new ConnectionPositionPair( {originX: 'end', originY: 'top'}, {overlayX: 'start', overlayY: 'top'}, ), ]; readonly APPLE_SEARCH_LABEL = `⌘`; readonly DEFAULT_SEARCH_LABEL = `ctrl`; activeRouteItem = this.navigationState.primaryActiveRouteItem; theme = this.themeManager.theme; openedMenu: MenuType | null = null; currentDocsVersion = this.versionManager.currentDocsVersion; currentDocsVersionMode = this.versionManager.currentDocsVersion()?.version; // Set the values of the search label and title only on the client, because the label is user-agent specific. searchLabel = this.isBrowser ? isApple ? this.APPLE_SEARCH_LABEL : this.DEFAULT_SEARCH_LABEL : ''; searchTitle = this.isBrowser ? isApple ? `${COMMAND} ${SEARCH_TRIGGER_KEY.toUpperCase()}` : `${CONTROL} ${SEARCH_TRIGGER_KEY.toUpperCase()}` : ''; versions = this.versionManager.versions; isMobileNavigationOpened = this.navigationState.isMobileNavVisible; isMobileNavigationOpened$ = toObservable(this.isMobileNavigationOpened); primaryRouteChanged$ = toObservable(this.activeRouteItem); ngOnInit(): void { this.listenToRouteChange(); this.preventToScrollContentWhenSecondaryNavIsOpened(); this.closeMobileNavOnPrimaryRouteChange(); } setTheme(theme: Theme): void { this.themeManager.setTheme(theme); } openVersionMenu($event: MouseEvent): void { // It's required to avoid redirection to `home` $event.stopImmediatePropagation(); $event.preventDefault(); this.openMenu('version-picker'); } openMenu(menuType: MenuType): void { this.openedMenu = menuType; } closeMenu(): void { this.openedMenu = null; } openMobileNav($event: MouseEvent): void { $event.stopPropagation(); this.navigationState.setMobileNavigationListVisibility(true); } closeMobileNav(): void { this.navigationState.setMobileNavigationListVisibility(false); } toggleSearchDialog(event: MouseEvent): void { event.stopPropagation(); this.isSearchDialogOpen.update((isOpen) => !isOpen); } private closeMobileNavOnPrimaryRouteChange(): void { this.primaryRouteChanged$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => { this.closeMobileNav(); }); } private listenToRouteChange(): void { this.router.events .pipe( filter((event) => event instanceof NavigationEnd), map((event) => (event as NavigationEnd).urlAfterRedirects), ) .pipe( takeUntilDestroyed(this.destroyRef), //using location because router.url will only return "/" here startWith(this.location.path()), ) .subscribe((url) => { this.setActivePrimaryRoute(getBaseUrlAfterRedirects(url, this.router)); }); } // Set active route item, based on urlAfterRedirects. // First check if url starts with the main prefixes (docs, reference, tutorials). // (*) Docs navigation tree contains items which will navigate to /tutorials. // In that case after click on such link we should mark as active item, and display tutorials navigation tree. // If it's not starting with prefix then check if specific path exist in the array of defined routes // (*) Reference navigation tree contains items which are not start with prefix like /migrations or /errors. private setActivePrimaryRoute(urlAfterRedirects: string): void { if (urlAfterRedirects === '') { this.activeRouteItem.set(PagePrefix.HOME); } else if (urlAfterRedirects.startsWith(PagePrefix.DOCS)) { this.activeRouteItem.set(PagePrefix.DOCS); } else if ( urlAfterRedirects.startsWith(PagePrefix.REFERENCE) || urlAfterRedirects.startsWith(PagePrefix.API) || urlAfterRedirects.startsWith(PagePrefix.UPDATE) ) { this.activeRouteItem.set(PagePrefix.REFERENCE); } else if (urlAfterRedirects === PagePrefix.PLAYGROUND) { this.activeRouteItem.set(PagePrefix.PLAYGROUND); } else if (urlAfterRedirects.startsWith(PagePrefix.TUTORIALS)) { this.activeRouteItem.set(PagePrefix.TUTORIALS); } else if (DOCS_ROUTES.some((route) => route.path === urlAfterRedirects)) { this.activeRouteItem.set(PagePrefix.DOCS); } else if (REFERENCE_ROUTES.some((route) => route.path === urlAfterRedirects)) { this.activeRouteItem.set(PagePrefix.REFERENCE); } else if (TUTORIALS_ROUTES.some((route) => route.path === urlAfterRedirects)) { this.activeRouteItem.set(PagePrefix.TUTORIALS); } else { // Reset if no active route item could be found this.activeRouteItem.set(null); } } private preventToScrollContentWhenSecondaryNavIsOpened(): void { this.isMobileNavigationOpened$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((opened) => { if (opened) { this.document.body.style.overflowY = 'hidden'; } else { this.document.body.style.removeProperty('overflow-y'); } }); } }
{ "end_byte": 8153, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.ts" }
angular/adev/src/app/core/layout/navigation/nav-item.scss_0_2137
@use '@angular/docs/styles/media-queries' as mq; .adev-nav-item { color: var(--quaternary-contrast); position: relative; width: 6.875rem; @include mq.for-phone-only { width: 5.05rem; } @include mq.for-tablet { display: flex; align-items: center; justify-content: center; width: auto; } &::before { content: ''; position: absolute; bottom: 0; top: 0; left: 0; width: 2px; @include mq.for-tablet { width: auto; top: auto; right: 0; height: 2px; } // TODO: Make this gradient if the page is currently active, and black if child page active background-color: var(--primary-contrast); opacity: 0; transform: scale(0.9); transform-origin: center; transition: opacity 0.3s ease, transform 0.3s ease; } &:not(.adev-nav-item--logo) { @include mq.for-tablet { a, .adev-nav-button { gap: 0.25rem; } } } .adev-nav-button { width: 100%; font-weight: 500; } a, .adev-nav-button { display: flex; flex-direction: column; @include mq.for-tablet { flex-direction: row; } justify-content: center; align-items: center; gap: 0.75rem; padding-block: 1.25rem; text-decoration: none; fill: var(--quaternary-contrast); color: inherit; cursor: pointer; transition: fill 0.3s ease; } &__label { margin: 0; font-size: 0.813; // 13px color: inherit; abbr { font-size: 0.688; // 11px } } i { color: var(--quaternary-contrast); transition: color 0.3s ease; } span, abbr { transition: color 0.3s ease; } &:hover { a, .adev-nav-button { fill: var(--primary-contrast); } span, abbr { color: var(--primary-contrast); } i { color: var(--primary-contrast); } } &--active { &::before { opacity: 1; transform: scaleY(1); } &:not(.adev-nav-item--logo) { path { fill: var(--primary-contrast); } } span, abbr, i { color: var(--primary-contrast); } } }
{ "end_byte": 2137, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/nav-item.scss" }
angular/adev/src/app/core/layout/navigation/navigation.component.spec.ts_0_3154
/*! * @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 {ComponentFixture, TestBed} from '@angular/core/testing'; import {Navigation} from './navigation.component'; import {RouterTestingModule} from '@angular/router/testing'; import {By} from '@angular/platform-browser'; import {PagePrefix} from '../../enums/pages'; import {Theme, ThemeManager} from '../../services/theme-manager.service'; import {Version, signal} from '@angular/core'; import {of} from 'rxjs'; import {VersionManager} from '../../services/version-manager.service'; import {Search, WINDOW} from '@angular/docs'; describe('Navigation', () => { let component: Navigation; let fixture: ComponentFixture<Navigation>; const fakeThemeManager = { theme: signal<Theme>('dark'), setTheme: (theme: Theme) => {}, themeChanged$: of(), }; const fakeVersionManager = { currentDocsVersion: signal('v17'), versions: signal<Version[]>([]), }; const fakeWindow = {}; const fakeSearch = {}; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [Navigation, RouterTestingModule], providers: [ { provide: WINDOW, useValue: fakeWindow, }, { provide: Search, useValue: fakeSearch, }, ], }).compileComponents(); TestBed.overrideProvider(ThemeManager, {useValue: fakeThemeManager}); TestBed.overrideProvider(VersionManager, {useValue: fakeVersionManager}); fixture = TestBed.createComponent(Navigation); component = fixture.componentInstance; fixture.detectChanges(); }); it('should append active class to DOCS_ROUTE when DOCS_ROUTE is active', () => { component.activeRouteItem.set(PagePrefix.DOCS); fixture.detectChanges(); const docsLink = fixture.debugElement.query(By.css('a[href="/docs"]')).parent?.nativeElement; expect(docsLink).toHaveClass('adev-nav-item--active'); }); it('should not have active class when activeRouteItem is null', () => { component.activeRouteItem.set(null); fixture.detectChanges(); const docsLink = fixture.debugElement.query(By.css('a[href="/docs"]')).nativeElement; const referenceLink = fixture.debugElement.query(By.css('a[href="/reference"]')).nativeElement; expect(docsLink).not.toHaveClass('adev-nav-item--active'); expect(referenceLink).not.toHaveClass('adev-nav-item--active'); }); it('should call themeManager.setTheme(dark) when user tries to set dark theme', () => { const openThemePickerButton = fixture.debugElement.query( By.css('button[aria-label^="Open theme picker"]'), ).nativeElement; const setThemeSpy = spyOn(fakeThemeManager, 'setTheme'); openThemePickerButton.click(); fixture.detectChanges(); const setDarkModeButton = fixture.debugElement.query( By.css('button[aria-label="Set dark theme"]'), ).nativeElement; setDarkModeButton.click(); expect(setThemeSpy).toHaveBeenCalledOnceWith('dark'); }); });
{ "end_byte": 3154, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.spec.ts" }
angular/adev/src/app/core/layout/navigation/navigation.component.scss_0_6722
@use '@angular/docs/styles/media-queries' as mq; // primary nav :host { display: flex; position: sticky; top: 0; z-index: var(--z-index-nav); .adev-mobile-nav-button { display: flex; align-items: center; gap: 0.75rem; } // render tablet primary nav under blur when secondary is open @include mq.for-tablet { &:has(.adev-nav-primary--open) { z-index: 50; } } } .adev-mobile-nav-bar { display: none; @include mq.for-phone-only { display: flex; } gap: 0.75rem; backdrop-filter: blur(16px); background-color: color-mix(in srgb, var(--page-background) 70%, transparent); position: relative; width: 100vw; padding-block: 0.75rem; padding-inline: var(--layout-padding); border-block-end: 1px solid var(--septenary-contrast); box-sizing: border-box; transform: translateY(0); // mobile bar: enter with delay transition: transform 0.3s ease-out 0.6s; &:has(+ .adev-nav-primary--open) { transform: translateY(-100%); // mobile bar: exit without delay transition: transform 0.3s ease-in; } docs-icon { color: var(--primary-contrast); } } // First level navigation .adev-nav-primary { display: flex; flex-direction: column; justify-content: space-between; max-height: 100vh; overflow: auto; backdrop-filter: blur(16px); background-color: color-mix(in srgb, var(--page-background) 70%, transparent); // render primary nav / mini menu above tablet secondary bar z-index: 250; position: relative; transition: background-color 0.3s ease, border-color 0.3s ease; height: 100dvh; padding-block-start: 1rem; padding-block-end: 2rem; box-sizing: border-box; &.adev-nav-primary--next, &.adev-nav-primary--rc { // change nav background to indicate this is the rc docs background: linear-gradient( 140deg, color-mix(in srgb, var(--orange-red), transparent 60%) 0%, color-mix(in srgb, var(--vivid-pink), transparent 40%) 15%, color-mix(in srgb, var(--electric-violet), transparent 70%) 25%, color-mix(in srgb, var(--bright-blue), transparent 60%) 90%, ); } &.adev-nav-primary--deprecated { // change nav background to indicate this is an outdated version of the docs background-color: color-mix(in srgb, var(--symbolic-gray), transparent 30%); } // div containing mobile close button and adev-nav_top > div { display: flex; flex-direction: column; align-items: center; justify-content: center; } @include mq.for-phone-only { position: absolute; top: 0; background-color: var(--page-background); box-shadow: 10px 4px 3px 0 rgba(0, 0, 0, 0.001); transform: translateX(-100%); // primary nav: exit delayed // TODO: should only be delayed if there is a secondary nav transition: transform 0.3s ease-in 0.38s; &.adev-nav-primary--open { transform: translateX(0%); // primary nav: enter after mobile nav bar exits transition: transform 0.3s ease-out 0.1s; } @media (prefers-reduced-motion: reduce-motion) { transition: none; } } @include mq.for-tablet { flex-direction: row; width: 100vw; padding-inline: calc(var(--layout-padding) - 1.25rem); height: auto; padding-block: 0; } // Add a subtle border for the home page border-block-end: 1px solid var(--septenary-contrast); @include mq.for-tablet-up { border-inline-end: 1px solid var(--septenary-contrast); } @include mq.for-phone-only { border-inline-end: 1px solid var(--septenary-contrast); } } .adev-nav { &__top { padding: 0; margin: 0; list-style: none; display: flex; flex-direction: column; @include mq.for-tablet { flex-direction: row; } // version dropdown button .adev-version-button { border: 1px solid var(--senary-contrast); border-radius: 0.25rem; width: fit-content; margin: 0 auto; display: flex; justify-content: space-between; gap: 0.25rem; color: var(--quaternary-contrast); fill: var(--quaternary-contrast); transition: color 0.3s ease; font-size: 0.8rem; font-weight: 500; &:hover { color: var(--primary-contrast); } docs-icon { font-size: inherit; line-height: inherit; transition: transform 0.2s ease; } @include mq.for-phone-only { &.adev-mini-menu-open { &::after { transform: rotate(-90deg); } } } @include mq.for-tablet-landscape-up { &.adev-mini-menu-open { &::after { transform: rotate(-90deg); } } } } @include mq.for-tablet { > li:first-of-type { padding-inline-start: 1.25rem; } li { padding-inline: 1rem; } } } &__bottom { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; @include mq.for-tablet { flex-direction: row; margin-inline-end: 1.25rem; } .adev-nav-item--active { button { docs-icon { color: var(--primary-contrast); } } } button { border: none; background-color: transparent; cursor: pointer; width: 100%; padding-inline: 1rem; @include mq.for-tablet { padding-inline: 0.5rem; } docs-icon { color: var(--quaternary-contrast); font-size: 1.5rem; @include mq.for-tablet-landscape-down { font-size: 1.25rem; } } &:hover { docs-icon { color: var(--primary-contrast); } } } } } .adev-nav-item--logo a { height: 34px; } .adev-close-nav { display: none; @include mq.for-phone-only { display: block; } color: var(--primary-contrast); } .adev-search-desktop { height: 1.375rem; text-transform: capitalize; @include mq.for-tablet-landscape-down { display: none; } } .adev-sub-navigation-hidden { display: none; } .adev-secondary-tablet-bar { font-size: 0.875rem; backdrop-filter: blur(16px); background-color: color-mix(in srgb, var(--page-background) 70%, transparent); border-block-end: 1px solid var(--septenary-contrast); padding-block: 1rem; padding-inline: var(--layout-padding); transition: background-color 0.3s ease, border-color 0.3s ease; button { display: flex; gap: 0.5rem; align-items: center; color: var(--primary-contrast); padding: 0; font-weight: 500; } @include mq.for-tablet-landscape-up { display: none; } @include mq.for-phone-only { display: none; } }
{ "end_byte": 6722, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.scss" }
angular/adev/src/app/core/layout/navigation/navigation.component.html_0_2217
<!-- Primary Nav --> <div [attr.id]="PRIMARY_NAV_ID" (docsClickOutside)="closeMobileNav()" [docsClickOutsideIgnore]="[SECONDARY_NAV_ID]" > <!-- Mobile nav bar --> <div class="adev-mobile-nav-bar"> <!-- Logo icon --> <button type="button" class="adev-mobile-nav-button" aria-label="Toggle mobile navigation" (click)="openMobileNav($event)" > <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 223 236" width="32"> <g clip-path="url(#2a)"> <path fill="url(#2b)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z" /> <path fill="url(#2c)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z" /> </g> <defs> <linearGradient id="2b" x1="49.009" x2="225.829" y1="213.75" y2="129.722" gradientUnits="userSpaceOnUse" > <stop stop-color="#E40035" /> <stop offset=".24" stop-color="#F60A48" /> <stop offset=".352" stop-color="#F20755" /> <stop offset=".494" stop-color="#DC087D" /> <stop offset=".745" stop-color="#9717E7" /> <stop offset="1" stop-color="#6C00F5" /> </linearGradient> <linearGradient id="2c" x1="41.025" x2="156.741" y1="28.344" y2="160.344" gradientUnits="userSpaceOnUse" > <stop stop-color="#FF31D9" /> <stop offset="1" stop-color="#FF5BE1" stop-opacity="0" /> </linearGradient> <clipPath id="2a"><path fill="#fff" d="M0 0h223v236H0z" /></clipPath> </defs> </svg> <docs-icon role="presentation">menu</docs-icon> </button> </div>
{ "end_byte": 2217, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.html" }
angular/adev/src/app/core/layout/navigation/navigation.component.html_2221_8094
<nav class="adev-nav-primary docs-scroll-hide" [class.adev-nav-primary--open]="isMobileNavigationOpened()" [class.adev-nav-primary--rc]="currentDocsVersionMode === 'rc'" [class.adev-nav-primary--next]="currentDocsVersionMode === 'next'" [class.adev-nav-primary--deprecated]="currentDocsVersionMode === 'deprecated'" > <button type="button" class="adev-close-nav" (click)="closeMobileNav()" aria-label="Close navigation" > <docs-icon role="presentation">close</docs-icon> </button> <!-- Top section of primary nav --> <ul class="adev-nav__top"> <!-- Home / Angular logo --> <li class="adev-nav-item adev-nav-item--logo" [class.adev-nav-item--active]="activeRouteItem() === HOME_ROUTE" > <a aria-label="Angular homepage" routerLink="/"> <!-- Logo Symbol --> @if(!isUwu) { <svg class="angular-logo" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 223 236" width="32"> <g clip-path="url(#a)"> <path fill="url(#b)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z" /> <path fill="url(#c)" d="m222.077 39.192-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z" /> </g> <defs> <linearGradient id="b" x1="49.009" x2="225.829" y1="213.75" y2="129.722" gradientUnits="userSpaceOnUse" > <stop stop-color="#E40035" /> <stop offset=".24" stop-color="#F60A48" /> <stop offset=".352" stop-color="#F20755" /> <stop offset=".494" stop-color="#DC087D" /> <stop offset=".745" stop-color="#9717E7" /> <stop offset="1" stop-color="#6C00F5" /> </linearGradient> <linearGradient id="c" x1="41.025" x2="156.741" y1="28.344" y2="160.344" gradientUnits="userSpaceOnUse" > <stop stop-color="#FF31D9" /> <stop offset="1" stop-color="#FF5BE1" stop-opacity="0" /> </linearGradient> <clipPath id="a"> <path fill="#fff" d="M0 0h223v236H0z" /> </clipPath> </defs> </svg> } @else { <img src="assets/images/uwu.png" style="width: auto; margin: 0" class="uwu-logo" alt="Angular logo" height="34"/> } </a> <!-- Version picker for v18+ --> <div class="adev-nav-item"> <button type="button" aria-label="Select Angular version" role="menu" class="adev-version-button" [class.adev-mini-menu-open]="openedMenu === 'version-picker'" [cdkMenuTriggerFor]="docsVersionMiniMenu" [cdkMenuPosition]="miniMenuPositions" (cdkMenuClosed)="closeMenu()" (click)="openVersionMenu($event)" > {{ currentDocsVersion()?.displayName }} <svg xmlns="http://www.w3.org/2000/svg" height="15" viewBox="0 -960 960 960" width="15" fill="inherit" > <path d="M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z" /> </svg> </button> <ng-template #docsVersionMiniMenu> <ul class="adev-mini-menu adev-version-picker" cdkMenu> @for (item of versions(); track item) { <li> <a type="button" cdkMenuItem [href]="item.url" [attr.aria-label]="item.displayName" > <span>{{ item.displayName }}</span> </a> </li> } </ul> </ng-template> </div> </li> <!-- Search --> <li class="adev-nav-item"> <button class="adev-nav-button" type="button" (click)="toggleSearchDialog($event)" title="Search docs" > <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="inherit" > <path d="M14.583 15.48 9.104 10a4.591 4.591 0 0 1-1.458.844 5.156 5.156 0 0 1-1.771.302c-1.5 0-2.77-.52-3.813-1.563C1.022 8.542.5 7.285.5 5.813c0-1.473.52-2.73 1.563-3.771C3.103 1 4.367.479 5.854.479 7.326.48 8.58 1 9.614 2.042c1.035 1.041 1.553 2.298 1.553 3.77 0 .598-.098 1.174-.292 1.73A5.287 5.287 0 0 1 10 9.104l5.5 5.459-.917.916ZM5.854 9.895c1.125 0 2.083-.4 2.875-1.198a3.95 3.95 0 0 0 1.188-2.885 3.95 3.95 0 0 0-1.188-2.886C7.938 2.13 6.98 1.73 5.854 1.73c-1.139 0-2.107.4-2.906 1.198-.799.799-1.198 1.76-1.198 2.886 0 1.125.4 2.086 1.198 2.885.799.799 1.767 1.198 2.906 1.198Z" /> </svg> <span class="adev-nav-item__label adev-search-desktop" [attr.aria-label]="'Open search dialog with ' + searchTitle" > <kbd>{{ searchLabel }}</kbd> <kbd>K</kbd> </span> </button> </li> <!-- Docs -->
{ "end_byte": 8094, "start_byte": 2221, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.html" }
angular/adev/src/app/core/layout/navigation/navigation.component.html_8101_12012
<li class="adev-nav-item" [class.adev-nav-item--active]="activeRouteItem() === DOCS_ROUTE"> <a [routerLink]="DOCS_ROUTE"> <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="18" fill="inherit" > <path d="M3.645 13.792h6.708v-1.25H3.645v1.25Zm0-3.542h6.708V9H3.645v1.25Zm-2.063 7.083a1.2 1.2 0 0 1-.875-.375 1.2 1.2 0 0 1-.375-.875V1.917a1.2 1.2 0 0 1 .375-.875 1.2 1.2 0 0 1 .875-.375h7.52l4.563 4.562v10.854a1.2 1.2 0 0 1-.375.875 1.2 1.2 0 0 1-.875.375H1.582ZM8.478 5.792V1.917H1.582v14.166h10.833V5.792H8.478Z" /> </svg> <span class="adev-nav-item__label">Docs</span> </a> </li> <!-- Tutorials --> <li class="adev-nav-item" [class.adev-nav-item--active]="activeRouteItem() === TUTORIALS_ROUTE" > <a [routerLink]="TUTORIALS_ROUTE"> <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="18" height="10" fill="inherit" > <path d="m5.668 10-5-5 5-5 1.187 1.188L3.022 5.02l3.813 3.812L5.668 10Zm6.667 0-1.188-1.188L14.98 4.98l-3.812-3.812L12.335 0l5 5-5 5Z" /> </svg> <span class="adev-nav-item__label">Tutorials</span> </a> </li> <!-- Playground --> <li class="adev-nav-item" [class.adev-nav-item--active]="activeRouteItem() === PLAYGROUND_ROUTE" > <a [routerLink]="PLAYGROUND_ROUTE"> <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"> <path d="M450.001-611.691v-32.386q-39.385-9.923-64.692-41.897-25.308-31.975-25.308-74.025 0-49.922 35.038-84.96 35.039-35.038 84.961-35.038t84.961 35.038q35.038 35.038 35.038 84.96 0 42.05-25.308 74.025-25.307 31.974-64.692 41.897v32.386l273.846 157.538q17.173 9.912 26.663 26.582 9.491 16.671 9.491 36.495v62.152q0 19.824-9.491 36.495-9.49 16.67-26.663 26.582L516.154-111.771q-17.203 9.846-36.217 9.846t-36.091-9.846L176.155-265.847q-17.173-9.912-26.663-26.582-9.491-16.671-9.491-36.495v-62.152q0-19.824 9.491-36.495 9.49-16.67 26.663-26.582l273.846-157.538Zm-6.155 364.537L200-387.461v58.537q0 3.078 1.539 5.962 1.538 2.885 4.615 4.808l267.692 154.692q3.077 1.923 6.154 1.923t6.154-1.923l267.692-154.692q3.077-1.923 4.615-4.808 1.539-2.884 1.539-5.962v-58.537L516.154-247.154q-17.203 9.847-36.217 9.847t-36.091-9.847Zm6.155-162.847V-542.77L250.46-427.691l223.386 128.846q3.077 1.924 6.154 1.924t6.154-1.924l223.001-128.846L509.999-542.77v132.769h-59.998ZM480-699.999q25 0 42.5-17.5t17.5-42.5q0-25-17.5-42.5t-42.5-17.5q-25 0-42.5 17.5t-17.5 42.5q0 25 17.5 42.5t42.5 17.5Zm-2.308 538.46Z" /> </svg> <span class="adev-nav-item__label">Playground</span> </a> </li> <!-- API Ref --> <li class="adev-nav-item" [class.adev-nav-item--active]="activeRouteItem() === REFERENCE_ROUTE" > <a [routerLink]="REFERENCE_ROUTE"> <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="18" fill="inherit" > <path d="M3.645 13.792h6.708v-1.25H3.645v1.25Zm0-3.542h6.708V9H3.645v1.25Zm-2.063 7.083a1.2 1.2 0 0 1-.875-.375 1.2 1.2 0 0 1-.375-.875V1.917a1.2 1.2 0 0 1 .375-.875 1.2 1.2 0 0 1 .875-.375h7.52l4.563 4.562v10.854a1.2 1.2 0 0 1-.375.875 1.2 1.2 0 0 1-.875.375H1.582ZM8.478 5.792V1.917H1.582v14.166h10.833V5.792H8.478Z" /> </svg> <span class="adev-nav-item__label">Reference</span> </a> </li> </ul> <!-- Bottom section of primary nav --> <div class="adev-nav__bottom"> <!-- Social Icons Dots -->
{ "end_byte": 12012, "start_byte": 8101, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.html" }
angular/adev/src/app/core/layout/navigation/navigation.component.html_12019_17045
<div class="adev-nav-item" [class.adev-nav-item--active]="openedMenu === 'social'"> <button type="button" [cdkMenuTriggerFor]="socialMiniMenu" [cdkMenuPosition]="miniMenuPositions" aria-label="Open social media links" (cdkMenuClosed)="closeMenu()" (cdkMenuOpened)="openMenu('social')" > <docs-icon role="presentation">more_horiz</docs-icon> </button> <ng-template #socialMiniMenu> <ul class="adev-mini-menu" cdkMenu> <li> <a [href]="YOUTUBE" cdkMenuItem title="Angular YouTube channel" target="_blank" rel="noopener" > <!-- Youtube Icon --> <svg width="20" height="15" viewBox="0 0 20 15" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M18.7556 2.94783C18.5803 1.98018 17.745 1.27549 16.7756 1.05549C15.325 0.747832 12.6403 0.527832 9.73563 0.527832C6.83266 0.527832 4.105 0.747832 2.65266 1.05549C1.685 1.27549 0.847969 1.93549 0.672656 2.94783C0.495625 4.04783 0.320312 5.58783 0.320312 7.56783C0.320312 9.54783 0.495625 11.0878 0.715625 12.1878C0.892656 13.1555 1.72797 13.8602 2.69563 14.0802C4.23563 14.3878 6.87563 14.6078 9.78031 14.6078C12.685 14.6078 15.325 14.3878 16.865 14.0802C17.8327 13.8602 18.668 13.2002 18.845 12.1878C19.0203 11.0878 19.2403 9.50314 19.285 7.56783C19.1956 5.58783 18.9756 4.04783 18.7556 2.94783ZM7.36031 10.6478V4.48783L12.728 7.56783L7.36031 10.6478Z" /> </svg> </a> </li> <li> <a [href]="X" cdkMenuItem title="Angular X (formerly Twitter) profile" target="_blank" rel="noopener" > <!-- X Icon --> <svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M0.04145 0.04432l6.56351 8.77603L0 15.95564h1.48651l5.78263-6.24705 4.6722 6.24705h5.05865l-6.9328-9.26967L16.21504.04432h-1.48651l-5.32552 5.75341L5.1001.04432H.04145Zm2.18602 1.09497h2.32396l10.26221 13.72122h-2.32396L2.22747 1.13928Z" /> </svg> </a> </li> <li> <a [href]="MEDIUM" cdkMenuItem title="Angular Medium blog" target="_blank" rel="noopener" > <!-- Medium Icon --> <svg width="20" height="20" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <path d="M7 6A7 7 0 107 20 7 7 0 107 6zM18 6.5A3 6.5 0 1018 19.5 3 6.5 0 1018 6.5zM23 8A1 5 0 1023 18 1 5 0 1023 8z" ></path> </svg> </a> </li> <li> <a [href]="GITHUB" cdkMenuItem title="Angular Github" target="_blank" rel="noopener"> <!-- Github Icon --> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" > <path fill-rule="evenodd" clip-rule="evenodd" d="M7.59948 19.0428C7.59948 18.8069 7.59118 18.182 7.58656 17.3526C4.89071 17.9526 4.32164 16.0201 4.32164 16.0201C3.88087 14.8718 3.24533 14.5663 3.24533 14.5663C2.36518 13.9492 3.31179 13.9621 3.31179 13.9621C4.28471 14.0323 4.79656 14.9868 4.79656 14.9868C5.66102 16.5052 7.06456 16.0672 7.61748 15.8125C7.70564 15.17 7.95579 14.732 8.23271 14.4837C6.08056 14.2331 3.81764 13.3801 3.81764 9.57199C3.81764 8.48737 4.19564 7.6003 4.81548 6.90522C4.71625 6.65414 4.38302 5.64384 4.91056 4.27537C4.91056 4.27537 5.72471 4.00814 7.57594 5.29399C8.34856 5.07384 9.17795 4.96307 10.0027 4.95937C10.8256 4.96307 11.6546 5.07384 12.429 5.29399C14.2793 4.00814 15.0921 4.27537 15.0921 4.27537C15.621 5.64337 15.2883 6.65368 15.1881 6.90522C15.8093 7.6003 16.1841 8.48737 16.1841 9.57199C16.1841 13.3898 13.9179 14.2298 11.7589 14.4758C12.1073 14.7828 12.4166 15.3892 12.4166 16.3165C12.4166 17.6452 12.4041 18.7174 12.4041 19.0428C12.4041 19.3091 12.579 19.6178 13.071 19.5205C16.9193 18.2041 19.6936 14.4814 19.6936 10.0926C19.6936 4.60353 15.3538 0.154297 10.0009 0.154297C4.64887 0.154297 0.309021 4.60353 0.309021 10.0926C0.309483 14.4828 3.08656 18.2078 6.9381 19.5218C7.42225 19.6128 7.59948 19.3058 7.59948 19.0428Z" /> </svg> </a> </li>
{ "end_byte": 17045, "start_byte": 12019, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.html" }
angular/adev/src/app/core/layout/navigation/navigation.component.html_17058_20895
<li> <a [href]="DISCORD" cdkMenuItem title="Angular Discord" target="_blank" rel="noopener"> <!-- Discord Icon --> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 127.14 96.36" width="20" height="20" fill="none" > <path fill-rule="evenodd" clip-rule="evenodd" d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,110.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z" /> </svg> </a> </li> </ul> </ng-template> </div> <!-- TODO: Refactor this and make it better. Accessible, animated, etc. --> <div class="adev-nav-item" [class.adev-nav-item--active]="openedMenu === 'theme-picker'"> <button type="button" [cdkMenuTriggerFor]="themeMiniMenu" [cdkMenuPosition]="miniMenuPositions" aria-label="Open theme picker" (cdkMenuClosed)="closeMenu()" (cdkMenuOpened)="openMenu('theme-picker')" > <docs-icon role="presentation"> @switch (theme()) { @case ('light') { {{ 'light_mode' }} } @case ('dark') { {{ 'dark_mode' }} } @case ('auto') { {{ 'routine' }} } } </docs-icon> </button> <ng-template #themeMiniMenu> <ul class="adev-mini-menu" cdkMenu> <li> <button type="button" cdkMenuItem (click)="setTheme('auto')" aria-label="Set default system theme" > <docs-icon class="docs-icon_high-contrast">routine</docs-icon> <span>System</span> </button> </li> <li> <button type="button" cdkMenuItem (click)="setTheme('dark')" aria-label="Set dark theme" > <docs-icon class="docs-icon_high-contrast">dark_mode</docs-icon> <span>Dark</span> </button> </li> <li> <button type="button" cdkMenuItem (click)="setTheme('light')" aria-label="Set light theme" > <docs-icon class="docs-icon_high-contrast">light_mode</docs-icon> <span>Light</span> </button> </li> </ul> </ng-template> </div> </div> </nav> <!-- Tablet: Second horizontal nav layer which opens the secondary nav --> @if (activeRouteItem() === DOCS_ROUTE || activeRouteItem() === REFERENCE_ROUTE) { <div class="adev-secondary-tablet-bar"> <button type="button" (click)="openMobileNav($event)"> <docs-icon class="docs-icon_high-contrast">menu</docs-icon> @if (activeRouteItem() === DOCS_ROUTE) { <span>Docs</span> } @if (activeRouteItem() === REFERENCE_ROUTE) { <span>API</span> } </button> </div> } </div>
{ "end_byte": 20895, "start_byte": 17058, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/navigation.component.html" }
angular/adev/src/app/core/layout/navigation/mini-menu.scss_0_1826
@use '@angular/docs/styles/media-queries' as mq; // Dark/Light mode switcher & social media icon buttons // ul .adev-mini-menu { padding: 0; color: var(--primary-contrast); background-color: var(--page-background); border: 1px solid var(--senary-contrast); border-radius: 0.25rem; z-index: var(--z-index-mini-menu); box-shadow: 10px 4px 40px 0 rgba(0, 0, 0, 0.075); @include mq.for-tablet { top: 75px; left: 5px; } li { list-style: none; // themes and versions button { padding: 1rem; min-width: 75px; min-height: 75px; width: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; docs-icon { font-size: 1.5rem; color: var(--quaternary-contrast); transition: color 0.3s ease; } &:hover { background-color: var(--senary-contrast); span, docs-icon { color: var(--primary-contrast); } } } // social links a { display: flex; justify-content: center; align-items: center; padding: 1rem; min-width: 50px; svg { fill: var(--quaternary-contrast); transition: fill 0.3s ease; } &:hover { background-color: var(--senary-contrast); svg { fill: var(--primary-contrast); } } } span { color: var(--quaternary-contrast); transition: color 0.3s ease; } } &-open { display: block; } } .adev-version-picker { overflow-y: auto; max-height: 90vh; top: 30px; left: 10px; position: absolute; bottom: auto; li { padding-inline: 0; } li a { line-height: 1em; } @include mq.for-tablet { top: 30px; left: auto; bottom: auto; } }
{ "end_byte": 1826, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/layout/navigation/mini-menu.scss" }
angular/adev/src/app/core/constants/versions.ts_0_1474
/*! * @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 */ export const VERSIONS_CONFIG = { aDevVersionsLinkPattern: 'https://{{prefix}}{{version}}angular.dev', aioVersions: [ { version: 'v17', url: 'https://v17.angular.io/docs', }, { version: 'v16', url: 'https://v16.angular.io/docs', }, { version: 'v15', url: 'https://v15.angular.io/docs', }, { version: 'v14', url: 'https://v14.angular.io/docs', }, { version: 'v13', url: 'https://v13.angular.io/docs', }, { version: 'v12', url: 'https://v12.angular.io/docs', }, { version: 'v11', url: 'https://v11.angular.io/docs', }, { version: 'v10', url: 'https://v10.angular.io/docs', }, { version: 'v9', url: 'https://v9.angular.io/docs', }, { version: 'v8', url: 'https://v8.angular.io/docs', }, { version: 'v7', url: 'https://v7.angular.io/docs', }, { version: 'v6', url: 'https://v6.angular.io/docs', }, { version: 'v5', url: 'https://v5.angular.io/docs', }, { version: 'v4', url: 'https://v4.angular.io/docs', }, { version: 'v2', url: 'https://v2.angular.io/docs', }, ], };
{ "end_byte": 1474, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/constants/versions.ts" }
angular/adev/src/app/core/constants/links.ts_0_467
/*! * @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 */ export const GITHUB = 'https://github.com/angular/angular'; export const X = 'https://x.com/angular'; export const MEDIUM = 'https://blog.angular.dev'; export const YOUTUBE = 'https://www.youtube.com/angular'; export const DISCORD = 'https://discord.gg/angular';
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/constants/links.ts" }
angular/adev/src/app/core/constants/keys.ts_0_343
/*! * @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 */ export const COMMAND = 'Command'; export const CONTROL = 'Control'; export const ESCAPE = 'Escape'; export const SEARCH_TRIGGER_KEY = 'k';
{ "end_byte": 343, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/constants/keys.ts" }
angular/adev/src/app/core/constants/element-ids.ts_0_296
/*! * @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 */ export const PRIMARY_NAV_ID = 'primaryNav'; export const SECONDARY_NAV_ID = 'secondaryNav';
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/constants/element-ids.ts" }
angular/adev/src/app/core/providers/current-version.ts_0_137
import {InjectionToken} from '@angular/core'; export const CURRENT_MAJOR_VERSION = new InjectionToken<number>('CURRENT_MAJOR_VERSION');
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/providers/current-version.ts" }
angular/adev/src/app/core/enums/pages.ts_0_716
/*! * @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 */ // File contains the enums used across whole application. // The enum with the prefixes of the main routes export enum PagePrefix { API = 'api', CLI = 'cli', DOCS = 'docs', HOME = '', PLAYGROUND = 'playground', REFERENCE = 'reference', TUTORIALS = 'tutorials', UPDATE = 'update-guide', } // The enum with the default pages for each main tab export enum DefaultPage { DOCS = 'overview', REFERENCE = 'api', TUTORIALS = 'tutorials', PLAYGROUND = 'playground', UPDATE = 'update-guide', }
{ "end_byte": 716, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/enums/pages.ts" }
angular/adev/src/app/core/services/example-content-loader.service.spec.ts_0_744
/*! * @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 {TestBed} from '@angular/core/testing'; import {ExampleContentLoader} from './example-content-loader.service'; import {PREVIEWS_COMPONENTS} from '@angular/docs'; describe('ExampleContentLoader', () => { let service: ExampleContentLoader; beforeEach(() => { TestBed.configureTestingModule({ providers: [ExampleContentLoader, {provide: PREVIEWS_COMPONENTS, useValue: []}], }); service = TestBed.inject(ExampleContentLoader); }); it('should be created', () => { expect(service).toBeTruthy(); }); });
{ "end_byte": 744, "start_byte": 0, "url": "https://github.com/angular/angular/blob/main/adev/src/app/core/services/example-content-loader.service.spec.ts" }