Sha256: 6e2f4ff221cb9efce0819c5ac62d0136477e007c5231d3f950874b6083b1c92b

Contents?: true

Size: 1.77 KB

Versions: 16

Compression:

Stored size: 1.77 KB

Contents

module UiBibz::Ui::Core

  # Create a button link
  #
  # 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+)
  # * +size+
  #   (+:xs+, +:sm+, +:lg+)
  # * +url+ - String url
  # * +glyph+ - Add glyph with name or hash options
  #   * +name+ - String
  #   * +size+ - Integer
  #   * +type+ - Symbol
  #
  # ==== Signatures
  #
  #   UiBibz::Ui::Core::ButtonLink.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::ButtonLink.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::ButtonLink.new('test', type: :primary, url: '#')
  #
  #   UiBibz::Ui::Core::ButtonLink.new(type: :primary, url: '#') do
  #     test
  #   end.render
  #
  # ==== Helper
  #
  #   button_link(content, options = {}, html_options = {})
  #
  #   button_link(options = {}, html_options = {}) do
  #     content
  #   end
  #
  class ButtonLink < Component

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

    # Render html tag
    def render
      link_to glyph_and_content_html, @options[:url], class_and_html_options("btn")
    end

  private

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

    # :lg, :sm or :xs
    def size
      "btn-#{ @options[:size] }" if @options[:size]
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ui_bibz-1.2.5.3 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.5.2 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.5.1 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.5 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.4 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.3 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.2 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.1 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.2.0 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.1.7 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.1.6 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.1.5 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.1.4 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.1.3 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.1.2 lib/ui_bibz/ui/core/button/button_link.rb
ui_bibz-1.1.1 lib/ui_bibz/ui/core/button/button_link.rb