Class: CCS::Components::GovUK::Pagination::Item
- Defined in:
- lib/ccs/components/govuk/pagination/item.rb,
lib/ccs/components/govuk/pagination/item/tag.rb,
lib/ccs/components/govuk/pagination/item/form.rb,
lib/ccs/components/govuk/pagination/item/ellipsis.rb
Overview
GOV.UK Pagination Item
This generates the HTML for the pagination item
Defined Under Namespace
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the pagination link
{ class: 'govuk-link govuk-pagination__link' }.freeze
Instance Method Summary collapse
-
#initialize(number:, current: false, **options) ⇒ Item
constructor
A new instance of Item.
-
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Pagination item.
Constructor Details
#initialize(number:, current: false, **options) ⇒ Item
Returns a new instance of Item.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ccs/components/govuk/pagination/item.rb', line 30 def initialize(number:, current: false, **) super(**) @number = number (@options[:attributes][:aria] ||= {})[:label] ||= "Page #{@number}" li_classes = 'govuk-pagination__item' if current li_classes << ' govuk-pagination__item--current' @options[:attributes][:aria][:current] = 'page' end @li_classes = li_classes end |
Instance Method Details
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Pagination item
53 54 55 |
# File 'lib/ccs/components/govuk/pagination/item.rb', line 53 def render(&) tag.li(class: li_classes, &) end |