Skip to content

Commit dae4456

Browse files
committed
chore: 移动组件目录
1 parent e4867b3 commit dae4456

File tree

7 files changed

+99
-61
lines changed

7 files changed

+99
-61
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@namespace BootstrapBlazor.Components
2+
@inherits BootstrapModuleComponentBase
3+
4+
<IntersectionObserver OnIntersecting="OnIntersecting" Threshold="1" AutoUnobserveWhenIntersection="false">
5+
<IntersectionObserverItem>
6+
@if (CanLoading)
7+
{
8+
if (LoadingTemplate != null)
9+
{
10+
@LoadingTemplate
11+
}
12+
else
13+
{
14+
<div class="bb-intersection-loading">
15+
<Spinner></Spinner>
16+
</div>
17+
}
18+
}
19+
else if (NoMoreTemplate != null)
20+
{
21+
@NoMoreTemplate
22+
}
23+
else if (!string.IsNullOrEmpty(NoMoreText))
24+
{
25+
<div class="bb-intersection-stop-text">@NoMoreText</div>
26+
}
27+
</IntersectionObserverItem>
28+
</IntersectionObserver>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
using Microsoft.Extensions.Localization;
7+
8+
namespace BootstrapBlazor.Components;
9+
10+
/// <summary>
11+
/// 加载更多组件
12+
/// </summary>
13+
public partial class LoadMore
14+
{
15+
/// <summary>
16+
/// 获得/设置 触底回调方法 <see cref="CanLoading"/> 为 true 时才触发此回调方法
17+
/// </summary>
18+
[Parameter] public Func<Task>? OnLoadMore { get; set; }
19+
20+
/// <summary>
21+
/// 获得/设置 是否可以加载更多数据 默认为 true
22+
/// </summary>
23+
[Parameter]
24+
public bool CanLoading { get; set; } = true;
25+
26+
/// <summary>
27+
/// 获得/设置 加载更多模板 默认 null
28+
/// </summary>
29+
[Parameter]
30+
public RenderFragment? LoadingTemplate { get; set; }
31+
32+
/// <summary>
33+
/// 获得/设置 没有更多数据提示信息 默认为 null 读取资源文件中的预设值
34+
/// </summary>
35+
[Parameter]
36+
public string? NoMoreText { get; set; }
37+
38+
/// <summary>
39+
/// 获得/设置 没有更多数据时显示的模板 默认为 null
40+
/// </summary>
41+
[Parameter]
42+
public RenderFragment? NoMoreTemplate { get; set; }
43+
44+
[Inject, NotNull]
45+
private IStringLocalizer<LoadMore>? Localizer { get; set; }
46+
47+
/// <summary>
48+
/// <inheritdoc/>
49+
/// </summary>
50+
protected override void OnParametersSet()
51+
{
52+
base.OnParametersSet();
53+
54+
NoMoreText ??= Localizer[nameof(NoMoreText)];
55+
}
56+
57+
private async Task OnIntersecting(IntersectionObserverEntry entry)
58+
{
59+
if (entry.IsIntersecting)
60+
{
61+
if (OnLoadMore != null)
62+
{
63+
await OnLoadMore();
64+
}
65+
}
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
.nomore {
1+
.bb-intersection-loading {
22
display: flex;
33
justify-content: center;
44
padding: .5rem .5rem 1rem;
55
color: #aaa;
6-
font-size: .875rem;
76
}
87

9-
.loading {
8+
.bb-intersection-stop-text {
109
display: flex;
1110
justify-content: center;
1211
padding: .5rem .5rem 1rem;
1312
color: #aaa;
13+
font-size: .875rem;
1414
}

src/BootstrapBlazor/Components/LoadMore/LoadMore.razor

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/BootstrapBlazor/Components/LoadMore/LoadMore.razor.css

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/BootstrapBlazor/Components/LoadMore/LoadMore.razor.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/BootstrapBlazor/wwwroot/scss/components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
@import "../../Components/Input/BootstrapInputGroup.razor.scss";
5959
@import "../../Components/Input/FloatingLabel.razor.scss";
6060
@import "../../Components/Input/OtpInput.razor.scss";
61+
@import "../../Components/IntersectionObserver/LoadMore.razor.scss";
6162
@import "../../Components/IpAddress/IpAddress.razor.scss";
6263
@import "../../Components/Layout/Layout.razor.scss";
6364
@import "../../Components/Layout/LayoutSplitBar.razor.scss";

0 commit comments

Comments
 (0)