Added CategoryBadgeComponent

This commit is contained in:
Mia Rose Winter 2024-02-03 12:56:10 +01:00
parent 78f1d291f3
commit d0ad6d8cb5
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
2 changed files with 15 additions and 3 deletions

View file

@ -31,9 +31,7 @@
@if (Article.Categories.Count > 0) { @if (Article.Categories.Count > 0) {
<p class="flex flex-wrap gap-2 my-3"> <p class="flex flex-wrap gap-2 my-3">
@foreach (var category in Article.Categories.OrderBy(c => c.Color)) { @foreach (var category in Article.Categories.OrderBy(c => c.Color)) {
<span class="badge badge-@CategoryUtilities.GetCssClassPostfixForColor(category.Color)"> <CategoryBadgeComponent Category="category" />
@category.Name
</span>
} }
</p> </p>
} }

View file

@ -0,0 +1,14 @@
@using Wave.Utilities
@using Wave.Data
<span class="badge badge-@CategoryUtilities.GetCssClassPostfixForColor(Category.Color)" @attributes="AdditionalAttributes">
@Category.Name
</span>
@code {
[Parameter]
public required Category Category { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary<string, object>? AdditionalAttributes { get; set; }
}