Class: Railsboot::CalloutComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::CalloutComponent
- Defined in:
- app/components/railsboot/callout_component.rb
Constant Summary collapse
- VARIANTS =
["", "warning", "info", "danger"].freeze
- DEFAULT_VARIANT =
"".freeze
Instance Method Summary collapse
-
#initialize(variant: DEFAULT_VARIANT, **html_attributes) ⇒ CalloutComponent
constructor
A new instance of CalloutComponent.
- #render? ⇒ Boolean
Constructor Details
#initialize(variant: DEFAULT_VARIANT, **html_attributes) ⇒ CalloutComponent
Returns a new instance of CalloutComponent.
5 6 7 8 9 10 11 12 13 14 |
# File 'app/components/railsboot/callout_component.rb', line 5 def initialize(variant: DEFAULT_VARIANT, **html_attributes) @variant = fetch_or_fallback(variant, VARIANTS, DEFAULT_VARIANT) @html_attributes = html_attributes @html_attributes[:class] = class_names( "callout", {"callout-#{@variant}" => @variant.present?}, html_attributes.delete(:class) ) end |
Instance Method Details
#render? ⇒ Boolean
16 17 18 |
# File 'app/components/railsboot/callout_component.rb', line 16 def render? content.present? end |