Class: StimulusPlumbers::Components::Card::Renderer

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

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_html_options, #merge_string_option, #normalize_part

Constructor Details

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

Instance Method Details

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



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

def card(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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/stimulus_plumbers/components/card/renderer.rb', line 23

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

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