[frontend/components] Add icon and theme color to note ticker

This commit is contained in:
pancakes 2025-03-28 00:45:52 +10:00
parent 66afc34bbd
commit 91c7a330b0
No known key found for this signature in database
4 changed files with 41 additions and 16 deletions

View file

@ -9,7 +9,7 @@
<UserDisplayName User="@NoteResponse.User"/>
</span>
<span class="metadata">
<NoteMetadata Visibility="NoteResponse.Visibility" InstanceName="@null" CreatedAt="DateTime.Parse(NoteResponse.CreatedAt)"/>
<NoteMetadata Visibility="NoteResponse.Visibility" CreatedAt="DateTime.Parse(NoteResponse.CreatedAt)"/>
</span>
</div>
<NoteComponent Note="NoteResponse.Renote" Quote="NoteResponse.Quote" Indented="Indented" OpenNote="@OpenNote"/>

View file

@ -14,6 +14,8 @@
<NoteMetadata
Visibility="@Note.Visibility"
InstanceName="@Note.User.InstanceName"
InstanceIcon="@Note.User.InstanceIconUrl"
InstanceColor="@Note.User.InstanceColor"
CreatedAt="DateTime.Parse(Note.CreatedAt)"
OpenNoteId="@(OpenNote ? Note.Id : null)"
/>

View file

@ -34,15 +34,23 @@
}
</span>
</span>
@if (InstanceName != null)
{
<span class="instance">@InstanceName</span>
}
<span class="ticker" title="@InstanceName">
@if (InstanceIcon != null)
{
<img class="icon" src="@InstanceIcon" alt="icon"/>
}
@if (InstanceName != null)
{
<span class="instance" style="@(InstanceColor != null ? "--color: " + InstanceColor + ";" : "")">@InstanceName</span>
}
</span>
</div>
@code {
[Parameter] [EditorRequired] public required DateTime CreatedAt { get; set; }
[Parameter] [EditorRequired] public required NoteVisibility Visibility { get; set; }
[Parameter] [EditorRequired] public required string? InstanceName { get; set; }
[Parameter] public string? OpenNoteId { get; set; }
[Parameter] [EditorRequired] public required DateTime CreatedAt { get; set; }
[Parameter] [EditorRequired] public required NoteVisibility Visibility { get; set; }
[Parameter] public string? InstanceName { get; set; }
[Parameter] public string? InstanceIcon { get; set; }
[Parameter] public string? InstanceColor { get; set; }
[Parameter] public string? OpenNoteId { get; set; }
}

View file

@ -28,14 +28,29 @@
font-size: 1rem;
}
}
}
.ticker {
display: inline-flex;
gap: 0.5em;
align-items: center;
/*Left align so the right side is truncated*/
align-self: start;
/*Margin on the left so non truncated names are aligned to the right*/
margin-left: auto;
font-size: 0.9em;
text-overflow: ellipsis;
overflow: clip;
.icon {
width: 1rem;
height: 1rem;
color: transparent;
border-radius: 4px;
line-height: 1;
}
.instance {
/*Left align so the right side is truncated*/
align-self: start;
/*Margin on the left so non truncated names are aligned to the right*/
margin-left: auto;
font-size: 0.9em;
text-overflow: ellipsis;
overflow: clip;
--color: var(--font-color);
color: var(--color);
}
}