refactor pagination buttons

This commit is contained in:
2024-06-02 15:55:18 +02:00
parent 6f088f86a1
commit 8296b78d3e

View File

@ -83,30 +83,15 @@ defmodule SomethingErlangWeb.ThreadLive do
"""
end
defp label_button(%{label: "«", page: page} = assigns),
do: ~H"""
<.icon name="hero-chevron-double-left-mini" /><%= page %>
"""
defp label_button(%{label: "", page: page} = assigns),
do: ~H"""
<.icon name="hero-chevron-left-mini" /><%= page %>
"""
defp label_button(%{label: "", page: page} = assigns),
do: ~H"""
<%= page %><.icon name="hero-chevron-right-mini" />
"""
defp label_button(%{label: "»", page: page} = assigns),
do: ~H"""
<%= page %><.icon name="hero-chevron-double-right-mini" />
"""
defp label_button(%{page: page} = assigns),
do: ~H"""
<%= page %>
"""
defp label_button(%{label: label} = assigns) do
case label do
"«" -> ~H{<.icon name="hero-chevron-double-left-mini" /><%= @page %>}
"" -> ~H{<.icon name="hero-chevron-left-mini" /><%= @page %>}
"" -> ~H{<%= @page %><.icon name="hero-chevron-right-mini" />}
"»" -> ~H{<%= @page %><.icon name="hero-chevron-double-right-mini" />}
_ -> ~H{<%= @page %>}
end
end
defp buttons(thread) do
%{page: page_number, page_count: page_count} = thread