Sha256: 3f6bd12165f54dfc3bd9992def8a7e190d381146aa9479c22777f13f95d4d6fa

Contents?: true

Size: 1.77 KB

Versions: 10

Compression:

Stored size: 1.77 KB

Contents

module UiBibz::Ui::Core

  # Create a label
  #
  # This element is an extend of UiBibz::Ui::Core::Component.
  # The helper use 'etiquette' method to avoid conflict with Rails.
  #
  # ==== 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+)
  # * +glyph+ - Add glyph with name or hash options
  #   * +name+ - String
  #   * +size+ - Integer
  #   * +type+ - Symbol
  # * +type+ - Symbol
  #   (+pill+)
  #
  # ==== Signatures
  #
  #   UiBibz::Ui::Core::Label.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::Label.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::Label.new(content, state: :success, type: :pill).render
  #
  #   UiBibz::Ui::Core::Label.new() do
  #     #content
  #   end.render
  #
  # ==== Helper
  #
  #   etiquette(content, options = {}, html_options = {})
  #
  #   etiquette(options = {}, html_options = {}) do
  #     content
  #   end
  #
  class Label < Component

    # See UiBibz::Ui::Core::Component.initialize
    def initialize content = nil, options = nil, html_options = nil, &block
      super
    end

    # Render html tag
    def render
      content_tag :span, glyph_and_content_html, html_options
    end

  private

    def component_html_classes
      ['label', type]
    end

    def state
      sym = @options[:state] || :default
      "label-#{ sym }"
    end

    def type
      "label-pill" if @options[:type] == :pill
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ui_bibz-2.0.0.alpha10 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha9 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha8 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha7 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha6 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha5 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha4 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha3 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha2 lib/ui_bibz/ui/core/label.rb
ui_bibz-2.0.0.alpha lib/ui_bibz/ui/core/label.rb