Class: NfgUi::Bootstrap::Components::Alert

Inherits:
Base
  • Object
show all
Includes:
Utilities::Dismissible, Utilities::Headable, Utilities::Themeable
Defined in:
lib/nfg_ui/bootstrap/components/alert.rb

Overview

Bootstrap Alert Component

Direct Known Subclasses

Components::Elements::Alert

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Themeable

#outlined, #theme

Methods included from Utilities::Headable

#heading

Methods included from Utilities::Dismissible

#dismissible

Methods inherited from Base

#component_family, #data, #href, #html_options, #id, #initialize, #style

Constructor Details

This class inherits a constructor from NfgUi::Bootstrap::Components::Base

Instance Method Details

#renderObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nfg_ui/bootstrap/components/alert.rb', line 12

def render
  (: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
            (:span, "×".html_safe, aria: { hidden: 'true' } )
          end
        )
      end
      if heading
        concat((:h4, heading, class: 'alert-heading'))
      end
      concat(block_given? ? yield : body)
    end
  end
end