Class: NfgUi::Bootstrap::Components::NavItem
- Includes:
- Utilities::Wrappable
- Defined in:
- lib/nfg_ui/bootstrap/components/nav_item.rb
Overview
Bootstrap Nav Component getbootstrap.com/docs/4.1/components/navs/
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Utilities::Wrappable
Attributes inherited from Base
#body, #options, #view_context
Instance Method Summary collapse
-
#active ⇒ Object
For passing through to nav_link bypass module since active / disabled is applied on the nav_link.
- #button ⇒ Object
- #component_family ⇒ Object
-
#disabled ⇒ Object
For passing through to nav_link.
- #dropdown ⇒ Object
-
#html_options ⇒ Object
href gets passed to the nav_link when present.
- #include_nav_link? ⇒ Boolean
- #remote ⇒ Object
- #render ⇒ Object
- #tab ⇒ Object
Methods included from Utilities::Wrappable
Methods inherited from Base
#data, #href, #id, #initialize, #style
Constructor Details
This class inherits a constructor from NfgUi::Bootstrap::Components::Base
Instance Method Details
#active ⇒ Object
For passing through to nav_link bypass module since active / disabled is applied on the nav_link
14 15 16 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 14 def active .fetch(:active, false) end |
#button ⇒ Object
18 19 20 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 18 def .fetch(:button, nil) end |
#component_family ⇒ Object
22 23 24 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 22 def component_family :nav end |
#disabled ⇒ Object
For passing through to nav_link
31 32 33 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 31 def disabled .fetch(:disabled, false) end |
#dropdown ⇒ Object
35 36 37 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 35 def dropdown .fetch(:dropdown, false) end |
#html_options ⇒ Object
href gets passed to the nav_link when present. Removes :href from nav_item’s html_options so we don’t end up with <li class=‘nav-item’ href=‘#href’><a class=‘nav-link’ href=‘#href’…
50 51 52 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 50 def super.except!(:href) end |
#include_nav_link? ⇒ Boolean
39 40 41 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 39 def include_nav_link? href.present? || dropdown || tab end |
#remote ⇒ Object
26 27 28 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 26 def remote .fetch(:remote, nil) end |
#render ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 54 def render super do capture do if include_nav_link? concat(NfgUi::Bootstrap::Components::NavLink.new({ body: ( ? : (block_given? ? yield : body)), active: active, disabled: disabled, dropdown: dropdown, tab: tab, remote: remote, href: (tab || href) }, view_context).render) concat(block_given? ? yield : body) if dropdown else (block_given? ? yield : body) end end end end |
#tab ⇒ Object
43 44 45 |
# File 'lib/nfg_ui/bootstrap/components/nav_item.rb', line 43 def tab .fetch(:tab, nil) end |