Skip to content

Commit

Permalink
refactor: dark text types badge to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
fchagasjr committed Dec 27, 2023
1 parent f45eafa commit d0dbba6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/components/badge_component.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class BadgeComponent < ViewComponent::Base
DARK_TEXT_TYPES = [:warning, :light]

attr_reader :text, :type, :rounded

def initialize(text:, type:, rounded: false)
Expand All @@ -9,8 +11,7 @@ def initialize(text:, type:, rounded: false)

def style
badge_style = ["bg-#{type}"]
dark_text_types = [:warning, :light]
badge_style.push("text-dark") if dark_text_types.include?(type)
badge_style.push("text-dark") if DARK_TEXT_TYPES.include?(type)
badge_style.push("rounded-pill") if rounded
badge_style.join(" ")
end
Expand Down

0 comments on commit d0dbba6

Please sign in to comment.