class NfgUi::Bootstrap::Components::Modal

Bootstrap Modal Component getbootstrap.com/docs/4.1/components/modal/

Public Instance Methods

component_family() click to toggle source

NOTE: ARIALABELLEDBY has not been introduced on speed modals. ex: aria-labelledby=“exampleModalLabel” which is then the ID of the modal title element

# File lib/nfg_ui/bootstrap/components/modal.rb, line 14
def component_family
  :modal
end
render() { |: body)| ... } click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 26
def render
  super do
    content_tag(:div, class: modal_dialog_css_classes, role: 'document') do
      content_tag(:div, class: 'modal-content') do
        capture do
          # Optionally, leave title nil
          # and the title / dismiss functionality is left out.
          if title.present?
            concat(NfgUi::Bootstrap::Components::ModalHeader.new({ title: title }, view_context).render)
          end
          if render_in_body
            concat(NfgUi::Bootstrap::Components::ModalBody.new({ body: (block_given? ? yield : body) }, view_context).render)
          else
            concat(block_given? ? yield : body)
          end
          if footer
            concat(NfgUi::Bootstrap::Components::ModalFooter.new({ body: footer }, view_context).render)
          end
        end
      end
    end
  end
end
render_in_body() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 50
def render_in_body
  options.fetch(:render_in_body, true)
end
size() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 54
def size
  options.fetch(:size, nil)
end
title() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 18
def title
  options.fetch(:title, nil)
end

Private Instance Methods

assistive_html_attributes() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 86
def assistive_html_attributes
  super.merge(role: 'dialog', tabindex: '-1', aria: { hidden: 'true' })
end
css_classes() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 60
def css_classes
  [
    super,
    'fade'
  ].join(' ')
end
modal_dialog_css_classes() click to toggle source
non_html_attribute_options() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 74
def non_html_attribute_options
  super.push((:footer if footer.present?), (:title if title.present?), :size)
end
resized?() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 78
def resized?
  [:sm, :lg, :xl].include?(size)
end
size_css_class() click to toggle source
# File lib/nfg_ui/bootstrap/components/modal.rb, line 82
def size_css_class
  "#{component_css_class}-#{size}"
end