class UiBibz::Ui::Core::Notifications::ProgressBar
Create a progress bar
This element is an extend of UiBibz::Ui::Core::Component
.
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
status
- status of element with symbol value: (:secondary
,:primary
,:info
,:warning
,:danger
) -
value
- Value of percentage (default: content) -
animated
- Boolean -
striped
- Boolean -
stacked
- Boolean -
line
- Boolean
Signatures¶ ↑
UiBibz::Ui::Core::Notifications::ProgressBar.new(percentage, options = nil, html_options = nil) UiBibz::Ui::Core::Notifications::ProgressBar.new(options = nil, html_options = nil) do percentage end
Examples¶ ↑
UiBibz::Ui::Core::Notifications::ProgressBar.new(50%, { value: 50}) # or UiBibz::Ui::Core::Notifications::ProgressBar.new(10%, { value: 10, status: :success },{ class: 'test' }).render # or UiBibz::Ui::Core::Notifications::ProgressBar.new({ value: 10, status: :success},{ class: 'test' }) do 10% end.render
Helper¶ ↑
ui_progress_bar(integer, options = {}, html_options = {}) ui_progress_bar(options = {}, html_options = {}) do |pb| pb.bar(integer, options = {}, html_options = {}) pb.bar(options = {}, html_options = {}) do integer end end
Public Class Methods
new(content = nil, options = nil, html_options = nil, &block)
click to toggle source
See UiBibz::Ui::Core::Component.initialize
Calls superclass method
UiBibz::Ui::Core::Component::new
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 61 def initialize(content = nil, options = nil, html_options = nil, &block) super @items = [] end
Public Instance Methods
bar(content = nil, options = nil, html_options = nil, &block)
click to toggle source
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 71 def bar(content = nil, options = nil, html_options = nil, &block) @items << UiBibz::Ui::Core::Notifications::Components::Bar.new(content, options, html_options, &block).render end
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 67 def pre_render content_tag :div, bars.join.html_safe, html_options end
Private Instance Methods
bars()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 81 def bars if !@items.empty? @items elsif options[:stacked] stacked_bars else [UiBibz::Ui::Core::Notifications::Components::Bar.new(content, options).render] end end
component_html_classes()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 77 def component_html_classes ['progress', line] end
line()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 91 def line 'progress-bar-line' if options[:line] end
stacked_bars()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 95 def stacked_bars percentages = [7.4, 15.3, 21.1, 25.9, 30.3, 100] stacked_colors.map.with_index do |color, i| if percentages[0, i].sum <= content.to_f if content.to_f.between?(percentages[0, i].sum, percentages[0, i + 1].sum) UiBibz::Ui::Core::Notifications::Components::Bar.new((content.to_f * percentages[i] / 100), min: 0, striped: options[:striped], animated: options[:animated], max: 100, status: color).render else UiBibz::Ui::Core::Notifications::Components::Bar.new(percentages[i], min: 0, striped: options[:striped], animated: options[:animated], max: 100, status: color).render end end end end
stacked_colors()
click to toggle source
# File lib/ui_bibz/ui/core/notifications/progress_bar.rb, line 108 def stacked_colors if options[:inverse] %i[success primary info warning danger].reverse else %i[success primary info warning danger] end end