-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8b1684
commit d94318d
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@namespace SiemensIXBlazor.Components | ||
@using Microsoft.JSInterop; | ||
@using SiemensIXBlazor.Enums.CardList; | ||
@using SiemensIXBlazor.Helpers; | ||
@inherits IXBaseComponent | ||
@inject IJSRuntime JSRuntime | ||
|
||
<ix-card-list @attributes="UserAttributes" class="@Class" style="@Style" | ||
id="@Id" | ||
label="@Label" | ||
show-all-count="@ShowAllCount" | ||
list-style="@(EnumParser<CardListStyle>.ParseEnumToString(ListStyle))" | ||
collapse="@Collapse" | ||
i-1-8n-more-cards="@I18NMoreCards" | ||
i-1-8n-show-all="@I18NShowAll" | ||
suppress-overflow-handling="@SuppressOverflowHandling"> | ||
@ChildContent | ||
</ix-card-list> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.JSInterop; | ||
using SiemensIXBlazor.Enums.CardList; | ||
using SiemensIXBlazor.Interops; | ||
|
||
namespace SiemensIXBlazor.Components | ||
{ | ||
public partial class CardList | ||
{ | ||
[Parameter, EditorRequired] | ||
public string Id { get; set; } = string.Empty; | ||
[Parameter] | ||
public RenderFragment? ChildContent { get; set; } | ||
[Parameter] | ||
public bool Collapse { get; set; } = false; | ||
[Parameter] | ||
public string I18NMoreCards { get; set; } = "There are more cards available"; | ||
[Parameter] | ||
public string I18NShowAll { get; set; } = "Show all"; | ||
[Parameter] | ||
public string? Label { get; set; } | ||
[Parameter] | ||
public CardListStyle ListStyle { get; set; } = CardListStyle.Stack; | ||
[Parameter] | ||
public int? ShowAllCount { get; set; } | ||
[Parameter] | ||
public bool SuppressOverflowHandling { get; set; } = false; | ||
[Parameter] | ||
public EventCallback<bool> CollapseChangedEvent { get; set; } | ||
[Parameter] | ||
public EventCallback ShowAllClickEvent { get; set; } | ||
[Parameter] | ||
public EventCallback ShowMoreCardClickEvent { get; set; } | ||
|
||
private BaseInterop _interop; | ||
|
||
protected async override Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
_interop = new(JSRuntime); | ||
|
||
await _interop.AddEventListener(this, Id, "collapseChanged", "CollapseChanged"); | ||
await _interop.AddEventListener(this, Id, "showAllClick", "ShowAllClicked"); | ||
await _interop.AddEventListener(this, Id, "showMoreCardClick", "ShowMoreCardClicked"); | ||
} | ||
} | ||
|
||
[JSInvokable] | ||
public async void CollapseChanged(bool value) | ||
{ | ||
await CollapseChangedEvent.InvokeAsync(value); | ||
} | ||
|
||
[JSInvokable] | ||
public async void ShowAllClicked() | ||
{ | ||
await ShowAllClickEvent.InvokeAsync(); | ||
} | ||
|
||
[JSInvokable] | ||
public async void ShowMoreCardClicked() | ||
{ | ||
await ShowMoreCardClickEvent.InvokeAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace SiemensIXBlazor.Enums.CardList | ||
{ | ||
public enum CardListStyle | ||
{ | ||
Scroll, | ||
Stack | ||
} | ||
} |