Class: Bs5::Progress::BarComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bs5::Progress::BarComponent
- Defined in:
- app/components/bs5/progress/bar_component.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #animated_class ⇒ Object
- #bar_class ⇒ Object
- #contextual_class ⇒ Object
-
#initialize(value, label: nil, color: nil, striped: false, animated: false) ⇒ BarComponent
constructor
A new instance of BarComponent.
- #label ⇒ Object
- #striped_class ⇒ Object
Constructor Details
#initialize(value, label: nil, color: nil, striped: false, animated: false) ⇒ BarComponent
Returns a new instance of BarComponent.
8 9 10 11 12 13 14 |
# File 'app/components/bs5/progress/bar_component.rb', line 8 def initialize(value, label: nil, color: nil, striped: false, animated: false) @value = value @label = label @color = color @striped = striped @animated = animated end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
6 7 8 |
# File 'app/components/bs5/progress/bar_component.rb', line 6 def color @color end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'app/components/bs5/progress/bar_component.rb', line 6 def value @value end |
Instance Method Details
#animated_class ⇒ Object
47 48 49 50 51 |
# File 'app/components/bs5/progress/bar_component.rb', line 47 def animated_class return unless animated? %w[progress-bar-striped progress-bar-animated] end |
#bar_class ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/components/bs5/progress/bar_component.rb', line 27 def class_names = %w[progress-bar] class_names << contextual_class class_names << striped_class class_names << animated_class class_names.flatten.uniq.join(' ') end |
#contextual_class ⇒ Object
35 36 37 38 39 |
# File 'app/components/bs5/progress/bar_component.rb', line 35 def contextual_class return unless color? "bg-#{color}" end |
#label ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/bs5/progress/bar_component.rb', line 16 def label return unless @label case @label when String @label else "#{value}%" end end |
#striped_class ⇒ Object
41 42 43 44 45 |
# File 'app/components/bs5/progress/bar_component.rb', line 41 def striped_class return unless striped? 'progress-bar-striped' end |