Class: Shadcn::ProgressComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/progress_component.rb

Overview

Progress component for showing completion status Matches shadcn/ui Progress component

Examples:

Basic progress

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

With custom max

<%= render Shadcn::ProgressComponent.new(value: 30, max: 50) %>

Indeterminate (loading)

<%= render Shadcn::ProgressComponent.new(indeterminate: true) %>

Constant Summary collapse

BASE_CLASSES =
"relative h-2 w-full overflow-hidden rounded-full bg-primary/20"
INDICATOR_CLASSES =
"h-full w-full flex-1 bg-primary transition-all"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(value: nil, max: 100, indeterminate: false, **options) ⇒ ProgressComponent

Returns a new instance of ProgressComponent.

Parameters:

  • value (Integer, Float, nil) (defaults to: nil)

    Current progress value

  • max (Integer, Float) (defaults to: 100)

    Maximum progress value

  • indeterminate (Boolean) (defaults to: false)

    Whether to show indeterminate state



23
24
25
26
27
28
# File 'app/components/shadcn/progress_component.rb', line 23

def initialize(value: nil, max: 100, indeterminate: false, **options)
  super(**options)
  @value = value
  @max = max
  @indeterminate = indeterminate
end