class NfgUi::Bootstrap::Components::Alert

Bootstrap Alert Component

Public Instance Methods

render() { |: body)| ... } click to toggle source
# File lib/nfg_ui/bootstrap/components/alert.rb, line 12
def render
  content_tag(:div, html_options) do
    capture do
      if dismissible
        concat(
          NfgUi::Bootstrap::Components::Button.new({ as: :button, class: 'close', theme: nil, data: { dismiss: 'alert' }, aria: { label: 'Close' } }, view_context).render do
            content_tag(:span, "×".html_safe, aria: { hidden: 'true' } )
          end
        )
      end
      if heading
        concat(content_tag(:h4, heading, class: 'alert-heading'))
      end
      concat(block_given? ? yield : body)
    end
  end
end

Private Instance Methods

assistive_html_attributes() click to toggle source
# File lib/nfg_ui/bootstrap/components/alert.rb, line 32
def assistive_html_attributes
  super.merge!(role: 'alert')
end
css_classes() click to toggle source
# File lib/nfg_ui/bootstrap/components/alert.rb, line 36
def css_classes
  [
    super,
    ("#{component_css_class}-dismissible" if dismissible),
    ('fade' if dismissible),
    ('show' if dismissible)
  ].join(' ').squish
end
outlineable?() click to toggle source
# File lib/nfg_ui/bootstrap/components/alert.rb, line 45
def outlineable?
  false
end