Class: Plutonium::UI::Wizard::Stepper

Inherits:
Component::Base show all
Defined in:
lib/plutonium/ui/wizard/stepper.rb

Overview

The horizontal step indicator (§7). Renders the visible step path with a completed / current / upcoming state per step. Navigation mode gates which steps are clickable:

- :linear → only already-visited steps link back (no forward jumps).
- :free   → any visited step links (still no forward jumps to unvisited).

Branch-hidden steps are simply absent from visible_path, so they never appear here.

Instance Method Summary collapse

Methods included from Component::Behaviour

#around_template

Methods included from Component::Tokens

#classes, #tokens

Methods included from Component::Kit

#BuildActionButton, #BuildActionsDropdown, #BuildAvatar, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?

Constructor Details

#initialize(steps:, current:, visited:, navigation:, step_url:, complete: []) ⇒ Stepper

Returns a new instance of Stepper.

Parameters:

  • steps (Array<Step>)

    the visible path.

  • current (Step)

    the current step.

  • visited (Array<String>)

    visited (reached) step keys.

  • complete (Array<String>) (defaults to: [])

    keys of steps that are actually complete (submitted AND valid) — distinct from visited. A step can be reached (e.g. the cursor landed on a branch step) without being completed.

  • navigation (Symbol)

    :linear or :free.

  • step_url (Proc)

    step_key → GET url.



24
25
26
27
28
29
30
31
# File 'lib/plutonium/ui/wizard/stepper.rb', line 24

def initialize(steps:, current:, visited:, navigation:, step_url:, complete: [])
  @steps = steps
  @current = current
  @visited = visited.map(&:to_s)
  @complete = complete.map(&:to_s).to_set
  @navigation = navigation
  @step_url = step_url
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit

Instance Method Details

#view_templateObject



33
34
35
36
37
38
39
40
41
# File 'lib/plutonium/ui/wizard/stepper.rb', line 33

def view_template
  nav(class: "pu-wizard-stepper mb-7", aria_label: "Progress") do
    ol(class: "pu-wizard-steps") do
      @steps.each_with_index do |step, index|
        render_step(step, index)
      end
    end
  end
end