Class: StimulusPlumbers::Components::Card

Inherits:
Plumber::Base show all
Defined in:
lib/stimulus_plumbers/components/card.rb,
lib/stimulus_plumbers/components/card/section.rb

Defined Under Namespace

Classes: Section

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(title: nil, **kwargs, &block) ⇒ Object



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

def render(title: nil, **kwargs, &block)
  html_options = merge_html_options(
    { classes: theme.resolve(:card).fetch(:classes, "") },
    kwargs
  )

  template.(:div, **html_options) do
    template.safe_join(
      [
        (template.(:h2, title) if title.present?),
        template.capture(&block)
      ].compact
    )
  end
end

#section(title: nil, **kwargs, &block) ⇒ Object



22
23
24
# File 'lib/stimulus_plumbers/components/card.rb', line 22

def section(title: nil, **kwargs, &block)
  Card::Section.new(template).render(title: title, **kwargs, &block)
end