Class: Fluxbit::TimelineItemComponent

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

Overview

The ‘Fluxbit::TimelineItemComponent` is a component for rendering individual timeline items.

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::TimelineItemComponent

Initializes the TimelineItem component.

Parameters:

  • **props (Hash)

    The properties to customize the timeline item.

  • props (Hash)

    a customizable set of options

Options Hash (**props):

  • :variant (Symbol) — default: nil

    The timeline variant from parent component.

  • :title (String) — default: nil

    The title of the timeline item.

  • :description (String) — default: nil

    The description text.

  • :date (String) — default: nil

    The date or time for the item.

  • :icon (String, Symbol) — default: nil

    The icon to display in the timeline indicator.

  • :status (Symbol) — default: :default

    The status of the item (:default, :completed, :current, :pending).

  • :color (Symbol) — default: :blue

    The color theme (:blue, :green, :red, :yellow, :purple, :indigo).

  • :href (String) — default: nil

    URL to make the item clickable.

  • :ring (Symbol) — default: :default

    The ring size around indicator (:none, :small, :default, :large).

  • :remove_class (String) — default: ''

    CSS classes to remove from the default class list.

  • **props (Hash)

    Remaining options declared as HTML attributes.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/fluxbit/timeline_item_component.rb', line 23

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

  @variant = @props.delete(:variant) || :default
  @title = @props.delete(:title)
  @description = @props.delete(:description)
  @date = @props.delete(:date)
  @icon = @props.delete(:icon)
  @status = options @props.delete(:status), collection: styles[:item][:indicator][:status].keys, default: :default
  @color = options @props.delete(:color), collection: styles[:item][:indicator][:colors].keys, default: :blue
  @ring = options @props.delete(:ring), collection: styles[:item][:indicator][:rings].keys, default: :default
  @href = @props.delete(:href)

  if @variant != :stepper
    add class: styles[:item][:base], to: @props
  end

  remove_class_from_props(@props)
end

Instance Method Details

#before_renderObject



44
45
46
47
48
49
50
# File 'app/components/fluxbit/timeline_item_component.rb', line 44

def before_render
  super
  if @variant == :stepper
    # Add stepper classes after @is_last is set
    add class: styles[:stepper][:item], to: @props
  end
end