Files
WebApp/src/app/domain-selector.ts
T
Angel Capetillo Zavala e95c175f9b fix(shell): load the domain menu deferred and let the header wrap on narrow screens
The menu and its overlay were in the initial bundle of every route (+183 kB); they now load in their own chunk, with a same-size placeholder. On phones the title moves to a second row instead of being squeezed beside the selector.

(cherry picked from commit 2ccddf80dbbe41a328281fcdc1c95ebe421f4191)
2026-11-12 01:43:27 -06:00

29 lines
1.2 KiB
TypeScript

import { Component, input } from '@angular/core';
import { RouterLink } from '@angular/router';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { Dominio } from './features/indicadores/indicadores.models';
/** The header's domain menu. Loaded deferred: Material's menu and overlay are not needed by the institutional routes. */
@Component({
selector: 'app-domain-selector',
imports: [RouterLink, MatButtonModule, MatMenuModule],
template: `
<button class="domain-selector" mat-button [matMenuTriggerFor]="domainMenu"
[attr.aria-label]="'Dominio actual: ' + labels()[actual()] + '. Cambiar dominio'">
{{ labels()[actual()] }} <span aria-hidden="true">▾</span>
</button>
<mat-menu #domainMenu="matMenu" aria-label="Cambiar dominio de indicadores">
@for (option of otros(); track option) {
<a mat-menu-item [routerLink]="['/indicadores', option]">{{ labels()[option] }}</a>
}
</mat-menu>
`,
styleUrl: './domain-selector.scss',
})
export class DomainSelector {
readonly actual = input.required<Dominio>();
readonly otros = input.required<readonly Dominio[]>();
readonly labels = input.required<Record<Dominio, string>>();
}