feat(ui): completar presentacion de figuras UX-06D

This commit is contained in:
Angel Capetillo Zavala
2026-10-13 13:41:45 -06:00
parent 41be0c343f
commit 37c4eacf84
12 changed files with 250 additions and 29 deletions
+23 -2
View File
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Component, ElementRef, inject, OnDestroy, OnInit, signal, ViewChild } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
@@ -7,6 +8,26 @@ import { RouterOutlet } from '@angular/router';
styleUrl: './app.scss',
templateUrl: './app.html',
})
export class App {
export class App implements OnInit, OnDestroy {
protected readonly title = 'Plataforma de Indicadores';
readonly showBackToTop = signal(false);
@ViewChild('mainContent') private mainContent?: ElementRef<HTMLElement>;
private readonly browserWindow = inject(DOCUMENT).defaultView;
private readonly updateScroll = () => this.showBackToTop.set((this.browserWindow?.scrollY ?? 0) > 400);
ngOnInit() {
this.updateScroll();
this.browserWindow?.addEventListener('scroll', this.updateScroll, { passive: true });
}
backToTop() {
const reducedMotion = this.browserWindow?.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
// Keep keyboard focus near the destination when the floating button disappears.
this.mainContent?.nativeElement.focus({ preventScroll: true });
this.browserWindow?.scrollTo({ top: 0, behavior: reducedMotion ? 'instant' : 'smooth' });
}
ngOnDestroy() {
this.browserWindow?.removeEventListener('scroll', this.updateScroll);
}
}