Iceshrimp.NET/Iceshrimp.Frontend/Components/Note/NoteBody.razor
2024-06-19 01:56:55 +02:00

58 lines
No EOL
1.7 KiB
Text

@if (NoteBase.Cw != null)
{
<div class="cw">
<span class="cw-field">@NoteBase.Cw</span><button class="cw-button" @onclick="ToggleCw" @onclick:stopPropagation="true">Toggle CW</button>
</div>
<div hidden="@CwToggle" class="note-body @(CwToggle ? "hidden" : "") @(Indented ? "indent" : "")">
<MfmText Text="@NoteBase.Text" />
</div>
}
@if (NoteBase.Cw == null && OverLength)
{
<div
class="note-body @(Truncate ? "truncated" : "") @(Indented ? "indent" : "")"
style="max-height: @(Truncate ? MaxHeight + "px" : "initial")"
>
<MfmText Text="@NoteBase.Text" />
</div>
<button class="truncate-btn" @onclick="ToggleTruncate" @onclick:stopPropagation="true">
@if (Truncate)
{<span>Show more</span> }
@if (!Truncate)
{<span>Show less</span>}
</button>
}
@if (NoteBase.Cw == null && OverLength == false)
{
<div class="note-body @(Indented ? "indent" : "")">
<MfmText Text="@NoteBase.Text" />
</div>
}
@if (NoteBase.Attachments.Count > 0)
{
<NoteAttachments Attachments="NoteBase.Attachments"/>
}
@code {
[Parameter] public required Shared.Schemas.NoteBase NoteBase { get; set; }
[Parameter] public required bool OverLength { get; set; }
[Parameter] public bool Indented { get; set; } = false;
private static int MaxHeight => 500;
private bool Truncate { get; set; } = true;
private bool CwToggle { get; set; } = true;
private void ToggleCw()
{
CwToggle = !CwToggle;
StateHasChanged();
}
private void ToggleTruncate()
{
Truncate = !Truncate;
}
}