Class: Bs5::AlertComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bs5::AlertComponent
- Includes:
- ActiveModel::Validations, ComponentsHelper
- Defined in:
- app/components/bs5/alert_component.rb
Constant Summary collapse
- STYLES =
%i[primary secondary success danger warning info light dark].freeze
Constants included from ComponentsHelper
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#is_dismissable ⇒ Object
readonly
Returns the value of attribute is_dismissable.
Instance Method Summary collapse
- #before_render ⇒ Object
-
#initialize(color: :primary, is_dismissable: false) ⇒ AlertComponent
constructor
A new instance of AlertComponent.
- #render? ⇒ Boolean
Methods included from ComponentsHelper
#bs5_collapse, #bs5_popover, #bs5_tooltip
Constructor Details
#initialize(color: :primary, is_dismissable: false) ⇒ AlertComponent
Returns a new instance of AlertComponent.
13 14 15 16 |
# File 'app/components/bs5/alert_component.rb', line 13 def initialize(color: :primary, is_dismissable: false) @color = color.to_sym @is_dismissable = is_dismissable end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
8 9 10 |
# File 'app/components/bs5/alert_component.rb', line 8 def color @color end |
#is_dismissable ⇒ Object (readonly)
Returns the value of attribute is_dismissable.
8 9 10 |
# File 'app/components/bs5/alert_component.rb', line 8 def is_dismissable @is_dismissable end |
Instance Method Details
#before_render ⇒ Object
18 19 20 |
# File 'app/components/bs5/alert_component.rb', line 18 def before_render raise errors..to_sentence if invalid? end |
#render? ⇒ Boolean
22 23 24 |
# File 'app/components/bs5/alert_component.rb', line 22 def render? content.present? end |