Skip to content

Commit 7db5816

Browse files
committed
add Classes and Styles parameters to BitBasicList #11019
1 parent 9809189 commit 7db5816

File tree

5 files changed

+97
-3
lines changed

5 files changed

+97
-3
lines changed

src/BlazorUI/Bit.BlazorUI/Components/Lists/BasicList/BitBasicList.razor

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@
5050

5151
@if (LoadMore && _loadMoreFinished is false)
5252
{
53-
<button class="bit-bsl-lmb" @onclick="() => PerformLoadMore(false)">
53+
<button @onclick="() => PerformLoadMore(false)"
54+
style="@Styles?.LoadMoreButton"
55+
class="bit-bsl-lmb @Classes?.LoadMoreButton">
5456
@if (LoadMoreTemplate is not null)
5557
{
5658
@LoadMoreTemplate(_isLoadingMore)
5759
}
5860
else
5961
{
60-
<div class="bit-bsl-lmt">
62+
<div style="@Styles?.LoadMoreText"
63+
class="bit-bsl-lmt @Classes?.LoadMoreText">
6164
@if (_isLoadingMore)
6265
{
6366
<span>...</span>

src/BlazorUI/Bit.BlazorUI/Components/Lists/BasicList/BitBasicList.razor.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Bit.BlazorUI;
1+
using System.Drawing;
2+
3+
namespace Bit.BlazorUI;
24

35
/// <summary>
46
/// BitBasicList provides a base component for rendering large sets of items. It’s agnostic of layout, the tile component used, and selection management.
@@ -19,6 +21,11 @@ public partial class BitBasicList<TItem> : BitComponentBase
1921

2022

2123

24+
/// <summary>
25+
/// Custom CSS classes for different parts of the list.
26+
/// </summary>
27+
[Parameter] public BitBasicListClassStyles? Classes { get; set; }
28+
2229
/// <summary>
2330
/// The custom content that will be rendered when there is no item to show.
2431
/// </summary>
@@ -110,6 +117,11 @@ public partial class BitBasicList<TItem> : BitComponentBase
110117
/// </summary>
111118
[Parameter] public RenderFragment<TItem>? RowTemplate { get; set; }
112119

120+
/// <summary>
121+
/// Custom CSS styles for different parts of the list.
122+
/// </summary>
123+
[Parameter] public BitBasicListClassStyles? Styles { get; set; }
124+
113125
/// <summary>
114126
/// Enables virtualization in rendering the list.
115127
/// </summary>
@@ -138,8 +150,15 @@ public async Task RefreshDataAsync()
138150

139151
protected override string RootElementClass => "bit-bsl";
140152

153+
protected override void RegisterCssClasses()
154+
{
155+
ClassBuilder.Register(() => Classes?.Root);
156+
}
157+
141158
protected override void RegisterCssStyles()
142159
{
160+
StyleBuilder.Register(() => Styles?.Root);
161+
143162
StyleBuilder.Register(() => (FullSize || FullWidth) ? "width:100%" : string.Empty);
144163
StyleBuilder.Register(() => (FullSize || FullHeight) ? "height:100%" : string.Empty);
145164

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Bit.BlazorUI;
2+
3+
public class BitBasicListClassStyles
4+
{
5+
/// <summary>
6+
/// Custom CSS classes/styles for the root element of the list.
7+
/// </summary>
8+
public string? Root { get; set; }
9+
10+
/// <summary>
11+
/// Custom CSS classes/styles for the LoadMore button of the list.
12+
/// </summary>
13+
public string? LoadMoreButton { get; set; }
14+
15+
/// <summary>
16+
/// Custom CSS classes/styles for the LoadMore text of the list.
17+
/// </summary>
18+
public string? LoadMoreText { get; set; }
19+
}

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/BasicList/BitBasicListDemo.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<DemoPage Name="BasicList"
99
Description="BitBasicList provides a base component for rendering large sets of items. It’s agnostic of layout, the tile component used, and selection management."
1010
Parameters="componentParameters"
11+
SubClasses="componentSubClasses"
1112
GitHubUrl="Lists/BasicList/BitBasicList.razor"
1213
GitHubDemoUrl="Lists/BasicList/BitBasicListDemo.razor">
1314
<DemoExample Title="Basic" RazorCode="@example1RazorCode" CsharpCode="@example1CsharpCode" Id="example1">

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/BasicList/BitBasicListDemo.razor.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ public partial class BitBasicListDemo
44
{
55
private readonly List<ComponentParameter> componentParameters =
66
[
7+
new()
8+
{
9+
Name = "Classes",
10+
Type = "BitBasicListClassStyles?",
11+
DefaultValue = "null",
12+
Description = "Custom CSS classes for different parts of the list.",
13+
LinkType = LinkType.Link,
14+
Href = "#class-styles",
15+
},
716
new()
817
{
918
Name = "EmptyContent",
@@ -124,6 +133,15 @@ public partial class BitBasicListDemo
124133
Description = "The template to render each row.",
125134
},
126135
new()
136+
{
137+
Name = "Styles",
138+
Type = "BitBasicListClassStyles?",
139+
DefaultValue = "null",
140+
Description = "Custom CSS styles for different parts of the list.",
141+
LinkType = LinkType.Link,
142+
Href = "#class-styles",
143+
},
144+
new()
127145
{
128146
Name = "Virtualize",
129147
Type = "bool",
@@ -139,6 +157,40 @@ public partial class BitBasicListDemo
139157
},
140158
];
141159

160+
private readonly List<ComponentSubClass> componentSubClasses =
161+
[
162+
new()
163+
{
164+
Id = "class-styles",
165+
Title = "BitBasicListClassStyles",
166+
Description = "",
167+
Parameters =
168+
[
169+
new()
170+
{
171+
Name = "Root",
172+
Type = "string?",
173+
DefaultValue = "null",
174+
Description = "Custom CSS classes/styles for the root element of the list.",
175+
},
176+
new()
177+
{
178+
Name = "LoadMoreButton",
179+
Type = "string?",
180+
DefaultValue = "null",
181+
Description = "Custom CSS classes/styles for the LoadMore button of the list.",
182+
},
183+
new()
184+
{
185+
Name = "LoadMoreText",
186+
Type = "string?",
187+
DefaultValue = "null",
188+
Description = "Custom CSS classes/styles for the LoadMore text of the list.",
189+
},
190+
]
191+
}
192+
];
193+
142194

143195

144196
private readonly List<Person> lotsOfPeople = [.. Enumerable.Range(0, 8000).Select(i => new Person

0 commit comments

Comments
 (0)