ScrivenerComponents

CIHex VersionHex docs

Pagination Phoenix.Component for the Scrivener library, compatible with Phoenix 1.7 and LiveViews.

This library is an alternative to scrivener_html, which is no longer actively maintained and is not compatible with Phoenix 1.7 and live views (numerous forks have sprung up to correct this by including a dependency on phoenix_html_helpers...). It reuses part of the scrivener_html code, but it relies on Phoenix.Component to generate the pagination HTML code.

Setup

Add :scrivener_components to your project's dependencies:

def deps do
  [
    {:scrivener_components, "~> 0.1.1"}
  ]
end

Depending on the CSS framework you use, import the component in your view.

defp html_helpers do
  quote do
    # ...
    # Import the pagination component for your CSS framework
    import Scrivener.Components.BootstrapV5
  end
end

Available framworks / modules:

Usage

Use in your template:

<.pagination page={page} url_params={[{"q", "term"}]} path={&~p"/index?#{&1}"} />

You may customize and translate texts:

<.pagination
  page={page}
  url_params={[{"q", "term"}]}
  path={&~p"/posts?#{&1}"}
  navigation_mode={:patch}
  options={[
    next: gettext("Next"),
    previous: gettext("Previous")
  ]} />
  data-custom-attr="hello"

Where: