Class: Fluxbit::TimelineComponent

Inherits:
Component
  • Object
show all
Includes:
Config::TimelineComponent
Defined in:
app/components/fluxbit/timeline_component.rb

Overview

The ‘Fluxbit::TimelineComponent` is a component for rendering customizable timelines.

Instance Method Summary collapse

Methods inherited from Component

#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?

Methods included from IconHelpers

#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon

Constructor Details

#initialize(**props) ⇒ Fluxbit::TimelineComponent

Initializes the Timeline component with various customization options.

Options Hash (**props):

  • :variant (Symbol) — default: :default

    The timeline variant (:default, :vertical, :stepper, :activity).

  • :position (Symbol) — default: :left

    The position of timeline indicators (:left, :center, :right).

  • :remove_class (String) — default: ''

    CSS classes to remove from the default class list.

  • **props (Hash)

    Remaining options declared as HTML attributes.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/fluxbit/timeline_component.rb', line 24

def initialize(**props)
  super
  @props = props

  @variant = options @props.delete(:variant), collection: styles[:variants].keys, default: @@variant
  @position = options @props.delete(:position), collection: styles[:positions].keys, default: @@position

  add class: [
    styles[:base],
    styles[:variants][@variant],
    styles[:positions][@position]
  ], to: @props

  remove_class_from_props(@props)
end

Instance Method Details

#callObject



40
41
42
43
44
# File 'app/components/fluxbit/timeline_component.rb', line 40

def call
  (@variant == :stepper ? "ol" : "ul", **@props) do
    items_with_position.join.html_safe
  end
end