Class: Daisy::Navigation::StepComponent

Inherits:
LocoMotion::BaseComponent show all
Defined in:
app/components/daisy/navigation/steps_component.rb

Overview

A step within a StepsComponent.

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary collapse

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

Methods inherited from LocoMotion::BaseComponent

build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces

Constructor Details

#initialize(*args, **kws, &block) ⇒ StepComponent

Create a new instance of the StepComponent.

Parameters:

  • args (Array)

    Not used.

  • kws (Hash)

    The keyword arguments for the component.

Options Hash (**kws):

  • title (String)

    The text to display in the step.

  • number (String)

    Custom content to display in the step’s circle. Can be text, numbers, or emoji.

  • css (String)

    Additional CSS classes for styling. Common options include:

    • Progress: ‘step-primary`, `step-secondary`, `step-accent`

    • Circle Content: ‘after:!text-green-500`, `after:!bg-black`



67
68
69
70
71
72
# File 'app/components/daisy/navigation/steps_component.rb', line 67

def initialize(*args, **kws, &block)
  super

  @simple_title = config_option(:title)
  @number = config_option(:number)
end

Instance Attribute Details

#simpleObject (readonly)

Returns the value of attribute simple.



49
50
51
# File 'app/components/daisy/navigation/steps_component.rb', line 49

def simple
  @simple
end

Instance Method Details

#before_renderObject



74
75
76
77
78
# File 'app/components/daisy/navigation/steps_component.rb', line 74

def before_render
  set_tag_name(:component, :li)
  add_css(:component, "step")
  add_html(:component, { data: { content: @number } }) if @number
end

#callObject



80
81
82
83
84
85
# File 'app/components/daisy/navigation/steps_component.rb', line 80

def call
  part(:component) do
    concat(@simple_title) if @simple_title
    concat(content) if content?
  end
end