Class: UiBibz::Ui::Core::ProgressBar

Inherits:
Component show all
Defined in:
lib/ui_bibz/ui/core/progress_bar/progress_bar.rb

Overview

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:

  • state - State of élement with symbol value: (:default, :primary, :info, :warning, :danger)

  • label - String (default: “percentage%”)

  • tap - Boolean (true: To add several bars)

  • percentage_min - Integer (default: 0)

  • percentage_max - Integer (default: 100)

  • sr_only - Boolean to show label (default: false)

  • type (:striped, :animated)

Signatures

UiBibz::Ui::Core::ProgressBar.new(percentage, options = nil, html_options = nil)

UiBibz::Ui::Core::ProgressBar.new(options = nil, html_options = nil) do
  percentage
end

UiBibz::Ui::Core::ProgressBar.new(tap: true).tap do |pb|
  pb.bar percentage, options = nil, html_options = nil
  pb.bar options = nil, html_options = nil do
    percentage
  end
end

Examples

UiBibz::Ui::Core::ProgressBar.new(50)
# or
UiBibz::Ui::Core::ProgressBar.new(10, { state: :success, sr_only: false, label: 'Loading...' },{ class: 'test' }).render
# or
UiBibz::Ui::Core::ProgressBar.new(tap: true).tap |pb|
  pb.bar 10, { state: :success, sr_only: false, label: 'Loading...' },{ class: 'test' }
  pb.bar { state: :primary } do
    20
  end
end.render

Helper

progress_bar(integer, options = {}, html_options = {})

progress_bar(options = { tap: true }, html_options = {}) do |pb|
  pb.bar(integer, options = {}, html_options = {})
  pb.bar(options = {}, html_options = {}) do
    integer
  end
end

Instance Attribute Summary

Attributes inherited from Component

#html_options, #options

Attributes inherited from Base

#output_buffer

Instance Method Summary (collapse)

Methods inherited from Component

#add_classes, #badge_html, #class_and_html_options, #glyph, #glyph_and_content_html, #glyph_with_space, #state

Methods inherited from Base

#i18n_set?

Constructor Details

- (ProgressBar) initialize(content = nil, options = nil, html_options = nil, &block)

See UiBibz::Ui::Core::Component.initialize



71
72
73
74
# File 'lib/ui_bibz/ui/core/progress_bar/progress_bar.rb', line 71

def initialize content = nil, options = nil, html_options = nil, &block
  super
  @bars = []
end

Instance Method Details

- (Object) bar(content = nil, options = nil, html_options = nil, &block)

Add progressbar bar items See UiBibz::Ui::Core::Bar



83
84
85
# File 'lib/ui_bibz/ui/core/progress_bar/progress_bar.rb', line 83

def bar content = nil, options = nil, html_options = nil, &block
  @bars << Bar.new(content, options, html_options, &block).render
end

- (Object) render

Render html tag



77
78
79
# File 'lib/ui_bibz/ui/core/progress_bar/progress_bar.rb', line 77

def render
   :div, content, class: 'progress'
end