diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-09-06 12:22:27 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2023-09-06 12:22:27 +1000 |
| commit | 013c841bf30771b04173cfeefe4e1d16d1127dea (patch) | |
| tree | f85d29a1eb3a8b7aa3ae13c578455c998099fa77 /Pages/Component/Dialog.razor | |
| parent | 09a50794b5f4011db547d1fbf18d4c835a3c620b (diff) | |
Added DialogService to manage dialog z-indexes
Diffstat (limited to 'Pages/Component/Dialog.razor')
| -rw-r--r-- | Pages/Component/Dialog.razor | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/Pages/Component/Dialog.razor b/Pages/Component/Dialog.razor index f479368..e71ddc6 100644 --- a/Pages/Component/Dialog.razor +++ b/Pages/Component/Dialog.razor @@ -1,6 +1,8 @@ -@implements IDialog +@inject IDialogService dialogService +@implements IDialog +@implements IDisposable -<div style="@(heightStyle + visiblilityStyle)"> +<div @onclick=Bump style="@(style)"> @if(Title is not null) { <p>@Title</p> <hr/> @@ -24,20 +26,49 @@ get => visible; set { visible = value; + if(value) + Bump(); StateHasChanged(); } } - public void Show() => Visible = true; - public void Hide() => Visible = false; + public int? ZIndex { + get => zIndex; + set { + zIndex = value; + StateHasChanged(); + } + } private bool visible = false; + private int? zIndex; + private string? height; + protected override void OnInitialized() => + dialogService.Register(this); + + public void Show() => Visible = true; + public void Hide() => Visible = false; + + private void Bump() => + dialogService.BumpZIndex(this); + + private string style => + zIndexStyle + + heightStyle + + visiblilityStyle; + + private string zIndexStyle => + zIndex is null ? "display:none;" : $"z-index:{zIndex};"; + private string heightStyle => $"{(height is null ? "" : $"max-height:{height};")}"; private string visiblilityStyle => Visible ? "opacity:1;visibility:visible;" : "opacity:0;visibility:hidden;"; + + public void Dispose() => + dialogService.Unregister(this); } |
