Class: StimulusPlumbers::Components::Card

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

Defined Under Namespace

Classes: Slots

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::Renderer

#set_slots, #slot_block_for, #slot_kwargs_for, #slot_renderable?

Methods included from Plumber::Options::Aria

#labelled_aria

Methods included from Plumber::Options::Html

#merge_html_options

Constructor Details

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

Instance Method Details

#render(variant: :tertiary, title_tag: :h2, **kwargs) {|slots| ... } ⇒ Object

Yields:

  • (slots)


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(variant: :tertiary, title_tag: :h2, **kwargs, &block)
  slots = Card::Slots.new
  yield slots if block_given?

  html_options = merge_html_options(theme.resolve(:card, variant: variant), kwargs)
  template.(:div, **html_options) do
    template.safe_join(
      [
        render_header(slots, title_tag),
        render_body(slots),
        render_action(slots)
      ].compact
    )
  end
end