Sha256: 9fa0fcf9b7c495814827e4633e6a3e6f6eebac205a406abe2b9dfb2b1b5faa03
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
require_relative '../../base' module CCS module Components module GovUK class Pagination < Base # = GOV.UK Pagination Item # # This generates the HTML for the pagination item # # @!attribute [r] number # @return [String] The number for the item # @!attribute [r] li_classes # @return [String] HTML classes for pagination item +li+ element class Item < Base private attr_reader :number, :li_classes public # @param number [String] the number for the item # @param current [Boolean] flag to indicate if this item is the current page # # @option options [String] :classes additional CSS classes for the item HTML # @option options [Boolean] :ellipsis If the value is +true+ then an ellipsis will be rendered # @option options [Hash] :attributes any additional attributes that will added as part of the HTML def initialize(number:, current: false, **options) super(**options) @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 # Generates the HTML for the GOV.UK Pagination item # # @yield the HTML for the pagination item link/button # # @return [ActiveSupport::SafeBuffer] def render(&) tag.li(class: li_classes, &) end # The default attributes for the pagination link DEFAULT_ATTRIBUTES = { class: 'govuk-link govuk-pagination__link' }.freeze end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ccs-frontend_helpers-2.1.0 | lib/ccs/components/govuk/pagination/item.rb |
ccs-frontend_helpers-2.0.0 | lib/ccs/components/govuk/pagination/item.rb |