Class: Keystone::Ui::ProgressComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::ProgressComponent
- Defined in:
- app/components/keystone/ui/progress_component.rb
Constant Summary collapse
- TRACK_CLASSES =
"w-full h-2 bg-surface-200 rounded-full overflow-hidden"- BAR_CLASSES =
"h-full bg-accent-500 rounded-full transition-all"- LABEL_CLASSES =
"mb-1 text-sm font-medium text-surface-700"
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #bar_classes ⇒ Object
-
#initialize(value:, max:, label: nil) ⇒ ProgressComponent
constructor
A new instance of ProgressComponent.
- #label_classes ⇒ Object
- #percent ⇒ Object
- #track_classes ⇒ Object
Constructor Details
#initialize(value:, max:, label: nil) ⇒ ProgressComponent
Returns a new instance of ProgressComponent.
12 13 14 15 16 |
# File 'app/components/keystone/ui/progress_component.rb', line 12 def initialize(value:, max:, label: nil) @value = value @max = max @label = label end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
10 11 12 |
# File 'app/components/keystone/ui/progress_component.rb', line 10 def label @label end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
10 11 12 |
# File 'app/components/keystone/ui/progress_component.rb', line 10 def max @max end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'app/components/keystone/ui/progress_component.rb', line 10 def value @value end |
Instance Method Details
#bar_classes ⇒ Object
26 27 28 |
# File 'app/components/keystone/ui/progress_component.rb', line 26 def BAR_CLASSES end |
#label_classes ⇒ Object
30 31 32 |
# File 'app/components/keystone/ui/progress_component.rb', line 30 def label_classes LABEL_CLASSES end |
#percent ⇒ Object
18 19 20 |
# File 'app/components/keystone/ui/progress_component.rb', line 18 def percent [ (value.to_f / max * 100).round, 100 ].min end |
#track_classes ⇒ Object
22 23 24 |
# File 'app/components/keystone/ui/progress_component.rb', line 22 def track_classes TRACK_CLASSES end |