refactor(ui/shared): scroll-lock, escape, aria-live, responsive sidebar
ConfirmDialog locks body scroll via IJSRuntime + Bootstrap's modal-open class on show, restores on hide. Escape key now closes the dialog; default ConfirmButtonClass flipped from btn-danger to btn-primary so non-destructive confirms aren't red. Destructive callsites (Delete, Discard) get explicit ConfirmButtonClass="btn-danger". ToastNotification adds aria-live="polite" + aria-atomic="true" on the container and an optional autoDismissMs parameter on every Show* method. LoadingSpinner text-muted -> text-secondary for contrast. DataTable gains a clear (x) button on the search input and applies disabled / aria-disabled directly to the pagination buttons. NewFolderDialog splits backdrop and modal markup to match ConfirmDialog. NavMenu wraps the nav list in an overflow-y scroll container so the username/sign-out footer stays anchored, and section headers convert from <li> to <div role="presentation">. MainLayout adds a hamburger toggle for <lg viewports; sidebar collapses via Bootstrap collapse data attributes. App.razor extracts inline <style> block to a shared site.css; adds a left-border accent on the active nav link; switches the reconnect modal to modal-dialog-centered. Login uses d-flex / min-vh-100 centering. NotAuthorizedView gets the same centered layout plus the ScadaLink brand heading. Sites.razor: only the new ConfirmButtonClass="btn-danger" follow-up.
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
@* Reusable toast notification component *@
|
||||
@*
|
||||
Reusable toast notification component.
|
||||
|
||||
z-index ladder:
|
||||
Toast container 1090 (this component, on top)
|
||||
ConfirmDialog modal element 1055 (Bootstrap default for .modal)
|
||||
ConfirmDialog backdrop 1040 (Bootstrap default for .modal-backdrop)
|
||||
|
||||
Toasts intentionally float above ConfirmDialog so confirmation feedback
|
||||
(Success/Error) is visible even while a dialog is open.
|
||||
*@
|
||||
@implements IDisposable
|
||||
|
||||
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1090;">
|
||||
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1090;" aria-live="polite" aria-atomic="true">
|
||||
@foreach (var toast in _toasts)
|
||||
{
|
||||
<div class="toast show mb-2" role="alert">
|
||||
@@ -15,30 +25,32 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private const int DefaultAutoDismissMs = 5000;
|
||||
|
||||
private readonly List<ToastItem> _toasts = new();
|
||||
private readonly object _lock = new();
|
||||
|
||||
public void ShowSuccess(string message, string title = "Success")
|
||||
public void ShowSuccess(string message, string title = "Success", int? autoDismissMs = null)
|
||||
{
|
||||
AddToast(title, message, ToastType.Success);
|
||||
AddToast(title, message, ToastType.Success, autoDismissMs);
|
||||
}
|
||||
|
||||
public void ShowError(string message, string title = "Error")
|
||||
public void ShowError(string message, string title = "Error", int? autoDismissMs = null)
|
||||
{
|
||||
AddToast(title, message, ToastType.Error);
|
||||
AddToast(title, message, ToastType.Error, autoDismissMs);
|
||||
}
|
||||
|
||||
public void ShowWarning(string message, string title = "Warning")
|
||||
public void ShowWarning(string message, string title = "Warning", int? autoDismissMs = null)
|
||||
{
|
||||
AddToast(title, message, ToastType.Warning);
|
||||
AddToast(title, message, ToastType.Warning, autoDismissMs);
|
||||
}
|
||||
|
||||
public void ShowInfo(string message, string title = "Info")
|
||||
public void ShowInfo(string message, string title = "Info", int? autoDismissMs = null)
|
||||
{
|
||||
AddToast(title, message, ToastType.Info);
|
||||
AddToast(title, message, ToastType.Info, autoDismissMs);
|
||||
}
|
||||
|
||||
private void AddToast(string title, string message, ToastType type)
|
||||
private void AddToast(string title, string message, ToastType type, int? autoDismissMs)
|
||||
{
|
||||
var toast = new ToastItem { Title = title, Message = message, Type = type };
|
||||
lock (_lock)
|
||||
@@ -47,8 +59,8 @@
|
||||
}
|
||||
StateHasChanged();
|
||||
|
||||
// Auto-dismiss after 5 seconds
|
||||
_ = Task.Delay(5000).ContinueWith(_ =>
|
||||
var dismissMs = autoDismissMs ?? DefaultAutoDismissMs;
|
||||
_ = Task.Delay(dismissMs).ContinueWith(_ =>
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user