Class: UiBibz::Ui::Core::Navigations::NavLink

Inherits:
Component show all
Includes:
UiBibz::Ui::Concerns::HtmlConcern
Defined in:
lib/ui_bibz/ui/core/navigations/components/nav_link.rb

Overview

Create a NavLink

This element is an extend of UiBibz::Ui::Core::Navigations::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

  • badge - String

  • link_html_options - Hash

Signatures

UiBibz::Ui::Core::Navigations::NavLink.new(content, options = nil, html_options = nil)

UiBibz::Ui::Core::Navigations::NavLink.new(options = nil, html_options = nil) do
  content
end

Examples

UiBibz::Ui::Core::Navigations::NavLink.new(content, { badge: 15, url: '/', state: :active, link_html_options: { class: 'link1' }},{ class: 'test' }).render

UiBibz::Ui::Core::Navigations::NavLink.new({glyph: { name: 'eye', size: 3 }, { class: 'test' }) do
  'Home'
end.render

Constant Summary

Constants inherited from Component

Component::BREAKPOINTS, Component::SIZES, Component::STATUSES

Instance Attribute Summary

Attributes inherited from Component

#content, #html_options, #options

Attributes inherited from Base

#output_buffer

Instance Method Summary collapse

Methods inherited from Component

#render, #tapped?

Methods included from PopoverExtension

#popover_data_html, #tooltip_data_html

Methods included from GlyphExtension

#generate_glyph, #glyph_and_content_html

Methods included from KlassExtension

#exclude_classes, #exclude_classes_in_html_options, #join_classes, #status

Methods inherited from Base

#generate_id, #i18n_set?, #inject_url

Constructor Details

#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ NavLink

See UiBibz::Ui::Core::Component.initialize



47
48
49
50
# File 'lib/ui_bibz/ui/core/navigations/components/nav_link.rb', line 47

def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @old_options = options
end

Instance Method Details

#pre_renderObject

Render html tag



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ui_bibz/ui/core/navigations/components/nav_link.rb', line 53

def pre_render
  if options[:nav_tags] == :a || %w[nav-links list-group].include?(options[:nav_type])
    UiBibz::Ui::Core::Navigations::NavLinkLink.new(content, options, html_options).render
  else
    cont = if options[:tag_type] == :span
             UiBibz::Ui::Core::Navigations::NavLinkSpan.new(content, @old_options).render
           else
             UiBibz::Ui::Core::Navigations::NavLinkLink.new(content, options).render
           end
    # html_options[:class] = remove_class(html_options[:class])
    remove_classes
    UiBibz::Ui::Core::Navigations::NavLinkList.new(cont, options, html_options).render
  end
end