Class: Bs5::BadgeComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bs5::BadgeComponent
- Includes:
- ActiveModel::Validations
- Defined in:
- app/components/bs5/badge_component.rb
Constant Summary collapse
- STYLES =
%i[primary secondary success danger warning info light dark].freeze
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #before_render ⇒ Object
-
#initialize(text:, color: :secondary, pill: false) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Constructor Details
#initialize(text:, color: :secondary, pill: false) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
12 13 14 15 16 |
# File 'app/components/bs5/badge_component.rb', line 12 def initialize(text:, color: :secondary, pill: false) @text = text @color = color.to_sym @pill = pill end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
7 8 9 |
# File 'app/components/bs5/badge_component.rb', line 7 def color @color end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'app/components/bs5/badge_component.rb', line 7 def text @text end |
Instance Method Details
#before_render ⇒ Object
18 19 20 |
# File 'app/components/bs5/badge_component.rb', line 18 def before_render raise errors..to_sentence if invalid? end |