Iceshrimp.NET/Iceshrimp.Frontend/Components/ProfileInfo.razor

120 lines
No EOL
3.9 KiB
Text

@using Iceshrimp.Frontend.Localization
@using Iceshrimp.Shared.Schemas.Web
@using Microsoft.Extensions.Localization
@using Iceshrimp.Assets.PhosphorIcons
@using Iceshrimp.Frontend.Core.Miscellaneous
@inject IStringLocalizer<Localization> Loc;
<div class="profile-info">
<div class="badges">
@if (UserProfile.Lang != null && (UserProfile.Pronouns?.TryGetValue(UserProfile.Lang, out var pronouns) ?? false))
{
<span class="badge">@pronouns</span>
}
@switch (UserProfile.Role)
{
case Role.Moderator:
<span class="badge">
<Icon Name="Icons.ShieldWarning" Size="1.3em"/>
@Loc["Moderator"]
</span>
break;
case Role.Admin:
<span class="badge">
<Icon Name="Icons.ShieldStar" Size="1.3em"/>
@Loc["Admin"]
</span>
break;
case Role.None:
break;
default:
throw new ArgumentOutOfRangeException();
}
@if (User.IsBot)
{
<span class="badge">
<Icon Name="Icons.Robot" Size="1.3em"/>
@Loc["Automated"]
</span>
}
@if (UserProfile.IsLocked)
{
<span class="badge">
<Icon Name="Icons.Lock" Size="1.3em"/>
@Loc["Private"]
</span>
}
</div>
@if (UserProfile.Bio != null)
{
<div class="bio">
<MfmText Text="@UserProfile.Bio" Emoji="@Emojis"/>
</div>
}
<div class="data">
@if (UserProfile.Birthday != null)
{
<div class="birthday field">
<span class="field-name">
<Icon Name="Icons.Balloon" Size="1.3em"/>
@Loc["Birthday"]
</span>
<span class="field-value">@UserProfile.Birthday</span>
</div>
}
@if (UserProfile.Location != null)
{
<div class="location field">
<span class="field-name">
<Icon Name="Icons.MapPin" Size="1.3em"/>
@Loc["Location"]
</span>
<span class="field-value">@UserProfile.Location</span>
</div>
}
@if (UserProfile.Pronouns != null)
{
<div class="pronouns field">
<span class="field-name">
<Icon Name="Icons.IdentificationCard" Size="1.3em"/>
@Loc["Pronouns"]
</span>
<span class="field-value">@string.Join(", ", UserProfile.Pronouns.Select(p => $"{p.Value} ({_languages.GetValueOrDefault(p.Key) ?? p.Key.ToUpper()})"))</span>
</div>
}
</div>
@if (UserProfile.Fields != null)
{
<div class="fields">
@foreach (var field in UserProfile.Fields)
{
<ProfileInfoField Field="field" Emojis="@Emojis"/>
}
</div>
}
<div class="metadata">
<div class="section">
<div class="field-data">
@UserProfile.Followers
</div>
<div class="field-text">
@Loc["Followers"]
</div>
</div>
<div class="section">
<div class="field-data">
@UserProfile.Following
</div>
<div class="field-text">
@Loc["Following"]
</div>
</div>
</div>
</div>
@code {
[Parameter] [EditorRequired] public required UserResponse User { get; set; }
[Parameter] [EditorRequired] public required UserProfileResponse UserProfile { get; set; }
[Parameter] [EditorRequired] public required List<EmojiResponse> Emojis { get; set; }
private Dictionary<string, string> _languages = LanguageHelper.Bcp47Languages;
}