Class: UiBibz::Ui::Core::Navbar
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' }
'Submit', type: :submit
end
nb.text 'My text'
end.render
Helper
( = { tap: true }, = {}) do |nb|
nb.nav( = { tap: true }, = {}) do |n|
n.link(content, = {}, = {})
n.link( = {}, = {}) do
content
end
end
end
Instance Attribute Summary
Attributes inherited from Component
#content, #html_options, #options
Attributes inherited from Base
Instance Method Summary (collapse)
- - (Object) brand(content = nil, options = nil, html_options = nil, &block)
-
- (Object) form(model_or_url, options = {}, &block)
Add navbar form items See UiBibz::Ui::Core::NavbarForm.
-
- (Navbar) initialize(content = nil, options = nil, html_options = nil, &block)
constructor
See UiBibz::Ui::Core::Component.initialize.
-
- (Object) nav(content = nil, options = nil, html_options = nil, &block)
Add navbar nav items See UiBibz::Ui::Core::NavbarNav.
-
- (Object) render
Render html tag.
-
- (Object) text(content = nil, options = nil, html_options = nil, &block)
Add navbar text items See UiBibz::Ui::Core::NavbarText.
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
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, = nil, = 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, = nil, = nil, &block @brand = UiBibz::Ui::Core::Component.new(content, , , &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, = {}, &block @items << UiBibz::Ui::Core::NavbarForm.new(model_or_url, , &block).render end |
- (Object) nav(content = nil, options = nil, html_options = nil, &block)
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, = nil, = nil, &block = || {} @items << UiBibz::Ui::Core::NavbarNav.new(content, , ).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 content_tag :nav, (['navbar', type, position]) do content_tag :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, = nil, = nil, &block @items << UiBibz::Ui::Core::NavbarText.new(content, , , &block).render end |