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

Inherits:
Component show all
Defined in:
lib/ui_bibz/ui/core/nav/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)

Signatures

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

UiBibz::Ui::Core::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::Nav.new(type: :pills).tap do |n|
  n.link 'Test', url: '#test'
  n.link 'Test2', url: '#test2', status: :active
  n.dropdown('Action') do |d|
    d.list content = nil, options = nil, html_options = nil, &block
  end
end.render

Helper

nav(options = { tap: true }, 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

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

#add_classes, #badge_html, #class_and_html_options, #glyph, #glyph_and_content_html, #glyph_with_space, #state

Methods inherited from Base

#i18n_set?

Constructor Details

- (Nav) initialize(content = nil, options = nil, html_options = nil, &block)

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



62
63
64
65
# File 'lib/ui_bibz/ui/core/nav/nav.rb', line 62

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

Instance Method Details

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



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

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

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



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

def link content = nil, options = {}, html_options = nil, &block
  @items << NavLink.new(content, options.merge({ nav_type: type }), html_options, &block).render
end

- (Object) render

Render html tag



68
69
70
# File 'lib/ui_bibz/ui/core/nav/nav.rb', line 68

def render
   :ul, @items.join.html_safe, class_and_html_options(["nav", type, position])
end