Skip to content

Commit

Permalink
Expose Wrapper Class for Tables
Browse files Browse the repository at this point in the history
Additional Request of #513
  • Loading branch information
jbomhold3 committed May 3, 2022
1 parent 0b27b59 commit 3e2df65
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 12 deletions.
30 changes: 30 additions & 0 deletions src/BlazorStrap-Docs/Samples/Content/Tables/Tables1b.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<BSTable IsResponsive="true" IsStriped="true">
<BSTHead>
<BSTR>
<BSTD>#</BSTD>
<BSTD>First</BSTD>
<BSTD>Last</BSTD>
<BSTD>Handle</BSTD>
</BSTR>
</BSTHead>
<BSTBody>
<BSTR>
<BSTD>1</BSTD>
<BSTD>John</BSTD>
<BSTD>Doe</BSTD>
<BSTD>JohnDoe <br/>media.com</BSTD>
</BSTR>
<BSTR>
<BSTD>2</BSTD>
<BSTD>Jane</BSTD>
<BSTD>Doe</BSTD>
<BSTD>JaneDoe <br/>media.com</BSTD>
</BSTR>
</BSTBody>
<BSTFoot>
<BSTR>
<BSTD ColSpan="4">Spanned Table Footer Here</BSTD>
</BSTR>

</BSTFoot>
</BSTable>
30 changes: 30 additions & 0 deletions src/BlazorStrap-Docs/wwwroot/Samples/Content/Tables/Tables1b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<BSTable IsResponsive="true" IsStriped="true">
<BSTHead>
<BSTR>
<BSTD>#</BSTD>
<BSTD>First</BSTD>
<BSTD>Last</BSTD>
<BSTD>Handle</BSTD>
</BSTR>
</BSTHead>
<BSTBody>
<BSTR>
<BSTD>1</BSTD>
<BSTD>John</BSTD>
<BSTD>Doe</BSTD>
<BSTD>JohnDoe <br/>media.com</BSTD>
</BSTR>
<BSTR>
<BSTD>2</BSTD>
<BSTD>Jane</BSTD>
<BSTD>Doe</BSTD>
<BSTD>JaneDoe <br/>media.com</BSTD>
</BSTR>
</BSTBody>
<BSTFoot>
<BSTR>
<BSTD ColSpan="4">Spanned Table Footer Here</BSTD>
</BSTR>

</BSTFoot>
</BSTable>
29 changes: 17 additions & 12 deletions src/BlazorStrap-Docs/wwwroot/Static/Content/Tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
See [shared](layout/shared) for additional parameters
:::

| Parameter | Type | Valid | Remarks/Output |
|-----------------|------|------------|-----------------------|
| Color | Enum | BSColor | `.table-[]` | {.table-striped .p-2}
| IsBordered | bool | true/false | `.table-bordered` |
| IsBorderLess | bool | true/false | `.table-borderless` |
| IsHoverable | bool | true/false | `.table-hover` |
| IsCaptionTop | bool | true/false | `.caption-top` |
| IsDark | bool | true/false | `.table-dark` |
| IsSmall | bool | true/false | `.table-sm` |
| IsStriped | bool | true/false | `.table-striped` |
| IsResponsive | bool | true/false | `.table-responsive` |
| ResponsiveSize | bool | true/false | `.table-responsive-#` |
| Parameter | Type | Valid | Remarks/Output |
|------------------------|--------|------------|-----------------------|
| Color | Enum | BSColor | `.table-[]` | {.table-striped .p-2}
| IsBordered | bool | true/false | `.table-bordered` |
| IsBorderLess | bool | true/false | `.table-borderless` |
| IsHoverable | bool | true/false | `.table-hover` |
| IsCaptionTop | bool | true/false | `.caption-top` |
| IsDark | bool | true/false | `.table-dark` |
| IsSmall | bool | true/false | `.table-sm` |
| IsStriped | bool | true/false | `.table-striped` |
| IsResponsive | bool | true/false | `.table-responsive` |
| ResponsiveSize | bool | true/false | `.table-responsive-#` |
| ResponsiveWrapperClass | string | string | Adds string to class |

:::
#### Component \<BSTR\>
Expand Down Expand Up @@ -46,6 +47,10 @@ Shared Parameters only

{{sample=Content/Tables/Tables1}}

### Responsive Tables Example

{{sample=Content/Tables/Tables1b}}

#### Component \<BSDataTable<TValue>\> (Version >= 5.0.105-Preview2)
See [shared](layout/shared) for additional parameters
:::
Expand Down
2 changes: 2 additions & 0 deletions src/BlazorStrap/Components/Content/BSTable.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public partial class BSTable : BlazorStrapBase
[Parameter] public bool IsDark { get; set; }
[Parameter] public bool IsHoverable { get; set; }
[Parameter] public bool IsResponsive { get; set; }
[Parameter] public string? ResponsiveWrapperClass { get; set; }
[Parameter] public Size ResponsiveSize { get; set; } = Size.None;
[Parameter] public bool IsSmall { get; set; }
[Parameter] public bool IsBordered { get; set; }
Expand All @@ -32,6 +33,7 @@ public partial class BSTable : BlazorStrapBase
internal string? WrapperClassBuilder => new CssBuilder("bs-table-responsive")
.AddClass("table-responsive", ResponsiveSize == Size.None)
.AddClass($"table-responsive-{ResponsiveSize.ToDescriptionString()}", ResponsiveSize != Size.None)
.AddClass(ResponsiveWrapperClass, !string.IsNullOrEmpty(ResponsiveWrapperClass))
.Build().ToNullString();

}
Expand Down

0 comments on commit 3e2df65

Please sign in to comment.