Class: CCS::Components::GovUK::Pagination::Increment::Next

Inherits:
CCS::Components::GovUK::Pagination::Increment show all
Defined in:
lib/ccs/components/govuk/pagination/increment/next.rb

Overview

GOV.UK Pagination Next

This generates the HTML for the pagination next link

Constant Summary collapse

PAGINATION_ICON_PATH =

The path for the pagination next icon

'm8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z'.freeze

Constants inherited from Base

Base::DEFAULT_ATTRIBUTES

Instance Method Summary collapse

Constructor Details

#initialize(text: nil, **options) ⇒ Next

Returns a new instance of Next.

Parameters:

  • type (Symbol)

    the type of increment, either :prev or :next

  • default_text (String)

    the default text for the pagination increment

  • text (String) (defaults to: nil)

    the text for the pagination increment

  • block_is_level (Boolean)

    when there are no items, this will be true and will add extra classes to the link to make the next and previous pagination links level

  • label_text (String)

    additional text for the link when the pagination block is level

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :href (String)

    the URL for the link

  • :form (ActionView::Helpers::FormBuilder)

    optional form builder used to create the button

  • :attributes (Hash)

    any additional attributes that will added as part of the HTML



17
18
19
# File 'lib/ccs/components/govuk/pagination/increment/next.rb', line 17

def initialize(text: nil, **options)
  super(type: :next, text: text, default_text: 'Next', **options)
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the next link in the pagination

Returns:

  • (ActiveSupport::SafeBuffer)


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ccs/components/govuk/pagination/increment/next.rb', line 25

def render
  tag.div(class: 'govuk-pagination__next') do
    super do
      concat(pagination_icon) if block_is_level
      concat(tag.span(class: pagination_text_classes) do
        concat(text)
        concat(tag.span(' page', class: 'govuk-visually-hidden')) if text == default_text
      end)
      pagination_icon_label_text
      concat(pagination_icon) unless block_is_level
    end
  end
end