-
Notifications
You must be signed in to change notification settings - Fork 10
/
SlideGroup.razor
108 lines (97 loc) · 2.9 KB
/
SlideGroup.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
@typeparam TItem
@inject IDataCacheService _dataCacheService
@inject NavigationManager NavigationManager
@if (string.IsNullOrWhiteSpace(Title) == false)
{
<div class="card-title">
<h2>@Title</h2>
@if (string.IsNullOrWhiteSpace(MoreLink) == false|| ForceShowMore)
{
<div>
@if (_dataCacheService.IsApp)
{
<MButton XSmall Text Block Color="primary" OnClick="OnClick">
<MIcon Left>@MoreIcon.ToIconString()</MIcon>
@MoreText
</MButton>
}
else
{
<MButton Text Block Color="primary" OnClick="OnClick">
<MIcon Left>@MoreIcon.ToIconString()</MIcon>
@MoreText
</MButton>
}
</div>
}
</div>
}
@if (_dataCacheService.IsApp)
{
<div class="slide-group">
@foreach (var item in Items)
{
<div class="slide-item">
@ChildContent(item)
</div>
}
@if (string.IsNullOrWhiteSpace(MoreLink) == false|| ForceShowMore)
{
<div class="slide-item">
<a class="item more-link" @onclick="OnClick">
<MIcon Large>@((MoreIcon== IconType.SeeDetails? IconType.SeeMore : MoreIcon).ToIconString())</MIcon>
<div class="text">@MoreText</div>
</a>
</div>
}
</div>
}
else
{
<MSlideGroup ShowArrows="true">
@foreach (var item in Items)
{
<MSlideItem>
@ChildContent(item)
</MSlideItem>
}
@if (string.IsNullOrWhiteSpace(MoreLink) == false|| ForceShowMore)
{
<MSlideItem>
<a class="item more-link" @onclick="OnClick">
<MIcon Large>@((MoreIcon== IconType.SeeDetails? IconType.SeeMore : MoreIcon).ToIconString())</MIcon>
<div class="text">@MoreText</div>
</a>
</MSlideItem>
}
</MSlideGroup>
}
@code {
[Parameter]
public RenderFragment<TItem> ChildContent { get; set; }
[Parameter]
public IEnumerable<TItem> Items { get; set; }
[Parameter]
public EventCallback OnClickMore { get; set; }
[Parameter]
public string MoreLink { get; set; }
[Parameter]
public IconType MoreIcon { get; set; } = IconType.SeeDetails;
[Parameter]
public bool ForceShowMore { get; set; }
[Parameter]
public string MoreText { get; set; } = "查看更多";
[Parameter]
public string Title { get; set; }
public async Task OnClick()
{
if (string.IsNullOrWhiteSpace(MoreLink))
{
await OnClickMore.InvokeAsync();
}
else
{
NavigationManager.NavigateTo(MoreLink);
}
}
}