about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/ModalWindow.razor
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--MatrixRoomUtils.Web/Shared/ModalWindow.razor86
-rw-r--r--MatrixRoomUtils.Web/Shared/ModalWindow.razor.css70
2 files changed, 0 insertions, 156 deletions
diff --git a/MatrixRoomUtils.Web/Shared/ModalWindow.razor b/MatrixRoomUtils.Web/Shared/ModalWindow.razor
deleted file mode 100644

index beb7198..0000000 --- a/MatrixRoomUtils.Web/Shared/ModalWindow.razor +++ /dev/null
@@ -1,86 +0,0 @@ -@using LibMatrix.Extensions -<div class="r-modal" style="top: @(_y)px; left: @(_x)px;"> - <div class="titlebar" @onmousedown="MouseDown" @onmouseup="MouseUp" @onmousemove="MouseMove" @onmouseleave="MouseMove"> - <b class="title" @ref="_titleRef">@Title</b> - <button class="btnclose" @onclick="OnCloseClicked">X</button> - <button class="btncollapse" @onclick="@(() => Collapsed = !Collapsed)">_</button> - </div> - <div class="r-modal-content" style="@((Collapsed ? "height: 0px;" : "") + $"min-width: {MinWidth}px;")"> - @ChildContent - </div> -</div> - -@code { - - [Parameter] - public RenderFragment? ChildContent { get; set; } - - [Parameter] - public string Title { get; set; } = "Untitled window"; - - [Parameter] - public double X { get; set; } = 60; - - [Parameter] - public double Y { get; set; } = 60; - - [Parameter] - public double MinWidth { get; set; } = 100; - - [Parameter] - public Action OnCloseClicked { get; set; } - - [Parameter] - public bool Collapsed { get; set; } = false; - - private ElementReference _titleRef; - - private double _x = 60; - private double _y = 60; - - protected override async Task OnInitializedAsync() { - _x = X; - _y = Y; - await base.OnInitializedAsync(); - } - - protected override async Task OnAfterRenderAsync(bool firstRender) { - //set minwidth to title width - MinWidth = await JSRuntime.InvokeAsync<int>("getWidth", _titleRef) + 75; - await base.OnAfterRenderAsync(firstRender); - } - - private void WindowDrag(DragEventArgs obj) { - Console.WriteLine("Drag: " + obj.ToJson()); - - _x += obj.MovementX; - _y += obj.MovementY; - - StateHasChanged(); - } - - private bool isDragging = false; - private double dragX = 0; - private double dragY = 0; - - private void MouseDown(MouseEventArgs obj) { - isDragging = true; - dragX = obj.ClientX; - dragY = obj.ClientY; - } - - private void MouseUp(MouseEventArgs obj) { - isDragging = false; - } - - private void MouseMove(MouseEventArgs obj) { - if (!isDragging) return; - - _x += obj.ClientX - dragX; - _y += obj.ClientY - dragY; - dragX = obj.ClientX; - dragY = obj.ClientY; - StateHasChanged(); - } - -} diff --git a/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css b/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css deleted file mode 100644
index 6d08114..0000000 --- a/MatrixRoomUtils.Web/Shared/ModalWindow.razor.css +++ /dev/null
@@ -1,70 +0,0 @@ -.r-modal { - position: absolute; - width: fit-content; - height: fit-content; - z-index: 1000; -} -.r-modal:hover { - z-index: 1001; -} - -.r-modal > .titlebar { - position: absolute; - display: block; - top: 0; - left: 0; - width: 100%; - height: 25px; - background-color: #000; - user-select: none; -} - -.r-modal > .titlebar > .title { - position: relative; - top: 0; - left: 0; - width: fit-content; - text-wrap: nowrap; - height: 100%; - line-height: 25px; - padding-left: 10px; - color: #fff; -} - -.r-modal > .titlebar > .btnclose { - position: absolute; - top: 0; - right: 0; - width: 25px; - height: 100%; - line-height: 25px; - text-align: center; - color: #fff; - background-color: #111; - cursor: pointer; -} -.r-modal > .titlebar > .btncollapse { - position: absolute; - top: 0; - right: 25px; - width: 25px; - height: 100%; - line-height: 25px; - text-align: center; - color: #fff; - background-color: #111; - cursor: pointer; -} - -.r-modal > .r-modal-content { - position: relative; - top: 25px; - left: 0; - width: fit-content; - height: fit-content; - min-width: 150px; - max-width: 75vw; - max-height: 75vh; - overflow: auto; - background-color: #111; -}