Various CSS work
This commit is contained in:
parent
ef174af0e1
commit
15579acba8
52 changed files with 8001 additions and 944 deletions
|
|
@ -0,0 +1,6 @@
|
|||
@model PlanTempus.Application.Features.Employees.Components.EmployeeStatCardViewModel
|
||||
|
||||
<swp-stat-card data-key="@Model.Key" class="@Model.Variant">
|
||||
<swp-stat-value>@Model.Value</swp-stat-value>
|
||||
<swp-stat-label>@Model.Label</swp-stat-label>
|
||||
</swp-stat-card>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlanTempus.Application.Features.Localization.Services;
|
||||
|
||||
namespace PlanTempus.Application.Features.Employees.Components;
|
||||
|
||||
public class EmployeeStatCardViewComponent : ViewComponent
|
||||
{
|
||||
private readonly ILocalizationService _localization;
|
||||
|
||||
public EmployeeStatCardViewComponent(ILocalizationService localization)
|
||||
{
|
||||
_localization = localization;
|
||||
}
|
||||
|
||||
public IViewComponentResult Invoke(string key)
|
||||
{
|
||||
var model = EmployeeStatCardCatalog.Get(key, _localization);
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
public class EmployeeStatCardViewModel
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required string Value { get; init; }
|
||||
public required string Label { get; init; }
|
||||
public string? Variant { get; init; }
|
||||
}
|
||||
|
||||
internal class EmployeeStatCardData
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required string Value { get; init; }
|
||||
public required string LabelKey { get; init; }
|
||||
public string? Variant { get; init; }
|
||||
}
|
||||
|
||||
public static class EmployeeStatCardCatalog
|
||||
{
|
||||
private static readonly Dictionary<string, EmployeeStatCardData> Cards = new()
|
||||
{
|
||||
["active-employees"] = new EmployeeStatCardData
|
||||
{
|
||||
Key = "active-employees",
|
||||
Value = "4",
|
||||
LabelKey = "employees.stats.activeEmployees",
|
||||
Variant = "teal"
|
||||
},
|
||||
["pending-invitations"] = new EmployeeStatCardData
|
||||
{
|
||||
Key = "pending-invitations",
|
||||
Value = "1",
|
||||
LabelKey = "employees.stats.pendingInvitations",
|
||||
Variant = "amber"
|
||||
},
|
||||
["roles-defined"] = new EmployeeStatCardData
|
||||
{
|
||||
Key = "roles-defined",
|
||||
Value = "4",
|
||||
LabelKey = "employees.stats.rolesDefined",
|
||||
Variant = "purple"
|
||||
}
|
||||
};
|
||||
|
||||
public static EmployeeStatCardViewModel Get(string key, ILocalizationService localization)
|
||||
{
|
||||
if (!Cards.TryGetValue(key, out var card))
|
||||
throw new KeyNotFoundException($"EmployeeStatCard with key '{key}' not found");
|
||||
|
||||
return new EmployeeStatCardViewModel
|
||||
{
|
||||
Key = card.Key,
|
||||
Value = card.Value,
|
||||
Label = localization.Get(card.LabelKey),
|
||||
Variant = card.Variant
|
||||
};
|
||||
}
|
||||
|
||||
public static IEnumerable<string> AllKeys => Cards.Keys;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue