Skip to content

Commit

Permalink
implement card list component
Browse files Browse the repository at this point in the history
  • Loading branch information
yagizhanNY committed Jul 5, 2023
1 parent f8b1684 commit d94318d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
18 changes: 18 additions & 0 deletions SiemensIXBlazor/Components/CardList/CardList.razor
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>
68 changes: 68 additions & 0 deletions SiemensIXBlazor/Components/CardList/CardList.razor.cs
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();
}
}
}
8 changes: 8 additions & 0 deletions SiemensIXBlazor/Enums/CardList/CardListStyle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SiemensIXBlazor.Enums.CardList
{
public enum CardListStyle
{
Scroll,
Stack
}
}

0 comments on commit d94318d

Please sign in to comment.