Class: Warped::Emails::Stepper

Inherits:
Base
  • Object
show all
Defined in:
lib/warped/emails/components/stepper.rb

Instance Attribute Summary

Attributes inherited from Base

#view_context

Instance Method Summary collapse

Methods inherited from Base

#content, #helpers, #render_in

Methods included from Styleable

#base_styles, #default_variants, included, #style, #variants

Methods included from Slottable

included, #slots

Constructor Details

#initialize(steps:, current_step: 1) ⇒ Stepper

Returns a new instance of Stepper.



44
45
46
47
48
# File 'lib/warped/emails/components/stepper.rb', line 44

def initialize(steps:, current_step: 1)
  super()
  @steps = steps
  @current_step = current_step
end

Instance Method Details

#templateObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/warped/emails/components/stepper.rb', line 50

def template
  tag.div(style: "width: 100%") do
    capture do
      (1..steps).map do |step|
        if step <= current_step
          concat step(step, state: :active)
        else
          concat step(step, state: :inactive)
        end

        if step < steps
          concat divider(state: step <= current_step ? :active : :inactive)
        end
      end
    end
  end
end