Sha256: cd22689669004d6ed1ed9f82434bbd38116b836d16ff3d7156bd1fa97495d984

Contents?: true

Size: 1.87 KB

Versions: 48

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

module UiBibz::Ui::Core::Forms::Dropdowns::Components
  # 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:
  # * +state+ - status of element 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::Forms::DropdownLink.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::Forms::DropdownLink.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::Forms::DropdownLink.new('Home', { glyph: 'home', state: :active, url: '#home', link_html_options: { class: 'link1' }},{ class: 'test' }).render
  #
  #   UiBibz::Ui::Core::Forms::DropdownLink.new({ glyph: { name: 'eye', size: 3 }, url: '#home' }, { class: 'test' }) do
  #     'Home'
  #   end.render
  #
  class DropdownLink < UiBibz::Ui::Core::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 pre_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

48 entries across 48 versions & 1 rubygems

Version Path
ui_bibz-3.0.13 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.12 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.11 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.10 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.9 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.8 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.7 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.6 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.5 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.4 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.3 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.2 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.1 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.0 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.0.beta19 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.0.beta18 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.0.beta17 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.0.beta16 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.0.beta15 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
ui_bibz-3.0.0.beta14 lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb