Class: StimulusPlumbers::Components::Popover::Trigger

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/components/popover/trigger.rb

Constant Summary collapse

STIMULUS_ACTION =
[
  "click->#{STIMULUS_CONTROLLER}#toggle",
  "keydown.esc->#{STIMULUS_CONTROLLER}#close"
].join(" ").freeze

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::Renderer

#set_slots, #slot_block_for, #slot_kwargs_for, #slot_renderable?

Methods included from Plumber::Options::Aria

#labelled_aria

Methods included from Plumber::Options::Html

#merge_html_options

Constructor Details

This class inherits a constructor from StimulusPlumbers::Plumber::Base

Instance Method Details

#render(panel_id:, haspopup: "dialog", **kwargs, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stimulus_plumbers/components/popover/trigger.rb', line 12

def render(panel_id:, haspopup: "dialog", **kwargs, &block)
  html_options = merge_html_options(
    theme.resolve(:popover_trigger),
    {
      type: "button",
      aria: { haspopup: haspopup, expanded: "false", controls: panel_id },
      data: { popover_target: "trigger", action: STIMULUS_ACTION }
    },
    kwargs
  )
  template.(:button, block_given? ? template.capture(&block) : nil, **html_options)
end