Class: Railsboot::AlertComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::AlertComponent
- Defined in:
- app/components/railsboot/alert_component.rb
Overview
ViewComponent: renders the alert block.
Instance Method Summary collapse
- #before_render ⇒ Object protected
-
#initialize(color: DEFAULT_COLOR, dismissible: false, **html_attributes) ⇒ AlertComponent
constructor
A new instance of AlertComponent.
Constructor Details
#initialize(color: DEFAULT_COLOR, dismissible: false, **html_attributes) ⇒ AlertComponent
Returns a new instance of AlertComponent.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/components/railsboot/alert_component.rb', line 4 def initialize(color: DEFAULT_COLOR, dismissible: false, **html_attributes) @color = fetch_or_raise(color, COLORS) @dismissible = dismissible @html_attributes = html_attributes @html_attributes[:tag] = "div" @html_attributes[:class] = class_names( "alert", "alert-#{@color}", { "alert-dismissible fade show" => @dismissible }, html_attributes.delete(:class) ) end |
Instance Method Details
#before_render ⇒ Object (protected)
20 21 22 |
# File 'app/components/railsboot/alert_component.rb', line 20 def before_render @html_attributes["role"] = "alert" end |