Class: DesignSystem::Generic::Builders::PaginationRenderer
- Inherits:
-
WillPaginate::ActionView::LinkRenderer
- Object
- WillPaginate::ActionView::LinkRenderer
- DesignSystem::Generic::Builders::PaginationRenderer
- Includes:
- Concerns::BrandDerivable
- Defined in:
- lib/design_system/generic/builders/pagination_renderer.rb
Overview
This class is used to provide will_paginate renderer.
Direct Known Subclasses
DesignSystem::Govuk::Builders::PaginationRenderer, Nhsuk::Builders::PaginationRenderer
Instance Method Summary collapse
- #container_attributes ⇒ Object
- #html_container(html) ⇒ Object
-
#initialize(context) ⇒ PaginationRenderer
constructor
A new instance of PaginationRenderer.
- #previous_or_next_page(page, text, classname, aria_label = nil) ⇒ Object
Methods included from Concerns::BrandDerivable
Constructor Details
#initialize(context) ⇒ PaginationRenderer
Returns a new instance of PaginationRenderer.
12 13 14 15 |
# File 'lib/design_system/generic/builders/pagination_renderer.rb', line 12 def initialize(context) @context = context super() end |
Instance Method Details
#container_attributes ⇒ Object
17 18 19 |
# File 'lib/design_system/generic/builders/pagination_renderer.rb', line 17 def container_attributes { class: "#{brand}-pagination", role: 'navigation', 'aria-label': 'Pagination' } end |
#html_container(html) ⇒ Object
21 22 23 24 |
# File 'lib/design_system/generic/builders/pagination_renderer.rb', line 21 def html_container(html) # Wrap pagination items in the correct container tag(:nav, tag(:ul, html, class: "#{brand}-list #{brand}-pagination__list"), container_attributes) end |
#previous_or_next_page(page, text, classname, aria_label = nil) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/design_system/generic/builders/pagination_renderer.rb', line 26 def previous_or_next_page(page, text, classname, aria_label = nil) if classname.include?('previous_page') build_page_item(page, text, 'Previous', previous_icon, "#{brand}-pagination-item--previous", aria_label) elsif classname.include?('next_page') build_page_item(page, text, 'Next', next_icon, "#{brand}-pagination-item--next", aria_label) end end |