Module: UltimateStaticModal::Helpers::ViewHelper

Defined in:
lib/ultimate_static_modal/helpers/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#static_drawer(position: nil, size: nil, **options, &block) ⇒ Object



10
11
12
13
14
15
# File 'lib/ultimate_static_modal/helpers/view_helper.rb', line 10

def static_drawer(position: nil, size: nil, **options, &block)
  cfg = UltimateTurboModal.configuration.drawer_config
  position = UltimateTurboModal::Base.validate_drawer_position!(position || cfg.position)
  size = UltimateTurboModal::Base.validate_drawer_size!(size || cfg.size)
  static_modal(drawer_position: position, size: size, **options, &block)
end

#static_drawer_template(id, **opts, &block) ⇒ Object



21
22
23
# File 'lib/ultimate_static_modal/helpers/view_helper.rb', line 21

def static_drawer_template(id, **opts, &block)
  (:template, id: id) { static_drawer(**opts, &block) }
end

#static_modal(**opts, &block) ⇒ Object



6
7
8
# File 'lib/ultimate_static_modal/helpers/view_helper.rb', line 6

def static_modal(**opts, &block)
  render(UltimateStaticModal.new(**opts), &block)
end

#static_modal_template(id, **opts, &block) ⇒ Object



17
18
19
# File 'lib/ultimate_static_modal/helpers/view_helper.rb', line 17

def static_modal_template(id, **opts, &block)
  (:template, id: id) { static_modal(**opts, &block) }
end

#static_modal_trigger(template_id, **button_opts, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ultimate_static_modal/helpers/view_helper.rb', line 25

def static_modal_trigger(template_id, **button_opts, &block)
  data = button_opts.delete(:data) || {}
  data = data.merge(
    controller: [data[:controller], "static-modal"].compact.join(" "),
    static_modal_id_value: template_id,
    action: [data[:action], "click->static-modal#open"].compact.join(" ")
  )

  button_opts = {type: "button"}.merge(button_opts).merge(data: data)
  button_tag(button_opts, &block)
end