Files
Heimdall/src/Heimdall.Web/Components/MetricTile.razor
T

39 lines
1.6 KiB
Plaintext
Raw Normal View History

@* MetricTile.razor — tuile de métrique compacte (label + valeur + jauge optionnelle). *@
@using MudBlazor
<MudPaper Elevation="1" Class="pa-3" Style="border-radius: var(--hmd-radius-md); height: 100%;">
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="d-flex align-center">
@if (Icon is not null)
{
<MudIcon Icon="@Icon" Size="Size.Small" Class="mr-1" />
}
@Label
</MudText>
<MudText Typo="Typo.h6" Class="mt-1 font-weight-bold" Style="@($"color:{ColorToCss(Color)}")">
@Value
</MudText>
@if (Progress is { } p)
{
<MudProgressLinear Value="@p" Color="@ProgressColor" Rounded="true" Size="Size.Small" Class="mt-2" />
}
</MudPaper>
@code {
[Parameter, EditorRequired] public string Label { get; set; } = "";
[Parameter, EditorRequired] public string Value { get; set; } = "—";
[Parameter] public Color Color { get; set; } = Color.Default;
[Parameter] public Color ProgressColor { get; set; } = Color.Primary;
[Parameter] public double? Progress { get; set; }
[Parameter] public string? Icon { get; set; }
private static string ColorToCss(Color color) => color switch
{
Color.Primary => "var(--mud-palette-primary)",
Color.Secondary => "var(--mud-palette-secondary)",
Color.Info => "var(--mud-palette-info)",
Color.Success => "var(--mud-palette-success)",
Color.Warning => "var(--mud-palette-warning)",
Color.Error => "var(--mud-palette-error)",
_ => "var(--mud-palette-text-primary)",
};
}