Class: Satis::ProgressBar::Component

Inherits:
ApplicationComponent show all
Defined in:
app/components/satis/progress_bar/component.rb

Instance Attribute Summary collapse

Attributes inherited from ApplicationComponent

#original_view_context

Instance Method Summary collapse

Methods inherited from ApplicationComponent

add_helper, #component_name

Constructor Details

#initialize(percentage, size: :default, label: false) ⇒ Component

Returns a new instance of Component.



8
9
10
11
12
13
# File 'app/components/satis/progress_bar/component.rb', line 8

def initialize(percentage, size: :default, label: false)
  super
  @percentage = percentage
  @size = size
  @label = label
end

Instance Attribute Details

#percentageObject (readonly)

Returns the value of attribute percentage.



6
7
8
# File 'app/components/satis/progress_bar/component.rb', line 6

def percentage
  @percentage
end

Instance Method Details

#labelObject



15
16
17
18
19
20
21
22
23
24
# File 'app/components/satis/progress_bar/component.rb', line 15

def label
  return if size == :small || size == :default
  if @label.is_a? FalseClass
    ''
  elsif @label.is_a? TrueClass
    "#{percentage}%"
  else
    @label
  end
end

#paddingObject



26
27
28
29
30
31
32
# File 'app/components/satis/progress_bar/component.rb', line 26

def padding
  if @size == :large
    "p-0.5"
  elsif @size == :xlarge
    "p-1"
  end
end

#sizeObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/components/satis/progress_bar/component.rb', line 43

def size
  case @size
  when :small
    "h-1.5"
  when :large
    "h-4"
  when :xlarge
    "h-6"
  else
    "h-2"
  end
end

#text_sizeObject



34
35
36
37
38
39
40
# File 'app/components/satis/progress_bar/component.rb', line 34

def text_size
  if @size == :large
    "text-xs"
  elsif @size == :xlarge
    "text-sm"
  end
end