Class: StimulusPlumbers::Components::Timeline

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

Defined Under Namespace

Classes: Event, Group

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

#event(datetime: nil, **kwargs, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/stimulus_plumbers/components/timeline.rb', line 17

def event(datetime: nil, **kwargs, &block)
  ev = Timeline::Event.new(template)
  html = ev.render(
    datetime:    datetime,
    interactive: @interactive,
    orientation: @orientation,
    **kwargs,
    &block
  )
  @interactive ||= ev.interactive
  template.concat(html)
end

#render(orientation: :vertical, interactive: false, **kwargs, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/stimulus_plumbers/components/timeline.rb', line 6

def render(orientation: :vertical, interactive: false, **kwargs, &block)
  @interactive = interactive
  @orientation = orientation
  content    = template.capture(self, &block)
  stimulus   = @interactive ? { data: { controller: "timeline" } } : {}
  ol_options = merge_html_options(theme.resolve(:timeline, orientation: orientation), kwargs, stimulus)
  list       = template.(:ol, content, **ol_options)

  orientation.to_sym == :vertical ? render_vertical_wrapper(list) : list
end