Class: Railsboot::BadgeComponent
- Defined in:
- app/components/railsboot/badge_component.rb
Constant Summary
Constants inherited from Component
Component::COLORS, Component::DEFAULT_COLOR
Instance Method Summary collapse
-
#initialize(pill: false, color: DEFAULT_COLOR, **html_attributes) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Constructor Details
#initialize(pill: false, color: DEFAULT_COLOR, **html_attributes) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/components/railsboot/badge_component.rb', line 2 def initialize(pill: false, color: DEFAULT_COLOR, **html_attributes) @pill = pill @color = fetch_or_raise(color, COLORS) @html_attributes = html_attributes @html_attributes[:tag] = :span @html_attributes[:class] = class_names( "badge", "bg-#{@color}", {"rounded-pill" => @pill}, html_attributes.delete(:class) ) end |