SharpRSS/WebSharpRSS/Shared/FeedItemList.razor
2023-05-26 21:54:12 +02:00

60 lines
2.3 KiB
Plaintext

@using WebSharpRSS.Models
@using Serilog
@using ToolQit.Extensions
@inject IDialogService _dialogService
<MudStack Spacing="2" Class="ma-2">
@if (Items != null)
{
foreach (var feedItemData in Items)
{
<MudItem @onclick="@(() => Callback(feedItemData))">
<MudPaper Height="250" Width="300" Class="px-2">
<div style="justify-self: start;" class="d-flex align-center">
@if (feedItemData.FaviconUrl != null)
{
<MudImage Src="@feedItemData.FaviconUrl" ObjectFit="ObjectFit.Contain"/>
}
<div class="d-inline pa-2 align-center" style="font-size: 16px;">
@if (feedItemData.Title != null)
{
@((MarkupString)feedItemData.Title)
}
</div>
</div>
<div>
@if (feedItemData.Description != null && !feedItemData.Description.IsNullEmptyWhiteSpace())
{
@((MarkupString)feedItemData.Description)
}
else
{
<MudText Color="Color.Dark" Typo="Typo.body2">No description found!</MudText>
}
</div>
<MudText Typo="Typo.overline">@feedItemData.PublishingDate.ToString()</MudText>
</MudPaper>
</MudItem>
}
}
else
{
<MudAlert Severity="Severity.Info" Variant="Variant.Filled">No items to load!</MudAlert>
}
</MudStack>
@code {
[Parameter]
public HashSet<FeedItemData>? Items { get; set; }
DialogOptions _dialogOptions = new DialogOptions() { FullWidth = true, MaxWidth = MaxWidth.ExtraLarge, NoHeader = true, CloseButton = true, CloseOnEscapeKey = true };
private void Callback(FeedItemData feedItem)
{
var parameters = new DialogParameters();
parameters.Add("Data", feedItem);
_dialogService.Show<ReadDialog>("", parameters, _dialogOptions);
Log.Verbose("Item: {ItemId} clicked", feedItem.Id);
}
}