Sha256: acefb1543b247af176bf4b4f7b559fd323182c2f5cc1221da678f61834368803

Contents?: true

Size: 1.77 KB

Versions: 10

Compression:

Stored size: 1.77 KB

Contents

module UiBibz::Ui::Core

  # Create DropdownLink
  #
  # 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+ - State of élement with symbol value:
  #   (+:active+)
  # * +url+ - String
  # * +glyph+ - Add glyph with name or hash options
  #   * +name+ - String
  #   * +size+ - Integer
  #   * +type+ - Symbol
  # * +link_html_options+ - Hash
  #
  # ==== Signatures
  #
  #   UiBibz::Ui::Core::DropdownLink.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::DropdownLink.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::DropdownLink.new('Home', { glyph: 'home', status: :active, url: '#home', link_html_options: { class: 'link1' }},{ class: 'test' }).render
  #
  #   UiBibz::Ui::Core::DropdownLink.new({ glyph: { name: 'eye', size: 3 }, url: '#home' }, { class: 'test' }) do
  #     'Home'
  #   end.render
  #
  class DropdownLink < Component

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

    # Render html tag
    def render
      link_to glyph_and_content_html, link_url, html_options
    end

    private

    def component_html_classes
      'dropdown-item'
    end

    def link_url
      options[:url] || "#"
    end

    def link_html_options
      @options[:link_html_options].nil? ? {} : @options[:link_html_options]
    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/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha9 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha8 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha7 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha6 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha5 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha4 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha3 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha2 lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb
ui_bibz-2.0.0.alpha lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb