Class: StimulusPlumbers::Components::OrderedList::Item

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/components/ordered_list/item.rb,
lib/stimulus_plumbers/components/ordered_list/item/slots.rb

Defined Under Namespace

Classes: Slots

Constant Summary collapse

HANDLE_ACTION =
"pointerdown->reorderable#onPointerDown pointermove->reorderable#onPointerMove " \
"pointerup->reorderable#onPointerUp"

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

#build(id:, handle: :item, &block) ⇒ Object



28
29
30
31
32
# File 'lib/stimulus_plumbers/components/ordered_list/item.rb', line 28

def build(id:, handle: :item, &block)
  @handle = handle
  html_options = merge_html_options(theme.resolve(:ordered_list_item), { id: id }, item_target_attrs)
  template.capture(html_options, &block)
end

#render(content = nil, id:, handle: :item, url: nil, target: nil, active: false, **html_options, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stimulus_plumbers/components/ordered_list/item.rb', line 10

def render(content = nil, id:, handle: :item, url: nil, target: nil, active: false, **html_options, &block)
  validate_options!(id, url, html_options)

  slots = build_slots(content, &block)

  build(id: id, handle: handle) do |attrs|
    template.(:li, **attrs) do
      template.safe_join(
        [
          render_icon_position(slots, :leading),
          render_body(slots, url: url, target: target, active: active, **html_options),
          render_icon_position(slots, :trailing)
        ]
      )
    end
  end
end