Class: StimulusPlumbers::Components::Popover::Renderer

Inherits:
StimulusPlumbers::Components::Plumber::Base show all
Defined in:
lib/stimulus_plumbers/components/popover/renderer.rb

Instance Attribute Summary

Attributes inherited from StimulusPlumbers::Components::Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from StimulusPlumbers::Components::Plumber::Base

#initialize, #theme

Methods included from StimulusPlumbers::Components::Plumber::HtmlOptions

#merge_html_options, #merge_string_option, #normalize_part

Constructor Details

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

Instance Method Details

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/stimulus_plumbers/components/popover/renderer.rb', line 25

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

  builder = 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