Class: Bootstrap4RailsComponents::Bootstrap::Components::NavLink

Inherits:
Base
  • Object
show all
Includes:
Utilities::Activatable, Utilities::Disableable, Utilities::Remotable
Defined in:
lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb

Overview

Instance Attribute Summary

Attributes included from Utilities::Disableable

#as

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Remotable

#remote

Methods included from Utilities::Disableable

#disabled

Methods included from Utilities::Activatable

#active

Methods inherited from Base

#component_initialize, #html_options, #id, #initialize, #style, #utility_initialize

Constructor Details

This class inherits a constructor from Bootstrap4RailsComponents::Bootstrap::Components::Base

Instance Method Details

#component_familyObject



13
14
15
# File 'lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb', line 13

def component_family
  :nav
end

#dataObject



29
30
31
# File 'lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb', line 29

def data
  tab ? super.merge!(toggle: 'tab') : super
end


17
18
19
# File 'lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb', line 17

def dropdown
  options.fetch(:dropdown, false)
end

#hrefObject



21
22
23
# File 'lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb', line 21

def href
  options.fetch(:href, nil)
end

#renderObject



33
34
35
36
37
38
39
# File 'lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb', line 33

def render
  if dropdown
    Bootstrap4RailsComponents::Bootstrap::Components::DropdownToggle.new({ body: (block_given? ? yield : body), as: :a, **html_options, theme: nil, nav_link: true }, view_context).render
  else
    super
  end
end

#tabObject



25
26
27
# File 'lib/bootstrap4_rails_components/bootstrap/components/nav_link.rb', line 25

def tab
  options.fetch(:tab, nil)
end