Skip to content

Commit 7a882b8

Browse files
authored
refactor(Table): add RenderLoader method reuse code snippet (#7860)
1 parent 658476d commit 7a882b8

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

src/BootstrapBlazor/Components/Table/Table.razor

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,7 @@
1616
}
1717
else if (ShowLoadingInFirstRender)
1818
{
19-
<div class="table-loading">
20-
@if (LoadingTemplate is not null)
21-
{
22-
@LoadingTemplate
23-
}
24-
else
25-
{
26-
<Spinner Color="Color.Primary" />
27-
}
28-
</div>
19+
@RenderLoader("table-loading")
2920
}
3021
}
3122
else
@@ -388,16 +379,8 @@
388379
{
389380
@RenderPagination
390381
}
391-
<div class="table-loader">
392-
@if (LoadingTemplate is not null)
393-
{
394-
@LoadingTemplate
395-
}
396-
else
397-
{
398-
<Spinner Color="Color.Primary" />
399-
}
400-
</div>
382+
383+
@RenderLoader("table-loader")
401384

402385
<Responsive OnBreakPointChanged="OnBreakPointChanged" />
403386
}
@@ -1156,4 +1139,16 @@
11561139
@<ValidateForm @ref="_inCellValidateForm" Model="EditModel" IsFormless="true" ShowLabel="false">
11571140
@RenderRowContent(item)
11581141
</ValidateForm>;
1142+
1143+
RenderFragment<string> RenderLoader => cssString =>
1144+
@<div class="@cssString">
1145+
@if (LoadingTemplate != null)
1146+
{
1147+
@LoadingTemplate
1148+
}
1149+
else
1150+
{
1151+
<Spinner Color="Color.Primary"></Spinner>
1152+
}
1153+
</div>;
11591154
}

0 commit comments

Comments
 (0)