Class: StimulusPlumbers::Components::Divider

Inherits:
Plumber::Base show all
Defined in:
lib/stimulus_plumbers/components/divider.rb

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

#extract_classes, #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(label = nil, **kwargs) ⇒ Object



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

def render(label = nil, **kwargs)
  divider_opts = merge_html_options(
    { classes: theme.resolve(:divider).fetch(:classes, "") },
    kwargs
  )
  template.(:div, role: "separator", **divider_opts) do
    if label.blank?
      hr_classes = theme.resolve(:divider_separator).fetch(:classes, "")
      template.tag.hr(class: hr_classes)
    else
      render_with(label)
    end
  end
end