summaryrefslogtreecommitdiff
path: root/Pages/Component/Dialog.razor
diff options
context:
space:
mode:
Diffstat (limited to 'Pages/Component/Dialog.razor')
-rw-r--r--Pages/Component/Dialog.razor70
1 files changed, 0 insertions, 70 deletions
diff --git a/Pages/Component/Dialog.razor b/Pages/Component/Dialog.razor
deleted file mode 100644
index 673ec2f..0000000
--- a/Pages/Component/Dialog.razor
+++ /dev/null
@@ -1,70 +0,0 @@
-@inject IJSRuntime jsRuntime
-@implements IDialog
-
-<div
- class="dialog"
- onmousedown="dialogMouseDown(event)"
- style="opacity:0;visibility:hidden;@(heightStyle)"
- @ref=dialogDiv>
- @if(Title is not null) {
- <div class="titlebar" onmousedown="dialogTitleMouseDown(event)">
- <p class="title">@Title</p>
- <hr/>
- </div>
- }
- <div class="content">
- @ChildContent
- </div>
-</div>
-
-@code {
- [Parameter]
- public string? Title { get; set; }
-
- [Parameter]
- public RenderFragment ChildContent { get; set; }
-
- [Parameter]
- public int HeightPixels { set => height = $"{value}px"; }
- [Parameter]
- public int HeightPercent { set => height = $"{value}%"; }
-
- public bool Visible {
- get => visible;
- set {
- visible = value;
- jsRuntime.InvokeVoidAsync(
- "setDialogVisibility",
- new object?[] { dialogDiv, value });
- }
- }
-
- private bool visible = false;
-
- private string? height;
-
- private ElementReference dialogDiv;
-
- public void Show() => Visible = true;
- public void Hide() => Visible = false;
-
- protected override async void OnAfterRender(bool firstRender) {
- if(firstRender) {
- await jsRuntime.InvokeVoidAsync("dialogAddObjectReference", new object[] {
- dialogDiv,
- DotNetObjectReference.Create(this)
- });
- }
- }
-
- [JSInvokable("KeyHandler")]
- public void KeyHandler(string key) {
- if(key == "Escape") {
- Hide();
- return;
- }
- }
-
- private string heightStyle =>
- $"{(height is null ? "" : $"max-height:{height};")}";
-}