Class: Railsboot::ProgressComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/progress_component.rb

Constant Summary

Constants inherited from Component

Component::COLORS, Component::DEFAULT_COLOR

Instance Method Summary collapse

Constructor Details

#initialize(value: 0, min: 0, max: 100, label: "", aria_label: nil, color: DEFAULT_COLOR, **html_attributes) ⇒ ProgressComponent

Returns a new instance of ProgressComponent.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/components/railsboot/progress_component.rb', line 2

def initialize(value: 0, min: 0, max: 100, label: "", aria_label: nil, color: DEFAULT_COLOR, **html_attributes)
  @value = value
  @min = min
  @max = max
  @label = label
  @aria_label = aria_label
  @color = fetch_or_raise(color, COLORS)
  @html_attributes = html_attributes

  @html_attributes[:tag] = "div"
  @html_attributes[:class] = class_names(
    "progress",
    html_attributes.delete(:class)
  )
end

Instance Method Details

#inner_classesObject



18
19
20
21
22
23
# File 'app/components/railsboot/progress_component.rb', line 18

def inner_classes
  class_names(
    "progress-bar",
    {"bg-#{@color}" => @color.present?}
  )
end