Class: NfgUi::Bootstrap::Components::Modal

Inherits:
Base
  • Object
show all
Defined in:
lib/nfg_ui/bootstrap/components/modal.rb

Overview

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

Direct Known Subclasses

Components::Patterns::Modal

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#component_familyObject

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



14
15
16
# File 'lib/nfg_ui/bootstrap/components/modal.rb', line 14

def component_family
  :modal
end


22
23
24
# File 'lib/nfg_ui/bootstrap/components/modal.rb', line 22

def footer
  options.fetch(:footer, nil)
end

#renderObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/nfg_ui/bootstrap/components/modal.rb', line 26

def render
  super do
    (:div, class: modal_dialog_css_classes, role: 'document') do
      (: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_bodyObject



50
51
52
# File 'lib/nfg_ui/bootstrap/components/modal.rb', line 50

def render_in_body
  options.fetch(:render_in_body, true)
end

#sizeObject



54
55
56
# File 'lib/nfg_ui/bootstrap/components/modal.rb', line 54

def size
  options.fetch(:size, nil)
end

#titleObject



18
19
20
# File 'lib/nfg_ui/bootstrap/components/modal.rb', line 18

def title
  options.fetch(:title, nil)
end