-
Notifications
You must be signed in to change notification settings - Fork 209
Open
Labels
Description
Hi there,
First of all thank you for your work, I will use this library in my next pet project.
However, I noticed that there is no easy way to change wrapper classes for pagination_links. For example, the templates for Bulma CSS are centered "by default", which means the classes are hard-coded in private functions. I ended up rewriting the functions like this:
def pagination_links(paginator, conn) do
%{page_number: current_page} = paginator
path_fn = fn number -> Routes.post_path(conn, :index, %{"page" => number}) end
content_tag :nav, class: "pagination" do
content_tag :ul, class: "pagination-list" do
Scrivener.HTML.raw_pagination_links(paginator)
|> Enum.map(fn content -> page(content, current_page, path_fn) end)
end
end
end
defp page({number, number}, number, path_fn),
do: link(Integer.to_string(number), to: path_fn.(number), class: "pagination-link is-current")
defp page({number, number}, _, path_fn),
do: link(Integer.to_string(number), to: path_fn.(number), class: "pagination-link")
defp page({text, number}, _, path_fn) when is_bitstring(text),
do: link(text, to: path_fn.(number), class: "pagination-link")
defp page({:ellipsis, safe}, _, _) do
content_tag :li do
content_tag(:span, safe, class: "pagination-ellipsis")
end
end
defp page(anything, _, _), do: inspect(anything)Do you think it would be possible to add options to change wrapper classes for each separate element? Or maybe add a simple API that one could use to define own renderer modules, a bit like HTTPoison.Base?
Technically, I'm still a newbie, but I'm open to implement and open a PR if you point me in the right direction.
Regards,
KM
Reactions are currently unavailable