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

Methods included from LocoMotion::Concerns::InspectableComponent

#build_inspect_string

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


39
40
41
42
43
44
# File 'app/components/daisy/navigation/steps_component.rb', line 39

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

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

Instance Attribute Details

#simple_titleObject (readonly)

Returns the value of attribute simple_title.



21
22
23
# File 'app/components/daisy/navigation/steps_component.rb', line 21

def simple_title
  @simple_title
end

Instance Method Details

#before_renderObject



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

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

  super
end

#callObject



54
55
56
57
58
59
# File 'app/components/daisy/navigation/steps_component.rb', line 54

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