Class: UiBibz::Ui::Core::Navigations::Navbar
- Defined in:
- lib/ui_bibz/ui/core/navigations/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 (:light,:dark) -
glyph -
status(:secondary,:primary,:info,:warning,:danger,inverse) -
position- Symbol (:top,:bottom) -
position_type- Symbol (:fixed,:sticky) -
title- String -
container- Hash container options -
container_html- Hash container html options -
expand_size- Symbol size
(:sm, :md, :lg, :xl, :xxl)
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
( = {}, = {}) do |nb|
nb.nav( = {}, = {}) do |n|
n.link(content, = {}, = {})
n.link( = {}, = {}) do
content
end
end
nb.brand content
nb.link 'toto', "#"
end
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
Instance Method Summary collapse
- #brand(content = nil, options = nil, html_options = nil) ⇒ Object
-
#form(model_or_url, options = {}) ⇒ Object
Add navbar form items See UiBibz::Ui::Core::NavbarForm.
- #id ⇒ Object
-
#initialize ⇒ Navbar
constructor
See UiBibz::Ui::Core::Component.initialize.
-
#nav(content = nil, options = nil, html_options = nil) ⇒ Object
Add navbar nav items See UiBibz::Ui::Core::NavbarNav.
- #navbar_toggle_html(content = nil, &block) ⇒ Object
-
#pre_render ⇒ Object
Render html tag.
-
#text(content = nil, options = nil, html_options = nil) ⇒ Object
Not use !!!!! Add navbar text items See UiBibz::Ui::Core::NavbarText.
Methods inherited from Component
Methods included from GlyphExtension
Methods included from KlassExtension
#exclude_classes, #exclude_classes_in_html_options, #join_classes
Methods inherited from Base
#generate_id, #i18n_set?, #inject_url
Constructor Details
#initialize ⇒ Navbar
See UiBibz::Ui::Core::Component.initialize
81 82 83 84 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 81 def initialize(...) super @items = [] end |
Instance Method Details
#brand(content = nil, options = nil, html_options = nil) ⇒ Object
126 127 128 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 126 def brand(content = nil, = nil, = nil, &) @brand = UiBibz::Ui::Core::Navigations::NavbarBrand.new(content, , , &).render end |
#form(model_or_url, options = {}) ⇒ Object
Add navbar form items See UiBibz::Ui::Core::NavbarForm
115 116 117 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 115 def form(model_or_url, = {}, &) @items << UiBibz::Ui::Core::Navigations::NavbarForm.new(model_or_url, , &) end |
#id ⇒ Object
130 131 132 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 130 def id @id ||= generate_id('navbar-id') end |
#nav(content = nil, options = nil, html_options = nil) ⇒ Object
Add navbar nav items See UiBibz::Ui::Core::NavbarNav
108 109 110 111 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 108 def nav(content = nil, = nil, = nil, &) ||= {} @items << UiBibz::Ui::Core::Navigations::NavbarNav.new(content, , ).tap(&) end |
#navbar_toggle_html(content = nil, &block) ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 134 def (content = nil, &block) @navbar_toggle_html = if block.nil? content else context = eval('self', block.binding) # rubocop:disable Style/EvalWithLocation context.capture(&block) end end |
#pre_render ⇒ Object
Render html tag
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 87 def pre_render content_tag :nav, do UiBibz::Ui::Core::Layouts::Container.new([:container], [:container_html]) do capture do if brand_position == :left concat title concat @navbar_toggle_html end concat if brand_position == :right concat title concat @navbar_toggle_html end concat body_html end end.render end end |
#text(content = nil, options = nil, html_options = nil) ⇒ Object
Not use !!!!! Add navbar text items See UiBibz::Ui::Core::NavbarText
122 123 124 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 122 def text(content = nil, = nil, = nil, &) @items << UiBibz::Ui::Core::Navigations::NavbarText.new(content, , , &) end |