This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<%= content_tag :span, class: classes do %> | ||
<%= text %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
module Games | ||
module Card | ||
class BadgeComponent < ViewComponent::Base | ||
BASE_CLASSES = "absolute -top-2 -right-2 uppercase p-2 text-xs rounded drop-shadow-md | ||
font-black lg:font-bold border".squish | ||
|
||
COLOR_CLASSES = { | ||
coming_soon: "bg-[#5A94FF] text-white border-[#4876cc]", | ||
pre_order: "bg-[#C65AFF] text-white border-[#763699]", | ||
new_release: "bg-[#ADFF5A] text-black border-[#80FE00]" | ||
}.freeze | ||
|
||
def initialize(game:) | ||
@game = game | ||
end | ||
|
||
private | ||
|
||
attr_reader :game | ||
|
||
def render? | ||
type.present? | ||
end | ||
|
||
def type | ||
if game.pre_order? then :pre_order | ||
elsif game.coming_soon? then :coming_soon | ||
elsif game.new_release? then :new_release | ||
end | ||
end | ||
|
||
def text | ||
{ | ||
coming_soon: t(".coming_soon"), | ||
pre_order: t(".pre_order"), | ||
new_release: t(".new_release") | ||
}[type] | ||
end | ||
|
||
def classes | ||
[BASE_CLASSES, COLOR_CLASSES[type]] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters