Class: Railsboot::StepperComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/stepper_component.rb

Overview

ViewComponent: renders the stepper block.

Constant Summary collapse

ALIGNMENTS =

Alignments.

%w[vertical horizontal].freeze
DEFAULT_ALIGNMENT =

Default alignment.

"vertical".freeze

Instance Method Summary collapse

Constructor Details

#initialize(alignment: DEFAULT_ALIGNMENT, tag: "ol", **html_attributes) ⇒ StepperComponent

Returns a new instance of StepperComponent.

Parameters:

  • alignment (String) (defaults to: DEFAULT_ALIGNMENT)

    stepper alignment (one of ALIGNMENTS)

  • tag (String) (defaults to: "ol")

    HTML tag to render for the stepper element

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    additional CSS classes, merged with the component's own classes



15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/railsboot/stepper_component.rb', line 15

def initialize(alignment: DEFAULT_ALIGNMENT, tag: "ol", **html_attributes)
  @tag = tag
  @alignment = fetch_or_raise(alignment, ALIGNMENTS)
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    "stepper",
    { "stepper-#{@alignment}" => @alignment.to_s == "horizontal" },
    html_attributes[:class]
  )
end