Module: UI::ProgressBehavior
- Included in:
- Progress, ProgressComponent
- Defined in:
- app/behaviors/ui/progress_behavior.rb
Overview
UI::ProgressBehavior
Instance Method Summary collapse
-
#progress_classes ⇒ Object
Returns combined CSS classes for the progress container.
-
#progress_html_attributes ⇒ Object
Returns HTML attributes for the progress container element.
-
#progress_indicator_classes ⇒ Object
Returns the indicator classes.
-
#progress_indicator_style ⇒ Object
Returns the transform style for the indicator.
-
#progress_value ⇒ Object
Returns the validated progress value (between 0 and 100).
Instance Method Details
#progress_classes ⇒ Object
Returns combined CSS classes for the progress container
38 39 40 41 42 43 44 |
# File 'app/behaviors/ui/progress_behavior.rb', line 38 def progress_classes classes_value = respond_to?(:classes, true) ? classes : @classes TailwindMerge::Merger.new.merge([ progress_base_classes, classes_value ].compact.join(" ")) end |
#progress_html_attributes ⇒ Object
Returns HTML attributes for the progress container element
26 27 28 29 30 31 32 33 34 35 |
# File 'app/behaviors/ui/progress_behavior.rb', line 26 def progress_html_attributes { class: progress_classes, role: "progressbar", "aria-valuemin": "0", "aria-valuemax": "100", "aria-valuenow": progress_value.to_i, data: {slot: "progress"} } end |
#progress_indicator_classes ⇒ Object
Returns the indicator classes
52 53 54 |
# File 'app/behaviors/ui/progress_behavior.rb', line 52 def progress_indicator_classes "bg-primary h-full w-full flex-1 transition-all" end |
#progress_indicator_style ⇒ Object
Returns the transform style for the indicator
57 58 59 |
# File 'app/behaviors/ui/progress_behavior.rb', line 57 def progress_indicator_style "transform: translateX(-#{100 - progress_value}%)" end |
#progress_value ⇒ Object
Returns the validated progress value (between 0 and 100)
47 48 49 |
# File 'app/behaviors/ui/progress_behavior.rb', line 47 def progress_value (@value || 0).to_f.clamp(0, 100) end |