Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: moved rarity color to game.css #36

Merged
merged 2 commits into from
Jan 18, 2024
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
18 changes: 9 additions & 9 deletions Server/Components/UI/ItemCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="col">
<div class="card" style="width: 15rem;">
<div class="card-header" style="background-color: @_color">
<div class="card-header" style="background-color: var(@_color)">
@Item.Name
</div>
<div class="card-body">
Expand Down Expand Up @@ -35,32 +35,32 @@
private readonly Guid guid = Guid.NewGuid();

List<string> messages = new List<string>();
private async Task ShowItemHistoryAsync() { } //await collapse1.ShowAsync();

Check warning on line 38 in Server/Components/UI/ItemCard.razor

View workflow job for this annotation

GitHub Actions / Checks

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
private async Task HideItemHistoryAsync() { } //await collapse1.HideAsync();

Check warning on line 39 in Server/Components/UI/ItemCard.razor

View workflow job for this annotation

GitHub Actions / Checks

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
[Parameter] public Item Item { get; set; } = null!;
[Parameter] public bool IsEquipped { get; set; }
[Parameter] public bool ItemHistory { get; set; }
[Parameter] public EventCallback OnEquipClicked { get; set; }
[Parameter] public EventCallback OnUnequipClicked { get; set; }

private string _color = "gray";
private string _color = "--rarity-common";

protected override void OnInitialized()
{
//ChangeColor();
ChangeColor();
base.OnInitialized();
}

private void ChangeColor()
{
_color = Item.Rarity switch
{
ItemRarity.Common => "gray",
ItemRarity.Uncommon => "#8ef059",
ItemRarity.Rare => "#5963f0",
ItemRarity.Insane => "#f54c40",
ItemRarity.Epic => "#b423f7",
ItemRarity.Legendary => "gold",
ItemRarity.Common => "--rarity-common",
ItemRarity.Uncommon => "--rarity-uncommon",
ItemRarity.Rare => "--rarity-rare",
ItemRarity.Insane => "--rarity-insane",
ItemRarity.Epic => "--rarity-epic",
ItemRarity.Legendary => "--rarity-legendary",
_ => _color
};
}
Expand Down
9 changes: 9 additions & 0 deletions Server/wwwroot/css/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ body {
justify-content: center;
align-items: center;
}

:root {
--rarity-common: #808080;
--rarity-uncommon: #8ef059;
--rarity-rare: #5963f0;
--rarity-insane: #f54c40;
--rarity-epic: #b423f7;
--rarity-legendary: gold;
}
Loading