class Bootstrap4RailsComponents::Bootstrap::Components::NavItem

Bootstrap Nav Component getbootstrap.com/docs/4.1/components/navs/

Public Instance Methods

active() click to toggle source

For passing through to nav_link bypass module since active / disabled is applied on the nav_link

# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 14
def active
  options.fetch(:active, false)
end
button() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 18
def button
  options.fetch(:button, nil)
end
component_family() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 22
def component_family
  :nav
end
disabled() click to toggle source

For passing through to nav_link

# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 31
def disabled
  options.fetch(:disabled, false)
end
dropdown() click to toggle source
html_options() click to toggle source

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'…

# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 50
def html_options
  super.except!(:href)
end
remote() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 26
def remote
  options.fetch(:remote, nil)
end
render() { |: body)), active: active, disabled: disabled, dropdown: dropdown, tab: tab, remote: remote, href: (tab || href)| ... } click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 54
def render
  super do
    capture do
      if include_nav_link?
        concat(Bootstrap4RailsComponents::Bootstrap::Components::NavLink.new({ body: (button ? button : (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() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 43
def tab
  options.fetch(:tab, nil)
end

Private Instance Methods

automatic_as() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 77
def automatic_as
  include_nav_link? ? :li : super
end
base_element() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 69
def base_element
  as
end
component_css_class() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 73
def component_css_class
  'nav-item'
end
css_classes() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 81
def css_classes
  [
    super,
    ('dropdown' if dropdown)
  ].join(' ').squish
end
default_html_wrapper_element() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 88
def default_html_wrapper_element
  :li
end
non_html_attribute_options() click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/components/nav_item.rb, line 92
def non_html_attribute_options
  super.push(:active,
             :disabled,
             :dropdown,
             :button,
             :tab,
             :remote)
end