Class: StimulusPlumbers::Components::Popover

Inherits:
Plumber::Base show all
Defined in:
lib/stimulus_plumbers/components/popover.rb,
lib/stimulus_plumbers/components/popover/builder.rb

Defined Under Namespace

Classes: Builder

Constant Summary

Constants included from Plumber::HtmlOptions

Plumber::HtmlOptions::STIMULUS_SPACEJOIN_KEYS

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::HtmlOptions

#merge_data_options, #merge_html_options, #merge_string_option, #normalize_part

Constructor Details

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

Instance Method Details

#render(interactive: true, **kwargs, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stimulus_plumbers/components/popover.rb', line 6

def render(interactive: true, **kwargs, &block)
  html_options = merge_html_options(
    { classes: theme.resolve(:popover).fetch(:classes, "") },
    kwargs
  )

  builder = Popover::Builder.new(template)
  template.capture(builder, &block)

  template.(:div, **html_options) do
    wrapped_content = if interactive
                        template.(:template, builder.content_html)
                      else
                        builder.content_html
                      end
    template.safe_join([builder.activator_html, wrapped_content])
  end
end