Class: Keystone::Ui::ProgressComponent

Inherits:
ViewComponent::Base
  • Object
show all
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

Instance Method Summary collapse

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

#labelObject (readonly)

Returns the value of attribute label.



10
11
12
# File 'app/components/keystone/ui/progress_component.rb', line 10

def label
  @label
end

#maxObject (readonly)

Returns the value of attribute max.



10
11
12
# File 'app/components/keystone/ui/progress_component.rb', line 10

def max
  @max
end

#valueObject (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_classesObject



26
27
28
# File 'app/components/keystone/ui/progress_component.rb', line 26

def bar_classes
  BAR_CLASSES
end

#label_classesObject



30
31
32
# File 'app/components/keystone/ui/progress_component.rb', line 30

def label_classes
  LABEL_CLASSES
end

#percentObject



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_classesObject



22
23
24
# File 'app/components/keystone/ui/progress_component.rb', line 22

def track_classes
  TRACK_CLASSES
end