68 lines
2.3 KiB
Plaintext
68 lines
2.3 KiB
Plaintext
@namespace WebApp.Components.Shared.Components
|
|
@inject IDialogService DialogService
|
|
|
|
@* Reuse dialog options pattern - could be extracted if used in more places *@
|
|
|
|
<MudItem xs="12" sm="6" md="4">
|
|
<MudCard Elevation="4" Class="@($"pa-4 {MarkdownHelper.GetNoteColorClass(Note.Id)}".Trim())" Style="cursor: pointer; height: 100%;" @onclick="OpenNoteDialog">
|
|
<MudCardContent>
|
|
<div class="d-flex align-center mb-2">
|
|
<MudIcon Icon="@Icons.Material.Filled.Note" Size="Size.Medium" Class="mr-2" />
|
|
<MudText Typo="Typo.h6" Class="flex-grow-1">@Note.Title</MudText>
|
|
@if (Note.IsPinned)
|
|
{
|
|
<MudIcon Icon="@Icons.Material.Filled.PushPin" Size="Size.Small" Color="Color.Primary" />
|
|
}
|
|
</div>
|
|
<MudDivider Class="mb-3" />
|
|
@if (!string.IsNullOrWhiteSpace(PreviewText))
|
|
{
|
|
<MudText Typo="Typo.body2" Style="max-height: 100px; overflow: hidden; text-overflow: ellipsis;">
|
|
@PreviewText
|
|
</MudText>
|
|
}
|
|
else
|
|
{
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary" Align="Align.Center" Class="my-4">
|
|
No content
|
|
</MudText>
|
|
}
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</MudItem>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public Note Note { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback OnNoteChanged { get; set; }
|
|
|
|
private const int CardPreviewMaxLength = 150;
|
|
private string PreviewText => MarkdownHelper.StripMarkdownPreview(Note.Content, CardPreviewMaxLength);
|
|
|
|
private async Task OpenNoteDialog()
|
|
{
|
|
var parameters = new DialogParameters
|
|
{
|
|
["NoteId"] = Note.Id
|
|
};
|
|
|
|
var options = new DialogOptions
|
|
{
|
|
MaxWidth = MaxWidth.Medium,
|
|
FullWidth = true,
|
|
CloseButton = true
|
|
};
|
|
|
|
var dialog = await DialogService.ShowAsync<NoteViewDialog>("Note", parameters, options);
|
|
var result = await dialog.Result;
|
|
|
|
// If dialog was closed and result indicates a change (e.g., note deleted or unpinned)
|
|
if (result != null && !result.Canceled)
|
|
{
|
|
await OnNoteChanged.InvokeAsync();
|
|
}
|
|
}
|
|
}
|