Sha256: 0ade03f6f117d249dd60ddb7f613992d17b4c817f027ff89de66c7ea07b31f6a

Contents?: true

Size: 1.48 KB

Versions: 90

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module NfgUi
  module Bootstrap
    module Components
      # Bootstrap Pagination - Page Item Component
      # https://getbootstrap.com/docs/4.1/components/pagination/
      class PageItem < NfgUi::Bootstrap::Components::Base
        # include Bootstrap::Utilities::Disableable
        include Bootstrap::Utilities::Activatable

        def component_family
          :pagination
        end

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

        def href
          super || '#'
        end

        # Send href through to the "page link" that's embedded within
        # the page item component
        def html_options
          super.except!(:href)
        end

        def page_link_html_options
          { class: 'page-link',
            **(disabled ? { tabindex: '-1' } : {}),
            href: href }
        end

        def render
          super do
            content_tag(:a, page_link_html_options) do
              capture do
                concat(block_given? ? yield : body)
                concat(content_tag(:span, '(current)', class: 'sr-only')) if active
              end
            end
          end
        end

        private

        def base_element
          :li
        end

        def css_classes
          [
            super,
            ('disabled' if disabled)
          ].join(' ').squish
        end

        def non_html_attribute_options
          super.push(:disabled)
        end
      end
    end
  end
end

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
nfg_ui-6.17.2 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-6.17.1 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-6.17.0 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-6.16.3 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-6.16.2 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-6.16.1 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-6.16.0 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-5.15.7 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-5.15.6 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-5.15.5 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-5.15.4 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-5.15.3 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.15.2 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.15.1 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.15.0 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.14.7 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.14.6.3 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.14.6.2 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.14.6.1 lib/nfg_ui/bootstrap/components/page_item.rb
nfg_ui-0.14.6 lib/nfg_ui/bootstrap/components/page_item.rb