Class: Satis::ProgressBar::Component
Instance Attribute Summary collapse
#original_view_context
Instance Method Summary
collapse
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
#percentage ⇒ Object
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
#label ⇒ Object
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
|
#padding ⇒ Object
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
|
#size ⇒ Object
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_size ⇒ Object
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
|