Class: StimulusPlumbers::Components::Timeline::Event

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

Defined Under Namespace

Classes: Slots

Instance Attribute Summary collapse

Attributes inherited from Plumber::Base

#template

Class Method Summary collapse

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 Attribute Details

#interactiveObject (readonly)

Returns the value of attribute interactive.



7
8
9
# File 'lib/stimulus_plumbers/components/timeline/event.rb', line 7

def interactive
  @interactive
end

Class Method Details

.detail_id_for(event_id) ⇒ Object



9
10
11
# File 'lib/stimulus_plumbers/components/timeline/event.rb', line 9

def self.detail_id_for(event_id)
  [event_id, "detail"].compact.join("_")
end

Instance Method Details

#render(datetime: nil, id: nil, interactive: false, orientation: :vertical, **kwargs) {|slots| ... } ⇒ Object

Yields:

  • (slots)


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/stimulus_plumbers/components/timeline/event.rb', line 13

def render(datetime: nil, id: nil, interactive: false, orientation: :vertical, **kwargs, &block)
  @detail_id = self.class.detail_id_for(id || template.sp_dom_id)

  slots = Timeline::Event::Slots.new
  yield slots if block_given?

  validate_slots!(slots, datetime: datetime)
  @orientation = orientation
  @interactive = interactive || slots.trigger?

  html_options = merge_html_options(theme.resolve(:timeline_item, orientation: orientation), kwargs)
  render_event(slots, datetime: datetime, html_options: html_options)
end