Sha256: f179c7d0e390f815afb62fb6d7864a830f51b83ccee0df17a5c57c7232315ec1

Contents?: true

Size: 1.32 KB

Versions: 60

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module NfgUi
  module Bootstrap
    module Components
      # Bootstrap Nav Component
      # https://getbootstrap.com/docs/4.1/components/navs/
      class NavLink < NfgUi::Bootstrap::Components::Base
        include Bootstrap::Utilities::Activatable
        include Bootstrap::Utilities::Disableable
        include Bootstrap::Utilities::Remotable

        def component_family
          :nav
        end

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

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

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

        def render
          if dropdown
            NfgUi::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

        private

        def base_element
          :a
        end

        def component_css_class
          'nav-link'
        end

        def non_html_attribute_options
          super.push(:tab, :dropdown)
        end

        def assistive_html_attributes
          return super unless tab
          { role: 'tab', aria: { controls: tab.tr('#', ''), selected: active } }
        end
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
nfg_ui-0.14.0.1 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.14.0 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.13.2 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.13.1 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.13.0 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.16.1 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.16 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.15 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.14 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.13 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.12 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.11 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.10 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.9 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.8 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.7 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.6 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.5 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.4 lib/nfg_ui/bootstrap/components/nav_link.rb
nfg_ui-0.12.3 lib/nfg_ui/bootstrap/components/nav_link.rb