mirror of https://github.com/ErsatzTV/ErsatzTV.git
5 changed files with 62 additions and 73 deletions
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
@using ErsatzTV.Application.MediaCards |
||||
@using LanguageExt.UnsafeValueAccess |
||||
@typeparam TCard |
||||
|
||||
@{ var letters = new System.Collections.Generic.HashSet<char>(); } |
||||
@foreach (TCard card in Cards.Filter(c => !string.IsNullOrWhiteSpace(c.Title)).OrderBy(c => c.SortTitle)) |
||||
{ |
||||
@if (!letters.Contains(card.SortTitle.Head())) |
||||
{ |
||||
Option<char> maybeLetter = card.SortTitle.ToLowerInvariant().HeadOrNone(); |
||||
if (maybeLetter.IsSome) |
||||
{ |
||||
char letter = maybeLetter.ValueUnsafe(); |
||||
if (letter >= '0' && letter <= '9') |
||||
{ |
||||
letter = '#'; |
||||
} |
||||
letters.Add(letter); |
||||
<div id="@($"letter-{letter}")" style="scroll-margin-top: 128px"> |
||||
@ChildContent(card) |
||||
</div> |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
@ChildContent |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic; |
||||
using ErsatzTV.Application.MediaCards; |
||||
using Microsoft.AspNetCore.Components; |
||||
|
||||
namespace ErsatzTV.Shared |
||||
{ |
||||
public partial class FragmentLetterAnchor<TCard> where TCard : MediaCardViewModel |
||||
{ |
||||
[Parameter] |
||||
public RenderFragment<TCard> ChildContent { get; set; } |
||||
|
||||
[Parameter] |
||||
public List<TCard> Cards { get; set; } |
||||
} |
||||
} |
||||
Loading…
Reference in new issue