3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/helpers/megatron/progress_helper.rb', line 3
def progress_bar(percentage, options={})
options = {
percentage: percentage,
label_position: 'before'
}.merge(options)
if options[:label] == true
options[:label] = "#{percentage}%"
end
percentage = 100 if percentage > 100
width = if options[:width]
"width: #{options.delete(:width)};"
else
''
end
color = options.delete(:color) || 'blue'
content_tag(:span, class: 'progress-bar-wrapper') {
if options[:label] && options[:label_position].to_s == 'before'
concat content_tag(:span, class: "progress-bar-label"){ options[:label] }
end
concat content_tag(:span, class: 'progress-bar', data: options, style: width) {
content_tag(:span, class: "progress-bar-fill #{color}-bg", style: "width: #{percentage}%"){}
}
if options[:label] && options[:label_position].to_s == 'after'
concat content_tag(:span, class: "progress-bar-label"){ options[:label] }
end
}
end
|