Class: Fluxbit::StepperComponent

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

Overview

The ‘Fluxbit::StepperComponent` is a customizable stepper component that extends `Fluxbit::Component`. It provides a visual representation of a multi-step process, supporting both horizontal and vertical orientations with various styling options including different colors and states.

Examples:

Basic usage

= fx_stepper do |stepper|
  = stepper.with_step(title: "Step 1", state: :completed)
  = stepper.with_step(title: "Step 2", state: :active)
  = stepper.with_step(title: "Step 3")
end

See Also:

  • For detailed documentation.

Defined Under Namespace

Classes: Step

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

Initializes the stepper component with the given properties.

Parameters:

  • **props (Hash)

    The properties to customize the stepper.

  • props (Hash)

    a customizable set of options

Options Hash (**props):

  • :orientation (Symbol) — default: :horizontal

    The orientation of the stepper (:horizontal, :vertical).

  • :variant (Symbol) — default: :default

    The variant of the stepper (:default, :progress, :detailed).

  • :color (Symbol) — default: :blue

    The color theme of the active step (:blue, :green, :red, :yellow, :indigo, :purple).

  • :remove_class (String) — default: ''

    CSS classes to remove from the default class list.

  • **props (Hash)

    Remaining options declared as HTML attributes.



36
37
38
39
40
41
42
43
44
45
46
# File 'app/components/fluxbit/stepper_component.rb', line 36

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

  @orientation = options @props.delete(:orientation), collection: styles[:base].keys, default: @@orientation
  @variant = options @props.delete(:variant), collection: styles[:list].keys, default: @@variant
  @color = options @props.delete(:color), collection: styles[:step][:default][:active].keys, default: @@color

  add class: styles[:base][@orientation], to: @props, first_element: true
  remove_class_from_props(@props)
end

Instance Method Details

#callObject



48
49
50
51
52
53
54
# File 'app/components/fluxbit/stepper_component.rb', line 48

def call
  tag.div(**@props) do
    tag.ol(class: styles[:list][@variant][@orientation]) do
      safe_join(steps.map.with_index { |step, index| render_step(step, index) })
    end
  end
end