Class: UiBibz::Ui::Core::Navigations::Nav

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

Overview

Create a nav

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:

  • type - Symbol (:pills, :tab)

  • position - Symbol (:left, :right, :center)

  • stacked - Boolean

  • tag - Symbol (:a, +:li)

  • justify - Boolean

  • fill - Boolean

Signatures

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

UiBibz::Ui::Core::Navigations::Nav.new(options = nil, html_options = nil).tap do |n|
  ...
  n.link content = nil, options = nil, html_options = nil, block
  n.link content = nil, options = nil, html_options = nil, block
  n.dropdown content = nil, options = nil, html_options = nil, block
  ...
end

Examples

UiBibz::Ui::Core::Navigations::Nav.new(type: :pills).tap do |n|
  n.link 'Test', url: '#test'
  n.link 'Test2', url: '#test2', state: :active
  n.dropdown('Action') do |d|
    d.list content = nil, options = nil, html_options = nil, &block
  end
end.render

Helper

nav(options = {}, html_options = {}) do |n|
  n.link(content, options = {}, html_options = {})
  n.link(options = {}, html_options = {}) do
    content
  end
  n.dropdown(name, options = {}, html_options = {}) do |d|
    d.list(content, options = {}, html_options = {})
    d.list(options = {}, html_options = {}) do
      content
    end
  end
end

Direct Known Subclasses

NavbarNav, TabGroup

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) ⇒ Nav

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



73
74
75
76
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 73

def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @items = []
end

Instance Method Details

Add nav dropdown items See UiBibz::Ui::Core::Navigations::NavDropdown



108
109
110
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 108

def dropdown(content = nil, options = {}, html_options = nil, &block)
  @items << NavDropdown.new(content, options, html_options).tap(&block)
end

Add nav link items See UiBibz::Ui::Core::Navigations::NavLink



85
86
87
88
89
90
91
92
93
94
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 85

def link(content = nil, options = {}, html_options = nil, &block)
  if block
    content[:nav_type] = type
    content[:nav_tags] = nav_tags
  else
    options[:nav_type] = type
    options[:nav_tags] = nav_tags
  end
  @items << NavLink.new(content, options, html_options, &block)
end

Add nav in nav



102
103
104
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 102

def nav(content = nil, options = {}, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Component.new(Nav.new(content, options).tap(&block).render, {}, html_options)
end

#pre_renderObject

Render html tag



79
80
81
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 79

def pre_render
   htlm_tag, @items.map(&:render).join.html_safe, html_options
end

#text(content = nil, options = {}, html_options = nil, &block) ⇒ Object



96
97
98
99
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 96

def text(content = nil, options = {}, html_options = nil, &block)
  block ? content[:nav_type] = type : options[:nav_type] = type
  @items << NavText.new(content, options, html_options, &block)
end