diff --git a/angular.json b/angular.json index 2b304ca..d3f5a4a 100644 --- a/angular.json +++ b/angular.json @@ -2,7 +2,8 @@ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "cli": { - "packageManager": "npm" + "packageManager": "npm", + "analytics": false }, "newProjectRoot": "projects", "projects": { diff --git a/public/assets/branding/isssteleon-logo.png b/public/assets/branding/isssteleon-logo.png new file mode 100644 index 0000000..df4c1f9 Binary files /dev/null and b/public/assets/branding/isssteleon-logo.png differ diff --git a/src/app/app.html b/src/app/app.html index ff298c4..d52a576 100644 --- a/src/app/app.html +++ b/src/app/app.html @@ -1,7 +1,20 @@ - - {{ title }} - +
+ -
- -
+
+ +
+ + +
diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index dc39edb..9742bb2 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,3 +1,4 @@ import { Routes } from '@angular/router'; +import { Home } from './home'; -export const routes: Routes = []; +export const routes: Routes = [{ path: '', component: Home }]; diff --git a/src/app/app.scss b/src/app/app.scss index 8e69d4f..4462be8 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -1,3 +1,86 @@ -main { - padding: 1.5rem; +.app-shell { + display: flex; + flex-direction: column; + min-height: 100vh; + min-height: 100dvh; +} + +.site-header { + background: var(--color-surface); + border-bottom: 1px solid var(--color-border); +} + +.site-header__content { + align-items: center; + display: flex; + justify-content: space-between; + min-height: 88px; + padding: 0 clamp(32px, 3.2vw, 48px); +} + +.brand { + align-items: center; + display: inline-flex; +} + +.brand img { + display: block; + height: auto; + width: clamp(180px, 16vw, 200px); +} + +.site-header__section { + color: var(--color-text); + font-size: 15px; + font-weight: 500; + letter-spacing: 0.01em; +} + +.app-main { + display: flex; + flex: 1; +} + +.site-footer { + background: var(--color-text-secondary); +} + +.site-footer__content { + align-items: center; + display: flex; + justify-content: center; + min-height: 86px; + padding: 0 clamp(32px, 3.2vw, 48px); +} + +.site-footer img { + display: block; + filter: brightness(0) invert(1); + height: auto; + width: clamp(160px, 15vw, 185px); +} + +@media (max-width: 600px) { + .site-header__content { + min-height: 70px; + padding: 0 20px; + } + + .brand img { + width: clamp(132px, 42vw, 170px); + } + + .site-header__section { + font-size: 13px; + text-align: right; + } + + .site-footer__content { + min-height: 76px; + padding: 0 20px; + } + + .site-footer img { + width: 155px; + } } diff --git a/src/app/app.spec.ts b/src/app/app.spec.ts index f1bdf4a..6c32756 100644 --- a/src/app/app.spec.ts +++ b/src/app/app.spec.ts @@ -1,12 +1,15 @@ import { TestBed } from '@angular/core/testing'; +import { provideRouter, Router } from '@angular/router'; +import { MatDialog } from '@angular/material/dialog'; import { App } from './app'; +import { routes } from './app.routes'; describe('App', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [App], - }) - .compileComponents(); + providers: [provideRouter(routes)], + }).compileComponents(); }); it('should create the app', () => { @@ -15,11 +18,165 @@ describe('App', () => { expect(app).toBeTruthy(); }); - it('should render the toolbar title', async () => { + it('should render the ISSSTELEON header and home page', async () => { const fixture = TestBed.createComponent(App); + fixture.detectChanges(); + await TestBed.inject(Router).navigateByUrl('/'); await fixture.whenStable(); fixture.detectChanges(); const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('mat-toolbar')?.textContent).toContain('ISSSTELEON'); + expect(compiled.querySelector('.brand img')?.getAttribute('alt')).toBe('ISSSTELEON'); + expect(compiled.querySelector('.site-header__section')?.textContent).toContain( + 'Análisis de información', + ); + expect(compiled.querySelector('h1')?.textContent).toContain('Analiza tu información'); + }); + + it('opens one dialog and keeps it open on backdrop and Escape', async () => { + const fixture = TestBed.createComponent(App); + fixture.detectChanges(); + await TestBed.inject(Router).navigateByUrl('/'); + await fixture.whenStable(); + fixture.detectChanges(); + + fixture.nativeElement.querySelector('.home__action').click(); + fixture.detectChanges(); + await fixture.whenStable(); + + const dialog = TestBed.inject(MatDialog); + expect(dialog.openDialogs).toHaveLength(1); + const overlay = document.querySelector('.cdk-overlay-container')!; + expect(overlay.querySelector('#upload-title')?.textContent).toContain('Cargar información'); + overlay.querySelector('.cdk-overlay-backdrop')?.click(); + document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); + expect(dialog.openDialogs).toHaveLength(1); + expect(overlay.querySelector('.upload-dialog__continue')?.hasAttribute('disabled')).toBe(true); + }); + + it('selects either source, continues, returns with selection, and closes explicitly', async () => { + const fixture = TestBed.createComponent(App); + fixture.detectChanges(); + await TestBed.inject(Router).navigateByUrl('/'); + await fixture.whenStable(); + fixture.detectChanges(); + + fixture.nativeElement.querySelector('.home__action').click(); + fixture.detectChanges(); + await fixture.whenStable(); + + const overlay = document.querySelector('.cdk-overlay-container')!; + const cards = () => overlay.querySelectorAll('.source-card'); + const continueButton = overlay.querySelector('.upload-dialog__continue')!; + const detectDialogChanges = () => TestBed.inject(MatDialog).openDialogs[0].componentRef?.changeDetectorRef.detectChanges(); + expect(continueButton.disabled).toBe(true); + overlay.querySelector('.source-card')!.click(); + detectDialogChanges(); + expect(continueButton.disabled).toBe(false); + continueButton.click(); + detectDialogChanges(); + fixture.detectChanges(); + expect(overlay.querySelector('.upload-dialog__description')?.textContent).toContain( + 'Selecciona los archivos que deseas procesar.', + ); + expect(overlay.querySelector('.upload-steps__item--active')?.textContent).toContain( + 'Configuración', + ); + expect(continueButton.disabled).toBe(true); + const fileInput = overlay.querySelector('input[type="file"]')!; + const validFile = new File(['contenido'], 'pacientes.XLSX', { + type: 'application/octet-stream', + }); + const csvFile = new File(['a,b'], 'consultas.csv', { type: 'text/csv' }); + const invalidFile = new File(['x'], 'documento.docx'); + const emptyFile = new File([], 'vacio.csv'); + const selectFiles = (...files: File[]) => { + Object.defineProperty(fileInput, 'files', { configurable: true, value: files }); + fileInput.dispatchEvent(new Event('change', { bubbles: true })); + detectDialogChanges(); + fixture.detectChanges(); + }; + selectFiles(validFile, csvFile, invalidFile, emptyFile); + expect(overlay.querySelectorAll('.file-row')).toHaveLength(2); + expect(overlay.querySelector('.file-messages')?.textContent).toContain( + 'documento.docx no fue agregado. Formato no compatible.', + ); + expect(overlay.querySelector('.file-messages')?.textContent).toContain( + 'vacio.csv no fue agregado. El archivo está vacío.', + ); + expect(continueButton.disabled).toBe(false); + selectFiles(validFile); + expect(overlay.querySelectorAll('.file-row')).toHaveLength(2); + expect(overlay.querySelector('.file-messages')?.textContent).toContain( + 'pacientes.XLSX ya se encuentra seleccionado.', + ); + const jsonFile = new File(['{}'], 'nuevo.json', { type: 'application/json' }); + const dialogComponent = TestBed.inject(MatDialog).openDialogs[0].componentRef! + .instance as import('./information-upload-dialog').InformationUploadDialog; + dialogComponent.onDrop({ + preventDefault: () => undefined, + dataTransfer: { files: [jsonFile] }, + } as unknown as DragEvent); + detectDialogChanges(); + fixture.detectChanges(); + expect(overlay.querySelectorAll('.file-row')).toHaveLength(3); + overlay.querySelector('.file-row__remove')!.click(); + detectDialogChanges(); + fixture.detectChanges(); + expect(overlay.querySelectorAll('.file-row')).toHaveLength(2); + continueButton.click(); + detectDialogChanges(); + fixture.detectChanges(); + expect(overlay.querySelector('h3')?.textContent).toContain('Confirmación'); + expect(overlay.querySelector('.configuration-placeholder p')?.textContent).toContain( + 'La confirmación de los archivos se implementará en la siguiente fase.', + ); + overlay.querySelector('.upload-dialog__back')!.click(); + detectDialogChanges(); + fixture.detectChanges(); + expect(overlay.querySelectorAll('.file-row')).toHaveLength(2); + while (overlay.querySelector('.file-row__remove')) { + overlay.querySelector('.file-row__remove')!.click(); + detectDialogChanges(); + fixture.detectChanges(); + } + expect(overlay.querySelectorAll('.file-row')).toHaveLength(0); + expect(overlay.querySelector('.upload-dialog__continue')?.disabled).toBe(true); + overlay.querySelector('.upload-dialog__back')!.click(); + detectDialogChanges(); + fixture.detectChanges(); + expect(cards()[0].getAttribute('aria-pressed')).toBe('true'); + overlay.querySelectorAll('.source-card')[1].click(); + detectDialogChanges(); + const sqlContinueButton = overlay.querySelector('.upload-dialog__continue')!; + expect(sqlContinueButton.disabled).toBe(false); + sqlContinueButton.click(); + detectDialogChanges(); + fixture.detectChanges(); + expect(overlay.querySelector('h3')?.textContent).toContain('Conexión SQL'); + expect(overlay.querySelector('.upload-dialog__continue')?.disabled).toBe(true); + overlay.querySelector('.upload-dialog__back')!.click(); + detectDialogChanges(); + fixture.detectChanges(); + expect(cards()[1].getAttribute('aria-pressed')).toBe('true'); + overlay.querySelector('.upload-dialog__close')!.click(); + fixture.detectChanges(); + await new Promise((resolve) => setTimeout(resolve, 200)); + expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0); + + fixture.nativeElement.querySelector('.home__action').click(); + fixture.detectChanges(); + await fixture.whenStable(); + const reopenedOverlay = document.querySelector('.cdk-overlay-container')!; + reopenedOverlay.querySelector('.source-card')!.click(); + const reopenedDialog = TestBed.inject(MatDialog).openDialogs[0].componentRef!; + reopenedDialog.changeDetectorRef.detectChanges(); + reopenedOverlay.querySelector('.upload-dialog__continue')!.click(); + reopenedDialog.changeDetectorRef.detectChanges(); + expect(reopenedOverlay.querySelector('.selected-files')).toBeNull(); + expect(reopenedOverlay.querySelector('.upload-dialog__continue')?.disabled).toBe(true); + reopenedOverlay.querySelector('.upload-dialog__cancel')!.click(); + fixture.detectChanges(); + await new Promise((resolve) => setTimeout(resolve, 200)); + expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0); }); }); diff --git a/src/app/app.ts b/src/app/app.ts index 71ff325..3e7d97c 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,13 +1,10 @@ import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; -import { MatToolbarModule } from '@angular/material/toolbar'; @Component({ - imports: [RouterOutlet, MatToolbarModule], + imports: [RouterOutlet], selector: 'app-root', styleUrl: './app.scss', templateUrl: './app.html', }) -export class App { - protected readonly title = 'ISSSTELEON'; -} +export class App {} diff --git a/src/app/home.html b/src/app/home.html new file mode 100644 index 0000000..5e3b7ca --- /dev/null +++ b/src/app/home.html @@ -0,0 +1,27 @@ +
+
+

ISSSTELEON · Análisis de información

+

Analiza tu información

+

+ Carga tus datos para procesarlos y consultar resultados de forma clara y sencilla. +

+ +
    +
  1. + + Carga información +
  2. +
  3. + + Procesa los datos +
  4. +
  5. + + Consulta resultados +
  6. +
+
+
diff --git a/src/app/home.scss b/src/app/home.scss new file mode 100644 index 0000000..9cabd3c --- /dev/null +++ b/src/app/home.scss @@ -0,0 +1,131 @@ +:host { + display: flex; + flex: 1; + min-width: 0; +} + +.home { + align-items: flex-start; + display: flex; + flex: 1; + justify-content: center; + min-height: inherit; + padding: 72px 32px; + text-align: center; +} + +.home__content { + margin-inline: auto; + max-width: 780px; + width: 100%; +} +.home__eyebrow { + color: var(--color-text-secondary); + font-size: 12px; + font-weight: 500; + letter-spacing: 0.12em; + margin: 0 0 18px; + text-transform: uppercase; +} +h1 { + color: var(--color-primary); + font-family: var(--font-heading); + font-size: clamp(2.75rem, 5.1vw, 3.375rem); + font-weight: 700; + letter-spacing: -0.045em; + line-height: 1.08; + margin: 0; +} +.home__description { + color: var(--color-text-secondary); + font-size: 16px; + line-height: 1.6; + margin: 20px auto 30px; + max-width: 560px; +} +.home__action { + align-items: center; + background: #f8f9fa; + border: 1px solid #e9ecef; + border-radius: 8px; + color: var(--color-text); + cursor: pointer; + display: inline-flex; + font: inherit; + font-weight: 600; + gap: 9px; + min-height: 50px; + padding: 12px 20px; + transition: + background-color 0.2s ease, + border-color 0.2s ease, + color 0.2s ease, + transform 0.2s ease; +} + +.home__action:hover { + background: #e9ecef; + border-color: #5f9ea0; + transform: translateY(-1px); +} + +.home__action:focus-visible { + outline: 3px solid rgb(168 194 67 / 55%); + outline-offset: 3px; +} + +.home__action:active { + transform: translateY(0); +} + +.home__action mat-icon { + color: #5f9ea0; + margin: 0; +} +.steps { + align-items: center; + color: var(--color-text-secondary); + display: flex; + flex-wrap: wrap; + gap: 24px 36px; + justify-content: center; + list-style: none; + margin: 74px 0 0; + padding: 0; +} +.steps__item { + align-items: center; + display: inline-flex; + font-size: 14px; + gap: 10px; +} +.steps__icon { + align-items: center; + background: var(--color-step); + border-radius: 50%; + color: var(--color-primary); + display: inline-flex; + height: 38px; + justify-content: center; + width: 38px; +} + +@media (max-width: 600px) { + .home { + padding: 56px 22px; + } + h1 { + font-size: clamp(2.35rem, 10vw, 2.8rem); + } + .home__description { + font-size: 15px; + margin-top: 16px; + } + .steps { + align-items: flex-start; + flex-direction: column; + gap: 16px; + margin: 52px auto 0; + max-width: 230px; + } +} diff --git a/src/app/home.ts b/src/app/home.ts new file mode 100644 index 0000000..7513f12 --- /dev/null +++ b/src/app/home.ts @@ -0,0 +1,27 @@ +import { Component, inject } from '@angular/core'; +import { MatDialog, MatDialogModule } from '@angular/material/dialog'; +import { MatIconModule } from '@angular/material/icon'; +import { InformationUploadDialog } from './information-upload-dialog'; + +@Component({ + imports: [MatDialogModule, MatIconModule], + selector: 'app-home', + styleUrl: './home.scss', + templateUrl: './home.html', +}) +export class Home { + private readonly dialog = inject(MatDialog); + + openInformationDialog(): void { + if (this.dialog.openDialogs.length > 0) return; + + this.dialog.open(InformationUploadDialog, { + width: '800px', + maxWidth: 'calc(100vw - 32px)', + autoFocus: 'first-tabbable', + restoreFocus: true, + disableClose: true, + panelClass: 'information-upload-dialog-panel', + }); + } +} diff --git a/src/app/information-upload-dialog.html b/src/app/information-upload-dialog.html new file mode 100644 index 0000000..2f13303 --- /dev/null +++ b/src/app/information-upload-dialog.html @@ -0,0 +1,105 @@ +
+
+

Cargar información

+ +
+ +
    +
  1. + Fuente +
  2. +
  3. + Configuración +
  4. +
  5. + Confirmación +
  6. +
+ + @if (step() === 'source') { +

Selecciona cómo deseas proporcionar los datos.

+
+
+ + +
+
+ } @else if (step() === 'configuration' && source() === 'file') { +

Selecciona los archivos que deseas procesar.

+
+
+ +

Arrastra tus archivos aquí

+

Excel · CSV · JSON · PDF

+ + +
+ + @if (fileMessages().length > 0) { +
    + @for (message of fileMessages(); track $index) {
  • {{ message }}
  • } +
+ } + + @if (files().length > 0) { +
+
+

Archivos seleccionados

+ {{ files().length }} +
+
    + @for (file of files(); track file.name + ':' + file.size) { +
  • + + {{ file.name }} + {{ formatFileSize(file.size) }} + +
  • + } +
+
+ } +
+ } @else if (step() === 'configuration') { +

Configura la fuente seleccionada.

+
+ +

Conexión SQL

+

La configuración de la conexión se implementará en la siguiente fase.

+
+ } @else { +

Revisa el siguiente paso de la carga de información.

+
+ +

Confirmación

+

La confirmación de los archivos se implementará en la siguiente fase.

+
+ } + +
+ +
+ @if (step() !== 'source') { + + } + @if (step() !== 'confirmation') { + + } +
+
+
diff --git a/src/app/information-upload-dialog.scss b/src/app/information-upload-dialog.scss new file mode 100644 index 0000000..17bea23 --- /dev/null +++ b/src/app/information-upload-dialog.scss @@ -0,0 +1,494 @@ +:host { + display: block; +} + +.upload-dialog { + background: #fff; + color: #081839; + padding: 28px 32px 24px; +} +.upload-dialog__header { + align-items: flex-start; + display: flex; + gap: 20px; + justify-content: space-between; +} +.upload-dialog__header h2 { + font-family: var(--font-heading); + font-size: 30px; + line-height: 1.15; + margin: 0; +} +.upload-dialog__description { + color: #7a7a7a; + font-size: 15px; + line-height: 1.5; + margin: 14px 0 0; +} +.upload-dialog__close { + color: #596273; + margin: -8px -10px 0 0; +} +.upload-steps { + align-items: center; + border-bottom: 1px solid #e3e7df; + color: #7a7a7a; + display: flex; + justify-content: center; + list-style: none; + margin: 24px 0 0; + padding: 0 0 20px; +} +.upload-steps li { + align-items: center; + display: flex; + font-size: 13px; + gap: 8px; +} +.upload-steps li + li::before { + background: #dfe3dc; + content: ''; + height: 1px; + margin: 0 14px; + width: clamp(20px, 8vw, 70px); +} +.upload-steps__number { + align-items: center; + background: #f0f2ed; + border-radius: 50%; + display: inline-flex; + font-size: 12px; + height: 25px; + justify-content: center; + width: 25px; +} +.upload-steps__number mat-icon { + font-size: 16px; + height: 16px; + width: 16px; +} +.upload-steps__item--active { + color: #081839; + font-weight: 600; +} +.upload-steps__item--active .upload-steps__number { + background: #a8c243; + color: #081839; +} +.upload-steps__item--complete { + color: #71882b; +} +.upload-steps__item--complete .upload-steps__number { + background: #f0f3e8; + color: #71882b; +} +.upload-dialog__content { + padding: 18px 0 28px; +} +.source-options { + display: grid; + gap: 16px; + grid-template-columns: repeat(2, minmax(0, 1fr)); +} +.source-card { + align-items: center; + background: #fff; + border: 1px solid #e3e7df; + border-radius: 9px; + color: #081839; + cursor: pointer; + display: flex; + gap: 16px; + min-height: 126px; + padding: 20px; + position: relative; + text-align: left; + transition: + background-color 0.16s ease, + border-color 0.16s ease; +} +.source-card:hover { + background: #fafbf7; + border-color: #c7d49a; +} +.source-card:focus-visible, +.upload-dialog__close:focus-visible, +.file-row__remove:focus-visible, +.upload-action:focus-visible { + outline: 3px solid rgb(168 194 67 / 65%); + outline-offset: 2px; +} +.source-card--selected { + background: #fbfcf6; + border: 2px solid #a8c243; + padding: 19px; +} +.source-card__icon { + align-items: center; + background: #f0f3e8; + border-radius: 8px; + color: #71882b; + display: inline-flex; + flex: 0 0 46px; + height: 46px; + justify-content: center; +} +.source-card__copy { + display: grid; + gap: 6px; + min-width: 0; +} +.source-card__title { + font-size: 16px; + font-weight: 600; +} +.source-card__description { + color: #7a7a7a; + font-size: 13px; + line-height: 1.45; +} +.source-card__check { + color: #71882b; + margin-left: auto; +} +.configuration-placeholder { + align-items: center; + display: flex; + flex-direction: column; + justify-content: center; + min-height: 164px; + text-align: center; +} +.configuration-placeholder__icon { + align-items: center; + background: #f0f3e8; + border-radius: 50%; + color: #71882b; + display: inline-flex; + height: 48px; + justify-content: center; + width: 48px; +} +.configuration-placeholder h3 { + font-family: var(--font-heading); + font-size: 22px; + margin: 14px 0 6px; +} +.configuration-placeholder p { + color: #7a7a7a; + font-size: 14px; + line-height: 1.55; + margin: 0; + max-width: 460px; +} +.file-configuration { + padding-top: 18px; +} +.dropzone { + align-items: center; + background: #fcfdfb; + border: 1.5px dashed #cbd2c4; + border-radius: 10px; + display: flex; + flex-direction: column; + justify-content: center; + min-height: 244px; + padding: 24px; + text-align: center; + transition: + background-color 0.14s ease, + border-color 0.14s ease; +} +.dropzone--active { + background: #f5f8e9; + border-color: #a8c243; + border-style: solid; +} +.dropzone__icon { + color: #71882b; + font-size: 40px; + height: 40px; + width: 40px; +} +.dropzone__title { + font-size: 16px; + font-weight: 600; + margin: 14px 0 4px; +} +.dropzone__formats { + color: #7a7a7a; + font-size: 13px; + margin: 0 0 16px; +} +.select-files-button { + --mat-button-outlined-label-text-color: #081839; + --mat-button-outlined-outline-color: #d7dccf; + --mat-button-outlined-state-layer-color: transparent; + --mat-button-outlined-ripple-color: transparent; + background: #fff; + border: 1px solid var(--mat-button-outlined-outline-color); + transition: border-color 0.18s ease; +} +.upload-action--outlined:hover { + background: #f3f6e9; + border-color: #a8c243; +} +.upload-action--outlined:active { + background: #e8eed5; +} +.select-files-button mat-icon { + color: #5f9ea0; + margin: 0; +} +.visually-hidden { + clip: rect(0, 0, 0, 0); + clip-path: inset(50%); + height: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + width: 1px; +} +.file-messages { + background: #fffaf0; + border: 1px solid #ead8a7; + border-radius: 7px; + color: #634d13; + font-size: 13px; + line-height: 1.45; + list-style: none; + margin: 12px 0 0; + padding: 10px 14px; +} +.file-messages li + li { + margin-top: 4px; +} +.selected-files { + margin-top: 20px; +} +.selected-files__header { + align-items: center; + display: flex; + gap: 10px; + justify-content: space-between; + margin-bottom: 8px; +} +.selected-files__header h3 { + font-size: 15px; + font-weight: 600; + margin: 0; +} +.selected-files__count { + align-items: center; + background: #f0f3e8; + border-radius: 20px; + color: #52651d; + display: inline-flex; + font-size: 12px; + font-weight: 600; + height: 25px; + justify-content: center; + min-width: 25px; + padding: 0 7px; +} +.selected-files__list { + border: 1px solid #e7eae3; + border-radius: 8px; + list-style: none; + margin: 0; + max-height: 220px; + overflow-y: auto; + padding: 0; +} +.file-row { + align-items: center; + display: grid; + gap: 10px; + grid-template-columns: 22px minmax(0, 1fr) auto 40px; + min-height: 54px; + padding: 6px 8px 6px 12px; +} +.file-row + .file-row { + border-top: 1px solid #eef0eb; +} +.file-row__icon { + color: #71882b; + font-size: 20px; + height: 20px; + width: 20px; +} +.file-row__name { + font-size: 13px; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.file-row__size { + color: #737b6b; + font-size: 12px; + white-space: nowrap; +} +.file-row__remove { + color: #596273; + height: 36px; + line-height: 36px; + width: 36px; +} +.upload-dialog__footer { + align-items: center; + border-top: 1px solid #e3e7df; + display: grid; + gap: 10px; + grid-template-columns: minmax(0, 1fr) auto; + padding-top: 18px; +} +.action-cancel { + justify-self: start; +} +.upload-dialog__navigation { + align-items: center; + display: flex; + gap: 10px; + justify-self: end; +} +.upload-action { + border-radius: 8px; + font: inherit; + font-weight: 600; + min-height: 44px; + padding: 10px 18px; + transition: background-color 0.18s ease; +} +.action-cancel, +.action-back { + --mat-button-text-state-layer-color: transparent; + --mat-button-text-ripple-color: transparent; +} +.action-cancel { + --mat-button-text-label-text-color: #fff; + background: #7a7a7a; +} +.action-cancel:hover { + background: #696969; +} +.action-cancel:active { + background: #5d5d5d; +} +.action-back { + --mat-button-text-label-text-color: #081839; + background: #fff; + border: 1px solid #d7dccf; +} +.action-back:hover { + background: #f3f6e9; + border-color: #a8c243; +} +.action-back:active { + background: #e8eed5; +} +.action-continue { + --mat-button-filled-container-color: #6f821c; + --mat-button-filled-label-text-color: #f7f9ef; + --mat-button-filled-state-layer-color: transparent; + --mat-button-filled-ripple-color: transparent; + min-width: 124px; +} +.action-continue:hover:not(:disabled) { + --mat-button-filled-container-color: #809625; +} +.action-continue:active:not(:disabled) { + --mat-button-filled-container-color: #607216; +} +.action-continue:disabled { + --mat-button-filled-disabled-container-color: #e8ecdf; + --mat-button-filled-disabled-label-text-color: #9da38f; + --mat-button-filled-disabled-state-layer-color: transparent; +} +@media (max-width: 600px) { + .upload-dialog { + padding: 22px 20px 18px; + } + .upload-dialog__header h2 { + font-size: 26px; + } + .upload-dialog__description { + font-size: 14px; + margin-top: 12px; + } + .upload-steps { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + } + .upload-steps li { + flex-direction: column; + font-size: 11px; + gap: 4px; + text-align: center; + } + .upload-steps li + li::before { + display: none; + } + .upload-steps__number { + height: 22px; + width: 22px; + } + .source-options { + grid-template-columns: 1fr; + } + .source-card { + min-height: 94px; + padding: 16px; + } + .source-card--selected { + padding: 15px; + } + .upload-dialog__content { + padding: 20px 0; + } + .dropzone { + min-height: 220px; + padding: 20px 12px; + } + .file-row { + gap: 6px; + grid-template-columns: 20px minmax(0, 1fr) auto 36px; + padding-left: 8px; + } + .file-row__name { + font-size: 12px; + } + .file-row__size { + font-size: 11px; + } +} + +@media (max-width: 360px) { + .upload-dialog { + padding-inline: 16px; + } + .upload-steps li { + font-size: 10px; + } + .upload-dialog__footer { + gap: 4px; + } + .upload-dialog__navigation { + gap: 4px; + } + .action-cancel, + .action-back { + min-width: 56px; + padding-inline: 6px; + } + .action-continue { + min-width: 92px; + padding-inline: 10px; + } +} + +@media (max-width: 300px) { + .upload-dialog__footer { + grid-template-columns: minmax(0, 1fr); + } +} diff --git a/src/app/information-upload-dialog.ts b/src/app/information-upload-dialog.ts new file mode 100644 index 0000000..2901f6b --- /dev/null +++ b/src/app/information-upload-dialog.ts @@ -0,0 +1,129 @@ +import { Component, signal } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; +import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; +import { MatIconModule } from '@angular/material/icon'; + +type UploadSource = 'file' | 'sql'; +type UploadStep = 'source' | 'configuration' | 'confirmation'; + +@Component({ + imports: [MatButtonModule, MatDialogModule, MatIconModule], + selector: 'app-information-upload-dialog', + styleUrl: './information-upload-dialog.scss', + templateUrl: './information-upload-dialog.html', +}) +export class InformationUploadDialog { + readonly step = signal('source'); + readonly source = signal(null); + readonly files = signal([]); + readonly fileMessages = signal([]); + readonly isDragOver = signal(false); + + private dragDepth = 0; + private readonly allowedExtensions = new Set(['xlsx', 'csv', 'json', 'pdf']); + + constructor(private readonly dialogRef: MatDialogRef) {} + + selectSource(source: UploadSource): void { + this.source.set(source); + } + + continue(): void { + if (this.step() === 'source' && this.source()) this.step.set('configuration'); + else if (this.step() === 'configuration' && this.source() === 'file' && this.files().length > 0) { + this.step.set('confirmation'); + } + } + + back(): void { + if (this.step() === 'confirmation') this.step.set('configuration'); + else if (this.step() === 'configuration') this.step.set('source'); + } + + close(): void { + this.dialogRef.close(); + } + + onFileSelection(event: Event): void { + const input = event.target as HTMLInputElement; + this.addFiles(input.files ? Array.from(input.files) : []); + input.value = ''; + } + + onDragEnter(event: DragEvent): void { + event.preventDefault(); + this.dragDepth++; + this.isDragOver.set(true); + } + + onDragOver(event: DragEvent): void { + event.preventDefault(); + if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy'; + } + + onDragLeave(event: DragEvent): void { + event.preventDefault(); + this.dragDepth = Math.max(0, this.dragDepth - 1); + if (this.dragDepth === 0) this.isDragOver.set(false); + } + + onDrop(event: DragEvent): void { + event.preventDefault(); + this.dragDepth = 0; + this.isDragOver.set(false); + this.addFiles(event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : []); + } + + removeFile(fileToRemove: File): void { + this.files.update((files) => files.filter((file) => file !== fileToRemove)); + } + + formatFileSize(size: number): string { + if (size < 1024) return `${size} bytes`; + const units = ['KB', 'MB', 'GB']; + let value = size / 1024; + let unit = 0; + while (value >= 1024 && unit < units.length - 1) { + value /= 1024; + unit++; + } + return `${new Intl.NumberFormat('es-MX', { maximumFractionDigits: 1 }).format(value)} ${units[unit]}`; + } + + fileIcon(file: File): string { + const extension = this.extensionOf(file.name); + if (extension === 'pdf') return 'picture_as_pdf'; + if (extension === 'csv' || extension === 'xlsx') return 'table_chart'; + return 'data_object'; + } + + private addFiles(incomingFiles: File[]): void { + const messages: string[] = []; + const accepted = [...this.files()]; + + for (const file of incomingFiles) { + const extension = this.extensionOf(file.name); + if (!this.allowedExtensions.has(extension)) { + messages.push(`${file.name} no fue agregado. Formato no compatible.`); + continue; + } + if (file.size === 0) { + messages.push(`${file.name} no fue agregado. El archivo está vacío.`); + continue; + } + if (accepted.some((existing) => existing.name === file.name && existing.size === file.size)) { + messages.push(`${file.name} ya se encuentra seleccionado.`); + continue; + } + accepted.push(file); + } + + if (accepted.length !== this.files().length) this.files.set(accepted); + this.fileMessages.set(messages); + } + + private extensionOf(fileName: string): string { + const finalDot = fileName.lastIndexOf('.'); + return finalDot >= 0 ? fileName.slice(finalDot + 1).toLowerCase() : ''; + } +} diff --git a/src/index.html b/src/index.html index 5ac61ae..cc672be 100644 --- a/src/index.html +++ b/src/index.html @@ -1,8 +1,8 @@ - + - WebApp + Análisis de información | ISSSTELEON diff --git a/src/styles.scss b/src/styles.scss index 8ba3af6..f91119b 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -1,10 +1,17 @@ -// Include theming for Angular Material with `mat.theme()`. -// This Sass mixin will define CSS variables that are used for styling Angular Material -// components according to the Material 3 design spec. -// Learn more about theming and how to use it for your application's -// custom components at https://material.angular.dev/guide/theming @use '@angular/material' as mat; +:root { + --color-primary: #a8c243; + --color-text: #081839; + --color-text-secondary: #7a7a7a; + --color-background: #f7f8f6; + --color-surface: #ffffff; + --color-border: #e3e7df; + --color-step: #f0f3e8; + --font-body: 'Roboto', sans-serif; + --font-heading: 'Rajdhani', 'Roboto Condensed', 'Arial Narrow', sans-serif; +} + html { height: 100%; @include mat.theme( @@ -20,20 +27,21 @@ html { } body { - // Default the application to a light color theme. This can be changed to - // `dark` to enable the dark color theme, or to `light dark` to defer to the - // user's system settings. color-scheme: light; - - // Set a default background, font and text colors for the application using - // Angular Material's system-level CSS variables. Learn more about these - // variables at https://material.angular.dev/guide/system-variables - background-color: var(--mat-sys-surface); - color: var(--mat-sys-on-surface); - font: var(--mat-sys-body-medium); - - // Reset the user agent margin. + background: var(--color-background); + color: var(--color-text); + font-family: var(--font-body); margin: 0; - height: 100%; + min-height: 100%; +} + +*, +*::before, +*::after { + box-sizing: border-box; +} + +.information-upload-dialog-panel .mat-mdc-dialog-surface { + border-radius: 12px; + padding: 0; } -/* You can add global styles to this file, and also import other style files */