1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-12-22 16:42:50 +01:00
Minecraft-Phantom-Panel/Web/Phantom.Web.Components/Tables/Table.razor

83 lines
1.5 KiB
Plaintext

@typeparam TItem
<div class="horizontal-scroll">
<table class="@FullClass">
<thead>
<tr>
@HeaderRow
</tr>
</thead>
@if (Items is null) {
<tbody>
<tr>
<td colspan="1000" class="fw-semibold">
Loading...
</td>
</tr>
</tbody>
}
else if (Items.Count > 0) {
<tbody>
@foreach (var item in Items) {
<tr>
<CascadingValue Name="Url" Value="@ItemUrl?.Invoke(item)">
@ItemRow(item)
</CascadingValue>
</tr>
}
</tbody>
}
else if (NoItemsRow != null) {
<tfoot>
<tr>
<td colspan="1000">@NoItemsRow</td>
</tr>
</tfoot>
}
</table>
</div>
@code {
[Parameter]
public string Class { get; set; } = string.Empty;
private string FullClass {
get {
List<string> classes = new (4) {
"table",
"align-middle"
};
if (ItemUrl != null) {
classes.Add("table-hover");
}
if (Class.Length > 0) {
classes.Add(Class);
}
return string.Join(' ', classes);
}
}
[Parameter, EditorRequired]
public RenderFragment HeaderRow { get; set; } = null!;
[Parameter, EditorRequired]
public RenderFragment<TItem> ItemRow { get; set; } = null!;
[Parameter]
public RenderFragment? NoItemsRow { get; set; } = null!;
[Parameter, EditorRequired]
public IReadOnlyList<TItem>? Items { get; set; }
[Parameter]
public Func<TItem, string>? ItemUrl { get; set; } = null;
}