Module: Card::Set::All::Modal::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb

Constant Summary collapse

{ small: "sm", medium: nil, large: "lg",  full: "full", xl: "xl" }.freeze
{ type: "button",
"data-bs-dismiss": "modal",
"data-cy": "close-modal" }.freeze

Instance Method Summary collapse

Instance Method Details

#add_modal_size_class(classes, size) ⇒ Object



97
98
99
100
101
102
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 97

def add_modal_size_class classes, size
  size = normalize_modal_size_class size
  return if size == :medium || size.blank?

  classes << "modal-#{MODAL_SIZE[size]}"
end


61
62
63
64
65
66
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 61

def modal_close_button link_text="Close", opts={}
  classes = opts.delete(:class)
  button_opts = opts.merge(MODAL_CLOSE_OPTS)
  add_class button_opts, classes if classes
  button_tag link_text, button_opts
end


88
89
90
91
92
93
94
95
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 88

def modal_dialog_classes opts
  classes = [classy("modal-dialog"), "modal-dialog-centered"]
  return classes unless opts.present?

  add_modal_size_class classes, opts[:size]
  # classes << "modal-dialog-centered" if opts[:vertically_centered]
  classes.join " "
end


73
74
75
76
77
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 73

def modal_link text=nil, opts={}
  opts = modal_link_opts(opts)
  opts[:path][:layout] ||= :modal
  link_to text, opts
end


79
80
81
82
83
84
85
86
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 79

def modal_link_opts opts
  add_class opts, "slotter"
  opts.reverse_merge! path: {},
                      "data-slotter-mode": "modal",
                      "data-modal-class": modal_dialog_classes(opts),
                      remote: true
  opts
end


68
69
70
71
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 68

def modal_submit_button opts={}
  add_class opts, "submit-button _close-modal"
  submit_button opts
end

#normalize_modal_size_class(size) ⇒ Object



104
105
106
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 104

def normalize_modal_size_class size
  size.in?(MODAL_SIZE.keys) ? size : cast_modal_option(size)
end


57
58
59
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 57

def show_in_modal_link link_text, body
  link_to_view :modal, link_text, "data-modal-body": body, "data-slotter-mode": "modal"
end


47
48
49
50
51
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 47

view :close_modal_link, unknown: true do
  link_to icon_tag(:close), path: "",
                            class: "_close-modal btn-close",
                            "data-bs-dismiss": "modal"
end


22
23
24
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 22

view :modal, wrap: :modal do
  ""
end


37
38
39
40
41
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 37

view :modal_footer, unknown: true do
  button_tag "Close",
             class: "btn-xs _close-modal float-end",
             "data-bs-dismiss" => "modal"
end


43
44
45
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 43

view :modal_link do
  modal_link _render_title, size: voo.size
end


26
27
28
29
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 26

view :modal_menu, unknown: true, wrap: :modal_menu do
  [render_close_modal_link,
   render_pop_out_modal_link(optional: :show)]
end


33
34
35
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 33

view :modal_title, unknown: true do
  ""
end


53
54
55
# File 'platypus/tmp/set/gem-defaults/mod031-layout/all/modal.rb', line 53

view :pop_out_modal_link, unknown: :blank do
  link_to icon_tag(:modal), path: {}, class: "pop-out-modal btn-close"
end