Class: DesignSystem::Govuk::Builders::PaginationRenderer

Inherits:
DesignSystem::Generic::Builders::PaginationRenderer show all
Defined in:
lib/design_system/govuk/builders/pagination_renderer.rb

Overview

This class is used to provide will_paginate renderer for Gov.UK.

Instance Method Summary collapse

Methods inherited from DesignSystem::Generic::Builders::PaginationRenderer

#initialize

Methods included from DesignSystem::Generic::Builders::Concerns::BrandDerivable

#brand

Constructor Details

This class inherits a constructor from DesignSystem::Generic::Builders::PaginationRenderer

Instance Method Details

#container_attributesObject



8
9
10
# File 'lib/design_system/govuk/builders/pagination_renderer.rb', line 8

def container_attributes
  { class: 'govuk-pagination', role: 'navigation', 'aria-label': 'Pagination' }
end

#html_container(html) ⇒ Object



12
13
14
# File 'lib/design_system/govuk/builders/pagination_renderer.rb', line 12

def html_container(html)
  tag(:nav, html, container_attributes)
end

#previous_or_next_page(page, text, classname, aria_label = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/design_system/govuk/builders/pagination_renderer.rb', line 16

def previous_or_next_page(page, text, classname, aria_label = nil)
  if classname.include?('previous_page')
    tag(:div, link_with_prev_title(text, page, aria_label), class: 'govuk-pagination__prev') if page
  elsif classname.include?('next_page')
    tag(:div, link_with_next_title(text, page, aria_label), class: 'govuk-pagination__next') if page
  end
end