Module

FPO.Components.Pagination

Generic pagination component. This component can be used to display a pagination bar with clickable page numbers.

It supports two Styles (Full and Compact) to control how many page numbers are displayed. Furthermore, one can specify how the component reacts to changes in the page count (i.e., when the user changes the amount of pages and thus the amount of pagination items) using Reaction.

The component allows for querying, i.e., the parent component can request the component to jump to a specific page number.

#Input

type Input = { pages :: Int, reaction :: Reaction, style :: Style }

#Output

data Output

The page number that was clicked.

Constructors

#Query

data Query a

Constructors

#Reaction

data Reaction

Specifies the way the pagination reacts to changes to the page count (i.e., the user changes the amount of pages and thus the amount of pagination items).

Constructors

  • FirstPage

    The first page is reached.

  • PreservePage

    The closest page is reached.

    That is, if the page number increases, the shown page does not change. Otherwise, if the current page number becomes invalid, the highest valid page number is shown.

#Style

data Style

The style of the pagination component.

Constructors

  • Full

    Full pagination style, showing all page numbers.

  • Compact Int

    Compact pagination style, showing only a few page numbers (first, last, current and directly adjacent pages).

    The argument i in Compact i specifies how many adjacent pages to show on each side of the current page, excluding the start and end pages (which are always shown).

#calculatePageCount

calculatePageCount :: Int -> Int -> Int

Calculates the number of pages based on the total number of items and the number of items per page.

#component

Modules