Remove unused modals service and display.

This commit is contained in:
2023-07-07 19:14:53 -05:00
parent 8884d15d6e
commit 3f318b46de
11 changed files with 11 additions and 135 deletions

View File

@@ -1,54 +0,0 @@
namespace Shogi.UI.Shared.Modal
{
/// <summary>
/// An injectible service which can be invoked to display preset modals via the <Modals /> razor component.
/// Only one modal me be visible at a time.
/// </summary>
public class ModalService
{
public event EventHandler<ModalVisibilityChangedEventArgs>? ModalVisibilityChangedEvent;
public ModalService()
{
}
public bool LoginModalIsVisible { get; private set; }
public bool GuestAccountDescriptionIsVisible { get; private set; }
public void ShowLoginModal()
{
SetAllVisibilitiesToFalse();
LoginModalIsVisible = true;
EmitCurrentState();
}
public void ShowGuestAccountDescriptionModal()
{
SetAllVisibilitiesToFalse();
GuestAccountDescriptionIsVisible = true;
EmitCurrentState();
}
public void HideAllModals()
{
SetAllVisibilitiesToFalse();
EmitCurrentState();
}
private void EmitCurrentState()
{
ModalVisibilityChangedEvent?.Invoke(this, new()
{
LoginModalIsVisible = LoginModalIsVisible,
GuestAccountDescriptionIsVisible = GuestAccountDescriptionIsVisible
});
}
private void SetAllVisibilitiesToFalse()
{
LoginModalIsVisible = false;
GuestAccountDescriptionIsVisible = false;
}
}
}

View File

@@ -1,9 +0,0 @@
namespace Shogi.UI.Shared.Modal
{
public class ModalVisibilityChangedEventArgs : EventArgs
{
public bool LoginModalIsVisible { get; set; }
public bool GuestAccountDescriptionIsVisible { get; set; }
}
}

View File

@@ -1,38 +0,0 @@
@inject ModalService modalService
@inject AccountManager Account
@inject NavigationManager NavManager
@inject ILocalStorage localStorage
@if (shouldShow)
{
<div class="my-modal-background">
<div class="my-modal">
@if (modalService.LoginModalIsVisible)
{
}
else if (modalService.GuestAccountDescriptionIsVisible)
{
}
</div>
</div>
}
@code {
bool shouldShow = false;
protected override void OnInitialized()
{
modalService.ModalVisibilityChangedEvent += OnModalChange;
}
void OnModalChange(object? sender, ModalVisibilityChangedEventArgs args)
{
if (args != null)
{
shouldShow = args.LoginModalIsVisible || args.GuestAccountDescriptionIsVisible;
StateHasChanged();
}
}
}

View File

@@ -1,21 +0,0 @@
.my-modal-background {
display: grid;
place-items: center;
position: fixed;
background-color: rgba(0,0,0,0.4);
inset: 0;
z-index: 900;
}
.my-modal {
text-align: center;
background-color: var(--contrast-color);
padding: 1rem;
max-width: 40rem;
}
.account-description {
display: grid;
grid-template-columns: 1fr max-content max-content;
column-gap: 1.5rem;
}