diff --git a/web/src/app/app.component.html b/web/src/app/app.component.html index 8494970..08a1171 100644 --- a/web/src/app/app.component.html +++ b/web/src/app/app.component.html @@ -25,6 +25,8 @@ DM Loremind } + + diff --git a/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.scss b/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.scss index bf33853..b187775 100644 --- a/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.scss +++ b/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.scss @@ -111,3 +111,41 @@ .shortcut-item-name { font-size: 0.8rem; font-weight: 500; } .shortcut-item-ctx { font-size: 0.7rem; color: #9ca3af; } + +// --- Mode compact (barre haute mobile) ---------------------------------------------- +:host(.compact) { + position: relative; + + .active-shortcut { margin-top: 0; } + + .shortcut-main { + justify-content: center; + gap: 0.3rem; + width: auto; + min-width: 44px; + height: 44px; + padding: 0 0.55rem; + } + + .live-dot { width: 10px; height: 10px; } + + .shortcut-list { + position: absolute; + top: calc(100% + 6px); + right: 0; + z-index: 30; + width: min(280px, calc(100vw - 2rem)); + padding: 0.4rem; + background: #0f0f1a; + border: 1px solid #2a2a45; + border-radius: 8px; + box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45); + } +} + +.compact-count { + font-size: 0.8rem; + font-weight: 700; + color: #d1fae5; + font-variant-numeric: tabular-nums; +} diff --git a/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.ts b/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.ts index 18d2494..127a572 100644 --- a/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.ts +++ b/web/src/app/sessions/active-session-shortcut/active-session-shortcut.component.ts @@ -1,4 +1,4 @@ -import { Component, DestroyRef, OnInit } from '@angular/core'; +import { Component, DestroyRef, ElementRef, HostBinding, HostListener, Input, OnInit, booleanAttribute } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { NavigationEnd, Router } from '@angular/router'; import { filter } from 'rxjs/operators'; @@ -11,8 +11,8 @@ import { ActiveSessionEntry, ActiveSessionsService } from '../../services/active * un clic y ramène depuis n'importe quel écran. Plusieurs séances (plusieurs tables) : * le bouton déplie la liste, la plus récente en tête. * - *

Composant autonome (styles propres) pour pouvoir le réutiliser tel quel dans la - * barre haute mobile.

+ *

Composant autonome (styles propres). En mode {@code compact} (barre haute mobile) : + * une pastille de 44 px, et la liste s'ouvre en menu déroulant (Échap / tap à côté la ferme).

*/ @Component({ selector: 'app-active-session-shortcut', @@ -24,6 +24,9 @@ export class ActiveSessionShortcutComponent implements OnInit { readonly ChevronDown = ChevronDown; readonly ChevronUp = ChevronUp; + /** Barre haute mobile : pastille seule, liste en menu déroulant. */ + @Input({ transform: booleanAttribute }) @HostBinding('class.compact') compact = false; + entries: ActiveSessionEntry[] = []; expanded = false; currentUrl = ''; @@ -31,7 +34,8 @@ export class ActiveSessionShortcutComponent implements OnInit { constructor( private activeSessions: ActiveSessionsService, private router: Router, - private destroyRef: DestroyRef + private destroyRef: DestroyRef, + private host: ElementRef ) {} ngOnInit(): void { @@ -50,6 +54,18 @@ export class ActiveSessionShortcutComponent implements OnInit { }); } + @HostListener('document:click', ['$event']) + onDocumentClick(event: MouseEvent): void { + if (this.compact && this.expanded && !this.host.nativeElement.contains(event.target as Node)) { + this.expanded = false; + } + } + + @HostListener('document:keydown.escape') + onEscape(): void { + if (this.expanded) this.expanded = false; + } + /** Une seule séance : on y va ; plusieurs : on déplie la liste. */ onMainClick(): void { if (this.entries.length === 1) {