Class: Primer::OpenProject::Pagination
- Defined in:
- app/components/primer/open_project/pagination.rb
Defined Under Namespace
Classes: PageData
Constant Summary collapse
- DEFAULT_MARGIN_PAGE_COUNT =
1- DEFAULT_SURROUNDING_PAGE_COUNT =
2- PAGE_TYPE__BREAK =
:break- PAGE_TYPE__PREV =
:prev- PAGE_TYPE__NEXT =
:next- PAGE_TYPE__NUM =
:num
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#href_builder ⇒ Object
readonly
Returns the value of attribute href_builder.
-
#margin_page_count ⇒ Object
readonly
Returns the value of attribute margin_page_count.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
-
#show_pages ⇒ Object
readonly
Returns the value of attribute show_pages.
-
#surrounding_page_count ⇒ Object
readonly
Returns the value of attribute surrounding_page_count.
Instance Method Summary collapse
-
#initialize(page_count:, current_page:, href_builder: nil, margin_page_count: DEFAULT_MARGIN_PAGE_COUNT, show_pages: true, surrounding_page_count: DEFAULT_SURROUNDING_PAGE_COUNT, link_arguments: {}, **system_arguments) ⇒ Pagination
constructor
A new instance of Pagination.
- #pages ⇒ Object
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(page_count:, current_page:, href_builder: nil, margin_page_count: DEFAULT_MARGIN_PAGE_COUNT, show_pages: true, surrounding_page_count: DEFAULT_SURROUNDING_PAGE_COUNT, link_arguments: {}, **system_arguments) ⇒ Pagination
Returns a new instance of Pagination.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/components/primer/open_project/pagination.rb', line 25 def initialize( page_count:, current_page:, href_builder: nil, margin_page_count: DEFAULT_MARGIN_PAGE_COUNT, show_pages: true, surrounding_page_count: DEFAULT_SURROUNDING_PAGE_COUNT, link_arguments: {}, **system_arguments ) @page_count = cast_integer!(page_count, "page_count") @current_page = cast_integer!(current_page, "current_page") @href_builder = href_builder || method(:default_href_builder) @margin_page_count = cast_integer!(margin_page_count, "margin_page_count") @show_pages = show_pages @surrounding_page_count = cast_integer!(surrounding_page_count, "surrounding_page_count") @link_arguments = link_arguments @system_arguments = system_arguments @system_arguments[:tag] = :nav @system_arguments[:classes] = class_names( "PaginationContainer", @system_arguments[:classes] ) @system_arguments["aria-label"] = I18n.t("pagination.label") validate_arguments! end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
18 19 20 |
# File 'app/components/primer/open_project/pagination.rb', line 18 def current_page @current_page end |
#href_builder ⇒ Object (readonly)
Returns the value of attribute href_builder.
18 19 20 |
# File 'app/components/primer/open_project/pagination.rb', line 18 def href_builder @href_builder end |
#margin_page_count ⇒ Object (readonly)
Returns the value of attribute margin_page_count.
18 19 20 |
# File 'app/components/primer/open_project/pagination.rb', line 18 def margin_page_count @margin_page_count end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
18 19 20 |
# File 'app/components/primer/open_project/pagination.rb', line 18 def page_count @page_count end |
#show_pages ⇒ Object (readonly)
Returns the value of attribute show_pages.
18 19 20 |
# File 'app/components/primer/open_project/pagination.rb', line 18 def show_pages @show_pages end |
#surrounding_page_count ⇒ Object (readonly)
Returns the value of attribute surrounding_page_count.
18 19 20 |
# File 'app/components/primer/open_project/pagination.rb', line 18 def surrounding_page_count @surrounding_page_count end |
Instance Method Details
#pages ⇒ Object
54 55 56 57 58 |
# File 'app/components/primer/open_project/pagination.rb', line 54 def pages build_pagination_model.map do |page| build_component_data(page) end end |