Class: CCS::Components::GovUK::Pagination::Increment::Previous

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

Overview

GOV.UK Pagination Previous

This generates the HTML for the pagination previous link

Constant Summary collapse

PAGINATION_ICON_PATH =

The path for the pagination previous icon

'm6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z'.freeze

Constants inherited from Base

Base::DEFAULT_ATTRIBUTES

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Previous.

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/previous.rb', line 17

def initialize(text: nil, **options)
  super(type: :prev, text: text, default_text: 'Previous', **options)
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the previous link in the pagination

Returns:

  • (ActiveSupport::SafeBuffer)


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

def render
  tag.div(class: 'govuk-pagination__prev') do
    super do
      concat(pagination_icon)
      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
    end
  end
end