Class: UiBibz::Ui::Core::Navigations::Nav
- Defined in:
- lib/ui_bibz/ui/core/navigations/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
) -
position
- Symbol (:left
,:right
,:center
) -
stacked
- Boolean -
tag
- Symbol (:a
, +:li) -
justify
- Boolean -
fill
- Boolean
Signatures
UiBibz::Ui::Core::Navigations::Nav.new(content, options = nil, html_options = nil)
UiBibz::Ui::Core::Navigations::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::Navigations::Nav.new(type: :pills).tap do |n|
n.link 'Test', url: '#test'
n.link 'Test2', url: '#test2', state: :active
n.dropdown('Action') do |d|
d.list content = nil, = nil, = nil, &block
end
end.render
Helper
nav( = {}, = {}) do |n|
n.link(content, = {}, = {})
n.link( = {}, = {}) do
content
end
n.dropdown(name, = {}, = {}) do |d|
d.list(content, = {}, = {})
d.list( = {}, = {}) do
content
end
end
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
-
#dropdown(content = nil, options = {}, html_options = nil, &block) ⇒ Object
Add nav dropdown items See UiBibz::Ui::Core::Navigations::NavDropdown.
-
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Nav
constructor
See UiBibz::Ui::Core::Component.initialize.
-
#link(content = nil, options = {}, html_options = nil, &block) ⇒ Object
Add nav link items See UiBibz::Ui::Core::Navigations::NavLink.
-
#nav(content = nil, options = {}, html_options = nil, &block) ⇒ Object
Add nav in nav.
-
#pre_render ⇒ Object
Render html tag.
- #text(content = nil, options = {}, html_options = nil, &block) ⇒ Object
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, #status
Methods inherited from Base
#generate_id, #i18n_set?, #inject_url
Constructor Details
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Nav
See UiBibz::Ui::Core::Component.initialize
73 74 75 76 |
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 73 def initialize(content = nil, = nil, = nil, &block) super @items = [] end |
Instance Method Details
#dropdown(content = nil, options = {}, html_options = nil, &block) ⇒ Object
Add nav dropdown items See UiBibz::Ui::Core::Navigations::NavDropdown
108 109 110 |
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 108 def dropdown(content = nil, = {}, = nil, &block) @items << NavDropdown.new(content, , ).tap(&block) end |
#link(content = nil, options = {}, html_options = nil, &block) ⇒ Object
Add nav link items See UiBibz::Ui::Core::Navigations::NavLink
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 85 def link(content = nil, = {}, = nil, &block) if block content[:nav_type] = type content[:nav_tags] = else [:nav_type] = type [:nav_tags] = end @items << NavLink.new(content, , , &block) end |
#nav(content = nil, options = {}, html_options = nil, &block) ⇒ Object
Add nav in nav
102 103 104 |
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 102 def nav(content = nil, = {}, = nil, &block) @items << UiBibz::Ui::Core::Component.new(Nav.new(content, ).tap(&block).render, {}, ) end |
#pre_render ⇒ Object
Render html tag
79 80 81 |
# File 'lib/ui_bibz/ui/core/navigations/nav.rb', line 79 def pre_render content_tag htlm_tag, @items.map(&:render).join.html_safe, end |