Class: Para::Markup::Modal

Inherits:
Component show all
Defined in:
lib/para/markup/modal.rb

Instance Attribute Summary

Attributes inherited from Component

#view

Instance Method Summary collapse

Methods inherited from Component

#initialize

Constructor Details

This class inherits a constructor from Para::Markup::Component

Instance Method Details

#body(options = {}, &block) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/para/markup/modal.rb', line 50

def body(options = {}, &block)
  merge_class!(options, 'modal-body')

  (:div, options) do
    capture { block.call }
  end
end

#container(options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/para/markup/modal.rb', line 4

def container(options = {}, &block)
  merge_class!(options, 'modal')
  merge_class!(options, 'fade') unless options.delete(:fade) == false
  merge_class!(options, 'in') if options.delete(:displayed)

  options.reverse_merge!(
    tabindex: '-1',
    role: 'dialog',
    'aria-hidden' => 'true',
    'aria-labelledby' => options[:id]
  )

  options[:data] ||= {}
  options[:data]['para-admin-modal-target'] ||= 'modal'

  (:div, options) do
    (:div, class: 'modal-dialog') do
      (:div, class: 'modal-content') do
        (:div, class: 'modal-inner') do
          capture { block.call(self) }
        end
      end
    end
  end
end


58
59
60
61
62
63
64
# File 'lib/para/markup/modal.rb', line 58

def footer(options = {}, &block)
  merge_class!(options, 'modal-footer')

  (:div, options) do
    capture { block.call }
  end
end

#header(options = {}, &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/para/markup/modal.rb', line 30

def header(options = {}, &block)
  merge_class!(options, 'modal-header')

  (:div, options) do
    (
      :button,
      '×'.html_safe,
      class: 'close',
      type: 'button',
      'aria-hidden' => 'true',
      data: {
        action: 'click->para-admin-modal#closeModal'
      }
    ) +
      (:h4, class: 'modal-title') do
        capture { block.call }
      end
  end
end