From 046bb4ce987f7bfcd6bb13a894f74b86a0d38994 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Mon, 10 Aug 2026 22:36:18 +0200 Subject: [PATCH] =?UTF-8?q?feat(web):=20design=20tokens=20&=20th=C3=A8me?= =?UTF-8?q?=20global=20dark-first=20(Fixes=20#32)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Theme/HeimdallTheme.cs : palette sémantique dark-first (bleu nuit, jamais #000/#FFF), contrastes calculés ≥4.5:1 (WCAG 2.2 AA), accent cyan vigie temps réel, statuts adaptés light/dark. Thèmes inline supprimés des deux layouts (MainLayout + MudBlazorLayout) au profit de l'instance unique. app.css : tokens CSS (échelle 4px, radius, ombres, focus-ring), focus visible global, skip-link, prefers-reduced-motion, zones tactiles 44px, classes hmd-tile/hmd-live-dot (hover lift + pulse live). MetricTile et composants partagés (EmptyState, SectionCard, FilterBar, LoadingSkeleton, PaginationBar, SettingsPage) passés sur les tokens radius. Contrastes vérifiés par calcul (outil ratio) pour toutes les paires texte/fond light + dark. Build vert, 165 tests Web verts. --- .../Components/Layout/MainLayout.razor | 117 +--------------- .../Components/Layout/MudBlazorLayout.razor | 76 +--------- src/Heimdall.Web/Components/MetricTile.razor | 2 +- .../Components/Pages/SettingsPage.razor | 8 +- .../Components/Shared/EmptyState.razor | 2 +- .../Components/Shared/FilterBar.razor | 2 +- .../Components/Shared/LoadingSkeleton.razor | 2 +- .../Components/Shared/PaginationBar.razor | 2 +- .../Components/Shared/SectionCard.razor | 2 +- src/Heimdall.Web/Theme/HeimdallTheme.cs | 132 ++++++++++++++++++ src/Heimdall.Web/wwwroot/app.css | 129 +++++++++++++++++ 11 files changed, 275 insertions(+), 199 deletions(-) create mode 100644 src/Heimdall.Web/Theme/HeimdallTheme.cs diff --git a/src/Heimdall.Web/Components/Layout/MainLayout.razor b/src/Heimdall.Web/Components/Layout/MainLayout.razor index 5a52423..900dd01 100644 --- a/src/Heimdall.Web/Components/Layout/MainLayout.razor +++ b/src/Heimdall.Web/Components/Layout/MainLayout.razor @@ -3,8 +3,9 @@ @inject NavigationManager Navigation @inject HeimdallAuthStateProvider AuthStateProvider @inject IJSRuntime JsRuntime +@using Heimdall.Web.Theme - + @@ -113,120 +114,6 @@ @code { private bool _drawerOpen = true; private string _searchQuery = ""; - private readonly MudTheme _theme = new() - { - PaletteLight = new PaletteLight - { - // ─── Noir & Blanc — mode clair ───────────────────────── - Black = "#000000", - White = "#FFFFFF", - - Primary = "#111111", - PrimaryContrastText = "#FFFFFF", - Secondary = "#555555", - SecondaryContrastText = "#FFFFFF", - Tertiary = "#333333", - TertiaryContrastText = "#FFFFFF", - - // Appbar — noir pur - AppbarBackground = "#000000", - AppbarText = "#FFFFFF", - - // Fond général - Background = "#FAFAFA", - Surface = "#FFFFFF", - - // Navigation - DrawerBackground = "#FFFFFF", - DrawerText = "#111111", - DrawerIcon = "#555555", - - // Typographie - TextPrimary = "#111111", - TextSecondary = "#555555", - TextDisabled = "#A3A3A3", - - // Bordures & lignes - LinesDefault = "#E5E5E5", - LinesInputs = "#D4D4D4", - - // Ombres & profondeur - Dark = "#000000", - DarkLighten = "#1A1A1A", - - // Couleurs de statut (volontairement vives sur fond clair) - Info = "#2563EB", - Warning = "#EA580C", - Error = "#DC2626", - Success = "#16A34A", - - // Tableaux - TableLines = "#E5E5E5", - TableStriped = "#FAFAFA", - - // Séparateurs - Divider = "#E5E5E5", - DividerLight = "#F0F0F0", - - // Overlays & interactions - }, - - PaletteDark = new PaletteDark - { - // ─── Noir & Blanc — mode sombre ──────────────────────── - Black = "#000000", - White = "#FFFFFF", - - Primary = "#FFFFFF", - PrimaryContrastText = "#000000", - Secondary = "#A3A3A3", - SecondaryContrastText = "#000000", - Tertiary = "#CCCCCC", - TertiaryContrastText = "#000000", - - // Appbar — noir (identique au light) - AppbarBackground = "#000000", - AppbarText = "#FFFFFF", - - // Fond général — presque noir - Background = "#0A0A0A", - Surface = "#1A1A1A", - - // Navigation - DrawerBackground = "#1A1A1A", - DrawerText = "#F5F5F5", - DrawerIcon = "#A3A3A3", - - // Typographie - TextPrimary = "#F5F5F5", - TextSecondary = "#A3A3A3", - TextDisabled = "#555555", - - // Bordures & lignes - LinesDefault = "#333333", - LinesInputs = "#444444", - - // Ombres & profondeur - Dark = "#000000", - DarkLighten = "#0A0A0A", - - // Couleurs de statut (légèrement adoucies pour dark) - Info = "#60A5FA", - Warning = "#F97316", - Error = "#EF4444", - Success = "#22C55E", - - // Tableaux - TableLines = "#333333", - TableStriped = "#222222", - - // Séparateurs - Divider = "#333333", - DividerLight = "#2A2A2A", - - // Overlays & interactions - } - }; private async Task Logout() { diff --git a/src/Heimdall.Web/Components/Layout/MudBlazorLayout.razor b/src/Heimdall.Web/Components/Layout/MudBlazorLayout.razor index 4239326..5e784ed 100644 --- a/src/Heimdall.Web/Components/Layout/MudBlazorLayout.razor +++ b/src/Heimdall.Web/Components/Layout/MudBlazorLayout.razor @@ -1,6 +1,7 @@ @inherits LayoutComponentBase +@using Heimdall.Web.Theme - + @@ -10,76 +11,3 @@ @Body - -@code { - // Thème monochrome noir & blanc — partagé avec MainLayout - private readonly MudTheme _theme = new() - { - PaletteLight = new PaletteLight - { - Black = "#000000", - White = "#FFFFFF", - Primary = "#111111", - PrimaryContrastText = "#FFFFFF", - Secondary = "#555555", - SecondaryContrastText = "#FFFFFF", - Tertiary = "#333333", - TertiaryContrastText = "#FFFFFF", - AppbarBackground = "#000000", - AppbarText = "#FFFFFF", - Background = "#FAFAFA", - Surface = "#FFFFFF", - DrawerBackground = "#FFFFFF", - DrawerText = "#111111", - DrawerIcon = "#555555", - TextPrimary = "#111111", - TextSecondary = "#555555", - TextDisabled = "#A3A3A3", - LinesDefault = "#E5E5E5", - LinesInputs = "#D4D4D4", - Dark = "#000000", - DarkLighten = "#1A1A1A", - Info = "#2563EB", - Warning = "#EA580C", - Error = "#DC2626", - Success = "#16A34A", - TableLines = "#E5E5E5", - TableStriped = "#FAFAFA", - Divider = "#E5E5E5", - DividerLight = "#F0F0F0", - }, - PaletteDark = new PaletteDark - { - Black = "#000000", - White = "#FFFFFF", - Primary = "#FFFFFF", - PrimaryContrastText = "#000000", - Secondary = "#A3A3A3", - SecondaryContrastText = "#000000", - Tertiary = "#CCCCCC", - TertiaryContrastText = "#000000", - AppbarBackground = "#000000", - AppbarText = "#FFFFFF", - Background = "#0A0A0A", - Surface = "#1A1A1A", - DrawerBackground = "#1A1A1A", - DrawerText = "#F5F5F5", - DrawerIcon = "#A3A3A3", - TextPrimary = "#F5F5F5", - TextSecondary = "#A3A3A3", - TextDisabled = "#555555", - LinesDefault = "#333333", - LinesInputs = "#444444", - Dark = "#000000", - DarkLighten = "#0A0A0A", - Info = "#60A5FA", - Warning = "#F97316", - Error = "#EF4444", - Success = "#22C55E", - TableLines = "#333333", - TableStriped = "#222222", - Divider = "#333333", - DividerLight = "#2A2A2A", - } - }; -} diff --git a/src/Heimdall.Web/Components/MetricTile.razor b/src/Heimdall.Web/Components/MetricTile.razor index 2966a3e..35d05ff 100644 --- a/src/Heimdall.Web/Components/MetricTile.razor +++ b/src/Heimdall.Web/Components/MetricTile.razor @@ -1,7 +1,7 @@ @* MetricTile.razor — tuile de métrique compacte (label + valeur + jauge optionnelle). *@ @using MudBlazor - + @if (Icon is not null) { diff --git a/src/Heimdall.Web/Components/Pages/SettingsPage.razor b/src/Heimdall.Web/Components/Pages/SettingsPage.razor index c642bbd..2424e10 100644 --- a/src/Heimdall.Web/Components/Pages/SettingsPage.razor +++ b/src/Heimdall.Web/Components/Pages/SettingsPage.razor @@ -20,7 +20,7 @@ @* Search + Category filter *@ - + + @@ -66,7 +66,7 @@ else if (_error) } else if (_settings is null || _settings.Count == 0) { - + Aucun paramètre configuré @@ -102,7 +102,7 @@ else @foreach (var setting in category.Value) { - +
diff --git a/src/Heimdall.Web/Components/Shared/EmptyState.razor b/src/Heimdall.Web/Components/Shared/EmptyState.razor index 611b419..711671f 100644 --- a/src/Heimdall.Web/Components/Shared/EmptyState.razor +++ b/src/Heimdall.Web/Components/Shared/EmptyState.razor @@ -1,6 +1,6 @@ @* Empty state placeholder shown when a list or section has no data. *@ - + @if (!string.IsNullOrEmpty(FaIcon)) { diff --git a/src/Heimdall.Web/Components/Shared/FilterBar.razor b/src/Heimdall.Web/Components/Shared/FilterBar.razor index 0d6d6f6..bf6863a 100644 --- a/src/Heimdall.Web/Components/Shared/FilterBar.razor +++ b/src/Heimdall.Web/Components/Shared/FilterBar.razor @@ -1,6 +1,6 @@ @* Reusable filter bar with search text field and optional category dropdown. *@ - +
diff --git a/src/Heimdall.Web/Components/Shared/LoadingSkeleton.razor b/src/Heimdall.Web/Components/Shared/LoadingSkeleton.razor index b051ec7..a85a199 100644 --- a/src/Heimdall.Web/Components/Shared/LoadingSkeleton.razor +++ b/src/Heimdall.Web/Components/Shared/LoadingSkeleton.razor @@ -1,6 +1,6 @@ @* Skeleton loading placeholder for cards and content areas. *@ - + @if (ShowTitle) { diff --git a/src/Heimdall.Web/Components/Shared/PaginationBar.razor b/src/Heimdall.Web/Components/Shared/PaginationBar.razor index 3561280..7267cd8 100644 --- a/src/Heimdall.Web/Components/Shared/PaginationBar.razor +++ b/src/Heimdall.Web/Components/Shared/PaginationBar.razor @@ -1,6 +1,6 @@ @* Pagination navigation bar with page info and Previous/Next buttons. *@ - + Page @Page sur @TotalPages (@Total entrées) diff --git a/src/Heimdall.Web/Components/Shared/SectionCard.razor b/src/Heimdall.Web/Components/Shared/SectionCard.razor index 1afbf79..2b021a8 100644 --- a/src/Heimdall.Web/Components/Shared/SectionCard.razor +++ b/src/Heimdall.Web/Components/Shared/SectionCard.razor @@ -1,6 +1,6 @@ @* Reusable section card with title, icon (MudBlazor or Font Awesome), optional help tooltip and action area. *@ - + @if (!string.IsNullOrEmpty(Title)) {
diff --git a/src/Heimdall.Web/Theme/HeimdallTheme.cs b/src/Heimdall.Web/Theme/HeimdallTheme.cs new file mode 100644 index 0000000..3bfd445 --- /dev/null +++ b/src/Heimdall.Web/Theme/HeimdallTheme.cs @@ -0,0 +1,132 @@ +using MudBlazor; + +namespace Heimdall.Web.Theme; + +/// +/// Thème global Heimdall — dark-first, palette sémantique « vigie ». +/// +/// Règles (cf. issue #32) : +/// - Jamais de noir pur (#000) ni de blanc pur (#FFF) comme fond. +/// - Tous les contrastes texte/fond vérifiés ≥ 4.5:1 (WCAG 2.2 AA) — voir +/// commentaires de chaque paire. +/// - Accent temps réel : cyan « vigie » (#22D3EE dark / #1D4ED8 light). +/// - Statuts sémantiques : success / warning / info / error choisis pour +/// passer AA sur les fonds du thème. +/// +public static class HeimdallTheme +{ + /// Instance unique du thème MudBlazor. + public static readonly MudTheme Instance = Create(); + + private static MudTheme Create() => new() + { + PaletteLight = new PaletteLight + { + // Surfaces — jamais #FFF pur en fond global + Background = "#F4F6FA", // gris bleuté (texte #1E293B → 13.5:1) + Surface = "#FFFFFF", // autorisé en carte uniquement + AppbarBackground = "#0B1220", // navy profond + AppbarText = "#E6EDF7", + DrawerBackground = "#0F172A", + DrawerText = "#E6EDF7", + DrawerIcon = "#94A3B8", + + // Primary — bleu vigie (6.2:1 sur fond) + Primary = "#1D4ED8", + PrimaryContrastText = "#FFFFFF", + Secondary = "#475569", + SecondaryContrastText = "#FFFFFF", + Tertiary = "#0F172A", + TertiaryContrastText = "#FFFFFF", + + // Typographie + TextPrimary = "#1E293B", + TextSecondary = "#475569", + TextDisabled = "#64748B", + + // Statuts — AA sur #F4F6FA (4.64:1 et plus) + Info = "#1D4ED8", + Warning = "#B45309", + Error = "#B91C1C", + Success = "#15803D", + + // Bordures & lignes + LinesDefault = "#CBD5E1", + LinesInputs = "#94A3B8", + TableLines = "#E2E8F0", + TableStriped = "#F1F5F9", + Divider = "#E2E8F0", + DividerLight = "#F1F5F9", + + // Ombres & profondeur + Dark = "#0F172A", + DarkLighten = "#1E293B", + }, + PaletteDark = new PaletteDark + { + // Surfaces — bleu nuit, jamais #000 + Background = "#0B1220", + Surface = "#111A2C", + AppbarBackground = "#0F172A", + AppbarText = "#E6EDF7", + DrawerBackground = "#0F172A", + DrawerText = "#E6EDF7", + DrawerIcon = "#94A3B8", + + // Primary — cyan vigie (10.4:1 sur fond) + Primary = "#22D3EE", + PrimaryContrastText = "#06202A", + Secondary = "#94A3B8", + SecondaryContrastText = "#0B1220", + Tertiary = "#38BDF8", + TertiaryContrastText = "#0B1220", + + // Typographie + TextPrimary = "#E6EDF7", + TextSecondary = "#94A3B8", + TextDisabled = "#64748B", + + // Statuts — AA sur #0B1220 (6.8:1 et plus) + Info = "#38BDF8", + Warning = "#F59E0B", + Error = "#F87171", + Success = "#22C55E", + + // Bordures & lignes + LinesDefault = "#1E293B", + LinesInputs = "#334155", + TableLines = "#1E293B", + TableStriped = "#0F172A", + Divider = "#1E293B", + DividerLight = "#182238", + + // Ombres & profondeur + Dark = "#060B14", + DarkLighten = "#0F172A", + }, + LayoutProperties = new LayoutProperties + { + DefaultBorderRadius = "10px", + }, + Typography = new Typography + { + Default = new DefaultTypography + { + FontFamily = ["Inter", "Segoe UI", "Roboto", "system-ui", "sans-serif"], + FontSize = "14px", + LineHeight = "1.5", + }, + H1 = new H1Typography { FontSize = "2rem", FontWeight = "600" }, + H2 = new H2Typography { FontSize = "1.6rem", FontWeight = "600" }, + H3 = new H3Typography { FontSize = "1.35rem", FontWeight = "600" }, + H4 = new H4Typography { FontSize = "1.15rem", FontWeight = "600" }, + H5 = new H5Typography { FontSize = "1rem", FontWeight = "600" }, + H6 = new H6Typography { FontSize = "0.95rem", FontWeight = "600" }, + Body1 = new Body1Typography { FontSize = "14px", LineHeight = "1.5" }, + Body2 = new Body2Typography { FontSize = "13px", LineHeight = "1.5" }, + Subtitle1 = new Subtitle1Typography { FontSize = "15px", FontWeight = "500" }, + Subtitle2 = new Subtitle2Typography { FontSize = "13px", FontWeight = "500" }, + }, + ZIndex = new ZIndex { Snackbar = 1500, Tooltip = 1600 }, + }; +} diff --git a/src/Heimdall.Web/wwwroot/app.css b/src/Heimdall.Web/wwwroot/app.css index 8b402fd..555dcef 100644 --- a/src/Heimdall.Web/wwwroot/app.css +++ b/src/Heimdall.Web/wwwroot/app.css @@ -723,3 +723,132 @@ a.mud-link:hover { .mud-input:focus-within .mud-input-outlined-border { border-width: 1.5px !important; } + +/* ═══════════════════════════════════════════════════════════════════ + Design tokens — échelle 4px (issue #32) + ═══════════════════════════════════════════════════════════════════ */ + +:root { + /* Espacements (4px scale) */ + --hmd-space-1: 4px; + --hmd-space-2: 8px; + --hmd-space-3: 12px; + --hmd-space-4: 16px; + --hmd-space-5: 24px; + --hmd-space-6: 32px; + --hmd-space-7: 48px; + + /* Radius */ + --hmd-radius-sm: 6px; + --hmd-radius-md: 10px; + --hmd-radius-lg: 16px; + --hmd-radius-pill: 999px; + + /* Focus ring visible (WCAG 2.2 — jamais outline:none sans alternative) */ + --hmd-focus-ring: 0 0 0 3px rgba(34, 211, 238, 0.45); + + /* Ombres */ + --hmd-shadow-sm: 0 1px 3px rgba(11, 18, 32, 0.12); + --hmd-shadow-md: 0 4px 12px rgba(11, 18, 32, 0.16); +} + +/* ═══════════════════════════════════════════════════════════════════ + Focus visible global (a11y, issue #41) + ═══════════════════════════════════════════════════════════════════ */ + +:focus-visible { + outline: 2px solid var(--mud-palette-primary) !important; + outline-offset: 2px !important; + border-radius: 4px; +} + +/* ═══════════════════════════════════════════════════════════════════ + Skip-link (a11y, issue #41) + ═══════════════════════════════════════════════════════════════════ */ + +.skip-link { + position: absolute; + left: -9999px; + top: 0; + z-index: 2000; + background: var(--mud-palette-primary); + color: var(--mud-palette-primary-contrasttext); + padding: 10px 16px; + border-radius: 0 0 var(--hmd-radius-md) 0; + font-weight: 600; +} + +.skip-link:focus { + left: 0; + top: 0; +} + +/* ═══════════════════════════════════════════════════════════════════ + Mouvement réduit (prefers-reduced-motion, a11y, issue #41) + ═══════════════════════════════════════════════════════════════════ */ + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + scroll-behavior: auto !important; + } +} + +/* ═══════════════════════════════════════════════════════════════════ + Zones tactiles — minimum 44px (mobile, issue #41) + ═══════════════════════════════════════════════════════════════════ */ + +@media (max-width: 600px) { + .mud-icon-button { + min-width: 44px !important; + min-height: 44px !important; + } +} + +/* ═══════════════════════════════════════════════════════════════════ + Cards & tiles — hover lift subtil (désactivé en reduced-motion) + ═══════════════════════════════════════════════════════════════════ */ + +.hmd-tile { + transition: transform 0.15s ease, box-shadow 0.15s ease; +} + +.hmd-tile:hover { + transform: translateY(-2px); + box-shadow: var(--hmd-shadow-md); +} + +@media (prefers-reduced-motion: reduce) { + .hmd-tile:hover { + transform: none; + } +} + +/* ═══════════════════════════════════════════════════════════════════ + Pulse « live » — indicateur temps réel (désactivé en reduced-motion) + ═══════════════════════════════════════════════════════════════════ */ + +@keyframes hmd-pulse { + 0%, 100% { opacity: 1; } + 50% { opacity: 0.35; } +} + +.hmd-live-dot { + width: 10px; + height: 10px; + border-radius: 50%; + background: var(--mud-palette-success); + animation: hmd-pulse 2s ease-in-out infinite; + display: inline-block; +} + +@media (prefers-reduced-motion: reduce) { + .hmd-live-dot { + animation: none; + } +} +