Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Provide an alternative when a player headshot is missing. #92

Merged
merged 3 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Client/Features/Admin/AddPlayer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<MudItem lg="4" xs="12" Class="d-flex justify-center align-center">
<MudGrid>
<MudItem xs="12" Class="d-flex justify-center">
<MudAvatar Image="@_previewHeadshotUrl" Size="Size.Large"/>
<Avatar Image="@_previewHeadshotUrl" Size="Size.Large"/>
</MudItem>
<MudItem xs="12">
<EditForm Model=_playerPreviewForm OnValidSubmit=PreviewHeadshotAsync>
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Features/Dashboard/Shared/RankedCard.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<MudCard Style=@BackgroundColor Class="ma-1">
<MudCardHeader>
<CardHeaderAvatar>
<MudAvatar [email protected]></MudAvatar>
<Avatar [email protected]></Avatar>
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="NameTypo">@RankedItem.Name</MudText>
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Features/FreeAgents/Detail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else
<MudCardContent>
<MudGrid>
<MudItem lg=3 xs=12 Class="d-flex flex-column align-center">
<MudAvatar Image=@_result.HeadShotUrl Size=Size.Large />
<Avatar Image=@_result.HeadShotUrl Size=Size.Large />
<MudText Typo=Typo.h5 Align=Align.Center Color=Color.Tertiary>
@_result.Name
</MudText>
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Features/Teams/List.razor
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ else
<MudCard>
<MudCardHeader Class="mud-card-header-override">
<CardHeaderAvatar>
<MudAvatar [email protected] Size=Size.Large></MudAvatar>
<Avatar [email protected] Size=Size.Large></Avatar>
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.h5">@team.Name</MudText>
Expand Down
17 changes: 17 additions & 0 deletions src/Client/Shared/Components/Avatar.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@if(string.IsNullOrEmpty(Image))
{
<div class="mud-theme-dark pa-2 rounded-circle">
<MudIcon [email protected] Size=Size @attributes=AllOtherAttributes></MudIcon>
</div>
}
else
{
<MudAvatar Image=@Image Size=Size @attributes=AllOtherAttributes></MudAvatar>
}


@code {
[Parameter] public string? Image { get; set; }
[Parameter] public Size Size { get; set; } = Size.Medium;
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AllOtherAttributes { get; set; }
}
2 changes: 1 addition & 1 deletion src/Client/Shared/Components/NameWithImage.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="d-flex align-center">
<MudAvatar Image=@ImageUrl Class="mr-1"></MudAvatar>
<Avatar Image=@ImageUrl Class="mr-1"></Avatar>
@Name
</div>

Expand Down
25 changes: 25 additions & 0 deletions src/Tests/Shared/Components/AvatarTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using DynamoLeagueBlazor.Client.Shared.Components;

namespace DynamoLeagueBlazor.Tests.Shared.Components;

public class AvatarTests : UITestBase
{
[Fact]
public void GivenNoImageUrl_ThenIsAnIcon()
{
var component = RenderComponent<Avatar>();

component.Markup.Should().Contain("icon");
}

[Fact]
public void GivenAnImageUrl_ThenIsAnAvatar()
{
var component = RenderComponent<Avatar>(parameters =>
{
parameters.Add(p => p.Image, RandomString);
});

component.Markup.Should().Contain("img");
}
}