feat: application shell, localized texts and user preferences (M3, part 1)

The pages built so far now live inside the shell of the mockups instead of the
M0 placeholder, every interface text comes from Resources/it-IT, and each user
keeps their own look and start page.

- Shell: top bar, collapsible side menu with fly-out sub-menus, status bar and
  tabs that keep each page alive (page type and route values per tab, so a tab
  never shows another page); at most 12 tabs, least-used clean tab evicted.
- One shortcut table with Alt variants for the combinations browsers keep
  (Ctrl+W, Ctrl+Tab, Ctrl+N); command palette for pages and commands.
- ITexts over embedded JSON; tests forbid literal texts in .razor components
  and check that every key used exists.
- User settings in sys_user_settings / user_settings; theme written on the
  server; profile page with live preview, start page, sessions and shortcuts.
- Home, coming-soon pages for later milestones, localized sign-in and error
  pages; ADR 0020; wiki, CHANGELOG, STATUS and data model updated.

Refs #25 #26 #31 #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 16:44:59 +01:00
1 parent 1c30054e3d
commit cf6f849cc1
72 files changed
+5785 -259

No files matched your search

+108
View File
@@ -0,0 +1,108 @@
namespace Khaemhat.Web.Shell;
/// <summary>The weight of a toast.</summary>
public enum ToastKind
{
/// <summary>Information.</summary>
Info = 0,
/// <summary>Done.</summary>
Success = 1,
/// <summary>Attention.</summary>
Warning = 2,
/// <summary>Failure.</summary>
Error = 3,
}
/// <summary>A short message in the bottom right corner (SPEC §10.7 <c>KhToast</c>).</summary>
/// <param name="Id">The identifier.</param>
/// <param name="Kind">The weight.</param>
/// <param name="Title">The title.</param>
/// <param name="Text">The text, or <see langword="null"/>.</param>
public sealed record Toast(Guid Id, ToastKind Kind, string Title, string? Text);
/// <summary>Shows toasts; <c>KhToastHost</c> in the layout renders them and removes them after a few seconds.</summary>
public sealed class ToastService
{
private readonly List<Toast> _toasts = [];
/// <summary>Raised when toasts appear or go.</summary>
public event Action? Changed;
/// <summary>The toasts on screen.</summary>
public IReadOnlyList<Toast> Toasts => _toasts;
/// <summary>Shows a toast.</summary>
/// <param name="kind">The weight.</param>
/// <param name="title">The title.</param>
/// <param name="text">The text.</param>
/// <returns>The toast.</returns>
public Toast Show(ToastKind kind, string title, string? text = null)
{
var toast = new Toast(Guid.NewGuid(), kind, title, text);
_toasts.Add(toast);
if (_toasts.Count > 5)
{
_toasts.RemoveAt(0);
}
Changed?.Invoke();
return toast;
}
/// <summary>Removes a toast.</summary>
/// <param name="id">The toast.</param>
public void Dismiss(Guid id)
{
if (_toasts.RemoveAll(t => t.Id == id) > 0)
{
Changed?.Invoke();
}
}
}
/// <summary>A question that needs a yes or no (SPEC §10.7 <c>KhConfirm</c>).</summary>
/// <param name="Title">The title.</param>
/// <param name="Text">The question.</param>
/// <param name="ConfirmText">The text of the confirming button.</param>
/// <param name="CancelText">The text of the cancelling button.</param>
/// <param name="Danger">Whether confirming destroys something (red button).</param>
public sealed record ConfirmRequest(string Title, string Text, string ConfirmText, string CancelText, bool Danger = false);
/// <summary>Asks confirmations; <c>KhDialogHost</c> in the layout shows them one at a time.</summary>
public sealed class DialogService
{
private TaskCompletionSource<bool>? _pending;
/// <summary>Raised when a question appears or is answered.</summary>
public event Action? Changed;
/// <summary>The question on screen, or <see langword="null"/>.</summary>
public ConfirmRequest? Current { get; private set; }
/// <summary>Asks a question and waits for the answer.</summary>
/// <param name="request">The question.</param>
/// <returns><see langword="true"/> when the user confirms.</returns>
public Task<bool> ConfirmAsync(ConfirmRequest request)
{
ArgumentNullException.ThrowIfNull(request);
_pending?.TrySetResult(false);
_pending = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
Current = request;
Changed?.Invoke();
return _pending.Task;
}
/// <summary>Called by the dialog with the answer.</summary>
/// <param name="confirmed">The answer.</param>
public void Answer(bool confirmed)
{
var pending = _pending;
_pending = null;
Current = null;
Changed?.Invoke();
pending?.TrySetResult(confirmed);
}
}