Class: UI::ProgressComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ProgressBehavior
Defined in:
app/view_components/ui/progress_component.rb

Overview

ProgressComponent - ViewComponent implementation

A progress indicator component for displaying task completion or loading status. Uses ProgressBehavior for shared styling logic.

Examples:

Basic usage with value

<%= render UI::ProgressComponent.new(value: 60) %>

Indeterminate progress (no value)

<%= render UI::ProgressComponent.new %>

With custom classes

<%= render UI::ProgressComponent.new(value: 80, classes: "h-4") %>

Instance Method Summary collapse

Methods included from ProgressBehavior

#progress_classes, #progress_html_attributes, #progress_indicator_classes, #progress_indicator_style, #progress_value

Constructor Details

#initialize(value: 0, classes: "", **attributes) ⇒ ProgressComponent

Returns a new instance of ProgressComponent.

Parameters:

  • value (Numeric) (defaults to: 0)

    Progress value between 0 and 100 (default: 0)

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



22
23
24
25
26
# File 'app/view_components/ui/progress_component.rb', line 22

def initialize(value: 0, classes: "", **attributes)
  @value = value
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



28
29
30
31
32
33
34
35
36
37
38
# File 'app/view_components/ui/progress_component.rb', line 28

def call
  attrs = progress_html_attributes

   :div, **attrs.merge(@attributes) do
     :div,
      nil,
      class: progress_indicator_classes,
      style: progress_indicator_style,
      data: {slot: "progress-indicator"}
  end
end