1
0
mirror of synced 2024-12-03 02:27:20 +01:00
TaikoLocalServer/TaikoWebUI/Components/Song/SongLeaderboardCard.razor
2024-06-03 11:03:09 -04:00

83 lines
3.7 KiB
Plaintext

@inject HttpClient Client;
@inject Blazored.LocalStorage.ILocalStorageService LocalStorage;
@using TaikoWebUI.Utilities;
<MudCard Outlined="true" Elevation="0">
<MudCardHeader>
<MudGrid Spacing="2" Class="align-center pb-2">
<MudItem xs="12" md="6">
<MudText Typo="Typo.h6">@Localizer["Leaderboard"]</MudText>
</MudItem>
<MudItem xs="12" md="6">
<MudToggleGroup T="string" Label="@Localizer["Difficulty"]" Variant="Variant.Outlined" Dense="true" ValueChanged="(value) => OnDifficultyChange(value)" Value="SelectedDifficulty">
@foreach (var difficulty in Enum.GetValues(typeof(Difficulty)))
{
if ((Difficulty)difficulty == Difficulty.None)
{
continue;
}
<MudToggleItem Value="@difficulty.ToString()">
<div class="d-flex align-center">
<img src="@($"/images/difficulty_{difficulty}.png")" alt="@difficulty.ToString()" title="@difficulty.ToString()" style="@Constants.ICON_STYLE"/>
</div>
</MudToggleItem>
}
</MudToggleGroup>
</MudItem>
</MudGrid>
</MudCardHeader>
<MudCardContent Class="pa-0">
@if (response == null || isLoading == true)
{
<MudCircularProgress />
}
else if (response.Leaderboard.Count == 0)
{
<MudGrid>
<MudItem xs="12">
<MudText Align="Align.Center" Class="my-16">
@Localizer["NoData"]
</MudText>
</MudItem>
</MudGrid>
}
else
{
<MudTable Items="@response.Leaderboard" Class="leaderboard-table" Elevation="0" Outlined="false" Dense="true" Striped="true">
<HeaderContent>
<MudTh>@Localizer["Rank"]</MudTh>
<MudTh>@Localizer["Player"]</MudTh>
<MudTh>@Localizer["Score"]</MudTh>
<MudTh>@Localizer["Rank"]</MudTh>
<MudTh>@Localizer["Crown"]</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.Rank</MudTd>
<MudTd>
<MudStack Row="true" AlignItems="AlignItems.Baseline">
<MudText Typo="Typo.body1">@context.UserName</MudText>
<MudText Typo="Typo.caption">(@Localizer["ID"]: @context.Baid)</MudText>
</MudStack>
</MudTd>
<MudTd>@context.BestScore</MudTd>
<MudTd>
@if (context.BestScoreRank is not ScoreRank.None)
{
<img src="@($"/images/rank_{context.BestScoreRank}.png")" alt="@(ScoreUtils.GetRankText(context.BestScoreRank))" title="@(ScoreUtils.GetRankText(context.BestScoreRank))" style="@Constants.ICON_STYLE"/>
}
else
{
<MudText Typo="Typo.body1">—</MudText>
}
</MudTd>
<MudTd>
<img src="@($"/images/crown_{context.BestCrown}.png")" alt="@(ScoreUtils.GetCrownText(context.BestCrown))" title="@(ScoreUtils.GetCrownText(context.BestCrown))" style="@Constants.ICON_STYLE"/>
</MudTd>
</RowTemplate>
</MudTable>
}
</MudCardContent>
</MudCard>