From f36c9e8d52b08253041392b0be9845422adca005 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Thu, 7 Sep 2023 09:34:07 +1000 Subject: Improved dialog styling and made dialogs draggable --- Pages/Component/Dialog.razor | 55 ++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 38 deletions(-) (limited to 'Pages/Component/Dialog.razor') diff --git a/Pages/Component/Dialog.razor b/Pages/Component/Dialog.razor index e71ddc6..dbfec49 100644 --- a/Pages/Component/Dialog.razor +++ b/Pages/Component/Dialog.razor @@ -1,13 +1,20 @@ -@inject IDialogService dialogService +@inject IJSRuntime jsRuntime @implements IDialog -@implements IDisposable -
+ @code { @@ -26,49 +33,21 @@ get => visible; set { visible = value; - if(value) - Bump(); - StateHasChanged(); - } - } - - public int? ZIndex { - get => zIndex; - set { - zIndex = value; - StateHasChanged(); + jsRuntime.InvokeVoidAsync( + "setDialogVisibility", + new object?[] { dialogDiv, value }); } } private bool visible = false; - private int? zIndex; - private string? height; - protected override void OnInitialized() => - dialogService.Register(this); + private ElementReference dialogDiv; 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); } -- cgit v1.3