Class: NfgUi::Bootstrap::Components::PageItem

Inherits:
Base
  • Object
show all
Includes:
Utilities::Activatable
Defined in:
lib/nfg_ui/bootstrap/components/page_item.rb

Overview

Bootstrap Pagination - Page Item Component getbootstrap.com/docs/4.1/components/pagination/

Direct Known Subclasses

Components::Elements::PageItem

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Activatable

#active

Methods inherited from Base

#data, #id, #initialize, #style

Constructor Details

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

Instance Method Details

#component_familyObject



12
13
14
# File 'lib/nfg_ui/bootstrap/components/page_item.rb', line 12

def component_family
  :pagination
end

#disabledObject



16
17
18
# File 'lib/nfg_ui/bootstrap/components/page_item.rb', line 16

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

#hrefObject



20
21
22
# File 'lib/nfg_ui/bootstrap/components/page_item.rb', line 20

def href
  super || '#'
end

#html_optionsObject

Send href through to the “page link” that’s embedded within the page item component



26
27
28
# File 'lib/nfg_ui/bootstrap/components/page_item.rb', line 26

def html_options
  super.except!(:href)
end


30
31
32
33
34
# File 'lib/nfg_ui/bootstrap/components/page_item.rb', line 30

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

#renderObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/nfg_ui/bootstrap/components/page_item.rb', line 36

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