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, &block) ⇒ Object
-
#form(model_or_url, options = {}, &block) ⇒ Object
Add navbar form items See UiBibz::Ui::Core::NavbarForm.
- #id ⇒ Object
-
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Navbar
constructor
See UiBibz::Ui::Core::Component.initialize.
-
#nav(content = nil, options = nil, html_options = nil, &block) ⇒ 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, &block) ⇒ Object
Not use !!!!! Add navbar text items See UiBibz::Ui::Core::NavbarText.
Methods inherited from Component
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
Methods inherited from Base
#generate_id, #i18n_set?, #inject_url
Constructor Details
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Navbar
See UiBibz::Ui::Core::Component.initialize
81 82 83 84 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 81 def initialize(content = nil, = nil, = nil, &block) super @items = [] end |
Instance Method Details
#brand(content = nil, options = nil, html_options = nil, &block) ⇒ Object
124 125 126 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 124 def brand(content = nil, = nil, = nil, &block) @brand = UiBibz::Ui::Core::Navigations::NavbarBrand.new(content, , , &block).render end |
#form(model_or_url, options = {}, &block) ⇒ Object
Add navbar form items See UiBibz::Ui::Core::NavbarForm
113 114 115 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 113 def form(model_or_url, = {}, &block) @items << UiBibz::Ui::Core::Navigations::NavbarForm.new(model_or_url, , &block) end |
#id ⇒ Object
128 129 130 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 128 def id @id ||= generate_id('navbar-id') end |
#nav(content = nil, options = nil, html_options = nil, &block) ⇒ Object
Add navbar nav items See UiBibz::Ui::Core::NavbarNav
106 107 108 109 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 106 def nav(content = nil, = nil, = nil, &block) ||= {} @items << UiBibz::Ui::Core::Navigations::NavbarNav.new(content, , ).tap(&block) end |
#navbar_toggle_html(content = nil, &block) ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 132 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 |
# 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 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.render end end |
#text(content = nil, options = nil, html_options = nil, &block) ⇒ Object
Not use !!!!! Add navbar text items See UiBibz::Ui::Core::NavbarText
120 121 122 |
# File 'lib/ui_bibz/ui/core/navigations/navbar.rb', line 120 def text(content = nil, = nil, = nil, &block) @items << UiBibz::Ui::Core::Navigations::NavbarText.new(content, , , &block) end |