Class: StimulusPlumbers::Components::ProgressBar

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

Constant Summary

Constants included from StimulusPlumbers::Components::Progress::Shared

StimulusPlumbers::Components::Progress::Shared::FORMATS

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, format: nil, **kwargs) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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,
  format: nil,
  **kwargs
)
  validate_segments!(segments, format)
  current = clamp(value, min, max)
  html_options = merge_html_options(
    theme.resolve(:progress_segment_group),
    kwargs,
    segmented_stimulus_data(current, min, max, mode, indeterminate),
    { role: "progressbar", aria: progress_aria(value: current, 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