Class: UiBibz::Ui::Core::Navbar

Inherits:
Component show all
Defined in:
lib/ui_bibz/ui/core/nav/navbar.rb

Overview

Create a Navbar

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 (default: :default) (:inverse, :default)

  • glyph

  • position - Symbol (:top, :bottom)

  • title - String

Signatures

UiBibz::Ui::Core::Navbar.new(options = nil, html_options = nil).tap do |nb|
  ...
  nb.nav(options = nil, html_options = nil) do |n|
    n.link content options = nil, html_options = nil, &block
    n.link content options = nil, html_options = nil, &block
  end
  ...
end

Examples

UiBibz::Ui::Core::Navbar.new().tap do |nb|
  nb.nav(position: :right) do |n|
    n.link 'Link 1', "#"
    n.link 'Link 2', "#"
  end
  nb.form(url: 'search/', type: :form_tag) do
    text_field_tag 'search', nil, { class: 'form-control', placeholder: 'Search' }
    button 'Submit', type: :submit
  end
  nb.text 'My text'
end.render

Helper

navbar(options = { tap: true }, html_options = {}) do |nb|
  nb.nav(options = { tap: true }, html_options = {}) do |n|
    n.link(content, options = {}, html_options = {})
    n.link(options = {}, html_options = {}) do
      content
    end
  end
end

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

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

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



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

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

Instance Method Details

- (Object) brand(content = nil, options = nil, html_options = nil, &block)



101
102
103
# File 'lib/ui_bibz/ui/core/nav/navbar.rb', line 101

def brand content = nil, options = nil, html_options = nil, &block
  @brand = UiBibz::Ui::Core::Component.new(content, options, html_options, &block)
end

- (Object) form(model_or_url, options = {}, &block)

Add navbar form items See UiBibz::Ui::Core::NavbarForm



91
92
93
# File 'lib/ui_bibz/ui/core/nav/navbar.rb', line 91

def form model_or_url, options = {}, &block
  @items << UiBibz::Ui::Core::NavbarForm.new(model_or_url, options, &block).render
end

Add navbar nav items See UiBibz::Ui::Core::NavbarNav



84
85
86
87
# File 'lib/ui_bibz/ui/core/nav/navbar.rb', line 84

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

- (Object) render

Render html tag



73
74
75
76
77
78
79
80
# File 'lib/ui_bibz/ui/core/nav/navbar.rb', line 73

def render
   :nav, class_and_html_options(['navbar', type, position]) do
     :div, class: 'container-fluid' do
      concat header_html
      concat body_html
    end
  end
end

- (Object) text(content = nil, options = nil, html_options = nil, &block)

Add navbar text items See UiBibz::Ui::Core::NavbarText



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

def text content = nil, options = nil, html_options = nil, &block
  @items << UiBibz::Ui::Core::NavbarText.new(content, options, html_options, &block).render
end