defmodule PetalComponents.Pagination do @moduledoc """ Pagination is the method of splitting up content into discrete pages. It specifies the total number of pages and inidicates to a user the current page within the context of total pages. """ use Phoenix.Component import PetalComponents.PaginationInternal alias PetalComponents.Link attr :path, :string, default: "/:page", doc: "page path" attr :class, :string, default: "", doc: "parent div CSS class" attr :link_type, :string, default: "a", values: ["a", "live_patch", "live_redirect", "button"] attr :event, :boolean, default: false, doc: "whether to use `phx-click` events instead of linking. Enabling this will disable `link_type` and `path`." attr :target, :any, default: nil, doc: "the LiveView/LiveComponent to send the event to. Example: `@myself`. Will be ignored if `event` is not enabled." attr :total_pages, :integer, default: nil, doc: "sets a total page count" attr :current_page, :integer, default: nil, doc: "sets the current page" attr :sibling_count, :integer, default: 1, doc: "sets a sibling count" attr :boundary_count, :integer, default: 1, doc: "sets a boundary count" attr :show_boundary_chevrons, :boolean, default: false, doc: "whether to show prev & next buttons at boundary pages" attr :rest, :global @doc """ In the `path` param you can specify :page as the place your page number will appear. e.g "/posts/:page" => "/posts/1" """ def pagination(assigns) do ~H"""