pagination contains more numbers now

This commit is contained in:
2022-08-02 14:11:49 +02:00
parent 962cf2592a
commit 606f5df100
2 changed files with 11 additions and 7 deletions

View File

@ -68,25 +68,25 @@ defmodule SomethingErlangWeb.ThreadLive.Show do
next_button_target = if page_number < page_count, do: page_number + 1, else: page_count
buttons = [
%{label: "«", page: 1, special: " btn-square" <> first_page_disabled_button},
%{label: "", page: prev_button_target, special: " btn-square" <> first_page_disabled_button},
%{label: "«", page: 1, special: "" <> first_page_disabled_button},
%{label: "", page: prev_button_target, special: "" <> first_page_disabled_button},
%{label: "#{page_number}", page: page_number, special: active_page_button},
%{label: "", page: next_button_target, special: " btn-square" <> last_page_disabled_button},
%{label: "»", page: page_count, special: " btn-square" <> last_page_disabled_button}
%{label: "", page: next_button_target, special: "" <> last_page_disabled_button},
%{label: "»", page: page_count, special: "" <> last_page_disabled_button}
]
~H"""
<div class="navbar my-4 bg-base-200">
<div class="flex-1"></div>
<div class="flex-none btn-group">
<div class="pagination flex-none btn-group">
<%= for btn <- buttons do %>
<%= live_redirect class: "btn btn-sm" <> btn.special,
to: Routes.thread_show_path(@socket, :show, @thread.id, page: btn.page) do %>
<%= case btn.label do %>
<% "«" -> %><Icons.chevron_left_double />
<% "«" -> %>1 <Icons.chevron_left_double />
<% "" -> %><Icons.chevron_left />
<% "" -> %><Icons.chevron_right />
<% "»" -> %><Icons.chevron_right_double />
<% "»" -> %><Icons.chevron_right_double /> <%= page_count %>
<% _ -> %><%= btn.label %>
<% end %>
<% end %>