diff --git a/frontend/src/app/features/parents/children-tab.component.ts b/frontend/src/app/features/parents/children-tab.component.ts index b3b0cf7..c007fef 100644 --- a/frontend/src/app/features/parents/children-tab.component.ts +++ b/frontend/src/app/features/parents/children-tab.component.ts @@ -12,23 +12,73 @@ import { ChildSummary } from '../../core/models';

Nuevo niño/a

-
- - - - - - + + +
+ +
-

- La mascota es un emoji y el color identifica al niño en sus tarjetas. -

+ + +
+ +
+ @for (m of mascots; track m) { + + } +
+
+ + +
+ +
+ @for (c of colors; track c) { + + } +
+
+ + +
+
+ + +
+
+ + +
+
+ +
@@ -39,14 +89,78 @@ import { ChildSummary } from '../../core/models';
{{ c.mascot }} {{ c.name }} · {{ c.age }} años · 🪙 {{ c.coins }} - +
} @empty { -

Aún no hay niños. Añade el primero arriba ✨

+

Aún no hay niños. Crea el primero arriba ✨

}
`, + styles: [ + ` + .field { margin-bottom: var(--space-4); } + .field__label { + display: flex; + align-items: center; + gap: 6px; + font-weight: 700; + color: var(--text-1); + margin-bottom: 6px; + } + .field__opt { font-weight: 400; color: var(--text-3); } + .field__info { cursor: help; color: var(--text-4); font-size: 0.85rem; } + .field__input { + font-family: var(--font-body); + font-size: 1rem; + padding: 12px 14px; + border: 2px solid var(--border-2); + border-radius: var(--radius-sm); + background: var(--surface); + color: var(--text-strong); + width: 100%; + box-sizing: border-box; + } + .grid2 { + display: grid; + grid-template-columns: 1fr 1fr; + gap: var(--space-4); + } + @media (max-width: 520px) { + .grid2 { grid-template-columns: 1fr; } + } + .picker { display: flex; flex-wrap: wrap; gap: 8px; } + .emoji { + all: unset; + cursor: pointer; + width: 48px; + height: 48px; + border-radius: 14px; + display: flex; + align-items: center; + justify-content: center; + font-size: 26px; + background: var(--surface-soft); + border: 2px solid transparent; + transition: transform 0.1s, border-color 0.15s; + } + .emoji:hover { transform: scale(1.08); } + .emoji--sel { border-color: var(--accent-blue); background: color-mix(in srgb, var(--accent-blue) 12%, #fff); } + .swatch { + all: unset; + cursor: pointer; + width: 40px; + height: 40px; + border-radius: 50%; + box-shadow: var(--shadow-card); + border: 3px solid transparent; + transition: transform 0.1s; + } + .swatch:hover { transform: scale(1.1); } + .swatch--sel { border-color: var(--text-strong); transform: scale(1.1); } + .field__add { margin-top: var(--space-2); } + `, + ], }) export class ChildrenTabComponent { /** Avisa al panel de que la lista de niños cambió (para refrescar el selector). */ @@ -55,13 +169,17 @@ export class ChildrenTabComponent { private readonly api = inject(ParentApiService); protected readonly i18n = inject(I18nService); - protected readonly children = signal([]); + /** Emojis de mascota disponibles para elegir. */ + protected readonly mascots = ['🦊', '🐢', '🦉', '🐶', '🐱', '🐰', '🦁', '🐼', '🐸', '🐨', '🐵', '🦄', '🐯', '🐧']; + /** Paleta de acento del handoff. */ + protected readonly colors = ['#F2A65A', '#5B8DEF', '#A78BD0', '#7FBF6B', '#5BC0BE', '#F4C95D', '#EC8FA4']; - protected mascot = ''; + protected readonly children = signal([]); + protected readonly mascot = signal(''); + protected readonly accentColor = signal('#F2A65A'); protected name = ''; protected age: number | null = null; protected departureTime = ''; - protected accentColor = '#F2A65A'; constructor() { this.reload(); @@ -71,21 +189,29 @@ export class ChildrenTabComponent { this.api.listChildren().subscribe((list) => this.children.set(list)); } + /** Se puede dar de alta cuando hay nombre, mascota y una edad válida. */ + canAdd(): boolean { + return this.name.trim().length > 0 && this.mascot() !== '' && !!this.age && this.age > 0; + } + add(): void { - if (!this.name || !this.mascot || !this.age) { + if (!this.canAdd()) { return; } this.api .createChild({ - name: this.name, - mascot: this.mascot, - accentColor: this.accentColor, - age: this.age, + name: this.name.trim(), + mascot: this.mascot(), + accentColor: this.accentColor(), + age: this.age!, departureTime: this.departureTime || undefined, }) .subscribe(() => { - this.name = this.mascot = this.departureTime = ''; + this.name = ''; + this.mascot.set(''); this.age = null; + this.departureTime = ''; + this.accentColor.set('#F2A65A'); this.reload(); this.changed.emit(); });