Class: StepComponent
- Defined in:
- app/components/step_component.rb
Overview
Step — individual step within a StepGroup.
Usage:
StepGroup {
Step(active: true, icon: "truck", title: "Shipping", description: "Choose shipping")
Step(title: "Billing", description: "Enter billing info")
Step(disabled: true, title: "Confirm Order")
}
StepGroup {
Step(completed: true) {
text "Custom content"
}
}
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
Methods inherited from Component
default, #initialize, #render_in, slot
Constructor Details
This class inherits a constructor from Component
Instance Method Details
#to_s ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/components/step_component.rb', line 27 def to_s classes = class_names( { "active" => active, "completed" => completed, "disabled" => disabled }, "step" ) icon_el = icon ? tag.i(class: "#{icon} icon") : nil content_parts = [ (title ? tag.div(class: "title") { title } : nil), (description ? tag.div(class: "description") { description } : nil) ].compact content_el = if content_parts.any? tag.div(class: "content") { safe_join(content_parts) } end inner = if @content.present? @content else safe_join([ icon_el, content_el ]) end if href tag.a(class: classes, href: href) { inner } else tag.div(class: classes) { inner } end end |