This commit is contained in:
Andras Schmelczer 2026-05-28 21:24:47 +01:00
parent 3ad2766f82
commit f74ee43cb4
196 changed files with 18949 additions and 32173 deletions

View file

@ -0,0 +1,25 @@
import { Injectable, computed, signal } from '@angular/core';
/**
* Shared counter of currently-open modals. Each `lt-modal` increments on
* mount and decrements on destroy. Consumers read `anyOpen` to react.
*
* Used by `page.component` to disable tower drag-and-drop while any modal
* (block-edit carousel, page-settings, tower-settings, confirm-delete,
* settings) is on screen otherwise the user can drag towers from behind
* the open card.
*/
@Injectable({ providedIn: 'root' })
export class ModalStateService {
private readonly _openCount = signal(0);
readonly anyOpen = computed(() => this._openCount() > 0);
open(): void {
this._openCount.update((n) => n + 1);
}
close(): void {
this._openCount.update((n) => Math.max(0, n - 1));
}
}