Sha256: 40cf0e281b9d5a7e7b24f5fbabd68d20be0f140af6256f7d1e4b4d9397558fe7

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

module UiBibz::Ui::Core

  # Create a tag
  #
  # 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:
  # * +status+ - status 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::Tag.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::Tag.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::Tag.new(content, status: :success, type: :pill).render
  #
  #   UiBibz::Ui::Core::Tag.new() do
  #     #content
  #   end.render
  #
  # ==== Helper
  #
  #   etiquette(content, options = {}, html_options = {})
  #
  #   etiquette(options = {}, html_options = {}) do
  #     content
  #   end
  #
  class Tag < 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
      ['tag', type]
    end

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

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

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ui_bibz-2.0.0.alpha24 lib/ui_bibz/ui/core/tag.rb
ui_bibz-2.0.0.alpha23 lib/ui_bibz/ui/core/tag.rb
ui_bibz-2.0.0.alpha22 lib/ui_bibz/ui/core/tag.rb
ui_bibz-2.0.0.alpha21 lib/ui_bibz/ui/core/tag.rb
ui_bibz-2.0.0.alpha20 lib/ui_bibz/ui/core/tag.rb
ui_bibz-2.0.0.alpha19 lib/ui_bibz/ui/core/tag.rb
ui_bibz-2.0.0.alpha18 lib/ui_bibz/ui/core/tag.rb