Class: StimulusPlumbers::Components::ProgressBar

Inherits:
Plumber::Base show all
Includes:
StimulusPlumbers::Components::Progress::Shared
Defined in:
lib/stimulus_plumbers/components/progress_bar.rb

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::Renderer

#set_slots, #slot_block_for, #slot_kwargs_for, #slot_renderable?

Methods included from Plumber::Options::Aria

#labelled_aria

Methods included from Plumber::Options::Html

#merge_html_options

Constructor Details

This class inherits a constructor from StimulusPlumbers::Plumber::Base

Instance Method Details

#renderObject



8
9
10
# File 'lib/stimulus_plumbers/components/progress_bar.rb', line 8

def render(...)
  render_bar(...)
end

#render_segmented(value:, segments:, min: 0, max: 100, mode: :discrete, indeterminate: false, ramp: nil, **kwargs) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/stimulus_plumbers/components/progress_bar.rb', line 12

def render_segmented(value:, segments:, min: 0, max: 100, mode: :discrete, indeterminate: false, ramp: nil, **kwargs)
  html_options = merge_html_options(
    theme.resolve(:progress_segmented),
    kwargs,
    progress_stimulus_data(
      value:                          value,
      min:                            min,
      max:                            max,
      variant:                        "segmented",
      "progress-segment-mode-value":  mode,
      "progress-indeterminate-value": indeterminate
    ),
    { role: "progressbar", aria: progress_aria(value: value, min: min, max: max, indeterminate: indeterminate) }
  )
  slots = ramp_intents(ramp, segments).map { |intent| render_segment(intent: intent) }
  template.(:div, template.safe_join(slots), **html_options)
end