40 lines
1.5 KiB
Plaintext
40 lines
1.5 KiB
Plaintext
@inherits DComponentBase
|
|||
|
|
|
||
|
|
@* daisyUI Table: https://daisyui.com/components/table/ . ChildContent is the <thead>/<tbody>/<tfoot> markup. Class and
|
||
|
|
the other attributes go on the <table>; with Scroll (the default) it sits in an overflow-x-auto div, whose classes
|
||
|
|
are WrapperClass (pinned rows need it to have a height, e.g. h-96). *@
|
||
|
|
@if (Scroll)
|
||
|
|
{
|
||
|
|
<div class="@Cx("overflow-x-auto", WrapperClass)">
|
||
|
|
<table @attributes="AdditionalAttributes" class="@CssClass">@ChildContent</table>
|
||
|
|
</div>
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
<table @attributes="AdditionalAttributes" class="@CssClass">@ChildContent</table>
|
||
|
|
}
|
||
|
|
|
||
|
|
@code {
|
||
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
||
|
|
[Parameter] public DSize Size { get; set; }
|
||
|
|
[Parameter] public bool Zebra { get; set; }
|
||
|
|
/// <summary>Sticky thead/tfoot rows while the wrapper scrolls vertically.</summary>
|
||
|
|
[Parameter] public bool PinRows { get; set; }
|
||
|
|
/// <summary>Sticky <th> columns while the wrapper scrolls horizontally.</summary>
|
||
|
|
[Parameter] public bool PinCols { get; set; }
|
||
|
|
/// <summary>Wrap the table in an overflow-x-auto div so it scrolls on narrow screens.</summary>
|
||
|
|
[Parameter] public bool Scroll { get; set; } = true;
|
||
|
|
[Parameter] public string WrapperClass { get; set; }
|
||
|
|
|
||
|
|
string CssClass => Cx("table", Zebra ? "table-zebra" : null, PinRows ? "table-pin-rows" : null,
|
||
|
|
PinCols ? "table-pin-cols" : null, SizeClass, Class);
|
||
|
|
|
||
|
|
string SizeClass => Size switch
|
||
|
|
{
|
||
|
|
DSize.Xs => "table-xs",
|
||
|
|
DSize.Sm => "table-sm",
|
||
|
|
DSize.Lg => "table-lg",
|
||
|
|
DSize.Xl => "table-xl",
|
||
|
|
_ => null
|
||
|
|
};
|
||
|
|
}
|