Class: Daisy::DataDisplay::TimelineEventComponent

Inherits:
LocoMotion::BaseComponent show all
Defined in:
app/components/daisy/data_display/timeline_event_component.rb

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

Methods inherited from LocoMotion::BaseComponent

build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces

Methods included from LocoMotion::Concerns::InspectableComponent

#build_inspect_string

Constructor Details

#initialize(*args, **kws, &block) ⇒ TimelineEventComponent

Creates a new timeline event component.

Parameters:

  • kws (Hash)

    The keyword arguments for the component.

Options Hash (**kws):

  • :start (String)

    Text to display in the start section. You can also provide custom content using the start slot.

  • :middle (String)

    Text to display in the middle section. You can also provide custom content using the middle slot.

  • :middle_icon (String)

    Name of a heroicon to display in the middle section. Ignored if middle is provided.

  • :end (String)

    Text to display in the end section. You can also provide custom content using the end slot.



68
69
70
71
72
73
74
75
76
77
78
# File 'app/components/daisy/data_display/timeline_event_component.rb', line 68

def initialize(*args, **kws, &block)
  super(*args, **kws, &block)

  @event_index = nil
  @events_length = nil

  @simple_start = config_option(:start)
  @simple_middle = config_option(:middle)
  @simple_middle_icon = config_option(:middle_icon)
  @simple_end = config_option(:end)
end

Instance Method Details

#before_renderObject



80
81
82
83
84
85
86
87
# File 'app/components/daisy/data_display/timeline_event_component.rb', line 80

def before_render
  set_tag_name(:component, :li)

  setup_parts
  setup_separator

  super
end

#set_event_index(index) ⇒ Object

rubocop:disable Naming/AccessorMethodName



100
101
102
# File 'app/components/daisy/data_display/timeline_event_component.rb', line 100

def set_event_index(index)
  @event_index = index
end

#set_events_length(length) ⇒ Object



104
105
106
# File 'app/components/daisy/data_display/timeline_event_component.rb', line 104

def set_events_length(length)
  @events_length = length
end

#setup_partsObject



89
90
91
92
93
# File 'app/components/daisy/data_display/timeline_event_component.rb', line 89

def setup_parts
  add_css(:start, "timeline-start")
  add_css(:middle, "timeline-middle")
  add_css(:end, "timeline-end")
end

#setup_separatorObject



95
96
97
# File 'app/components/daisy/data_display/timeline_event_component.rb', line 95

def setup_separator
  set_tag_name(:separator, :hr)
end