Class: Bs5::AlertComponent

Inherits:
ViewComponent::Base
  • Object
show all
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

ComponentsHelper::COMPONENTS

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colorObject (readonly)

Returns the value of attribute color.



8
9
10
# File 'app/components/bs5/alert_component.rb', line 8

def color
  @color
end

#is_dismissableObject (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_renderObject



18
19
20
# File 'app/components/bs5/alert_component.rb', line 18

def before_render
  raise errors.full_messages.to_sentence if invalid?
end

#render?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/components/bs5/alert_component.rb', line 22

def render?
  content.present?
end