Skip to content

Commit

Permalink
refactor: changed hard code item rarity colors to css variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Makrowave authored and purifetchi committed Jan 18, 2024
1 parent fa77b2b commit b10b8f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 8 additions & 8 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 @@ -43,7 +43,7 @@
[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()
{
Expand All @@ -55,12 +55,12 @@
{
_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;
}

0 comments on commit b10b8f1

Please sign in to comment.