- Tailwind source(none) wasn't scanning deps, so shadcn tokens (border-border, bg-muted, text-foreground, ...) used by live_table and sutra_ui weren't generated, leaving `border` to fall back to currentcolor — a heavy dark border around every table in light mode. Add @source directives for deps/live_table/lib and deps/sutra_ui/lib. - Drop the hardcoded width:100% on the outer .select wrapper so the per-page selector's Tailwind w-24 wins instead of stretching across the header and overlapping the search box. - Make whole rows clickable: global click delegator in app.ts forwards tr clicks to the first <a href> in the row (the Actions "View" link), skipping inner interactive elements. cursor + hover highlight added. - Replace the default Prev/Next footer with a daisyUI .join/.btn-based pager (MicrowavepropWeb.LiveTableFooter), wired up globally via :live_table defaults so it applies to every live_table at once.
59 lines
1.7 KiB
Elixir
59 lines
1.7 KiB
Elixir
defmodule MicrowavepropWeb.LiveTableFooter do
|
|
@moduledoc false
|
|
use Phoenix.Component
|
|
|
|
def render(assigns) do
|
|
options = assigns.options
|
|
table_options = assigns.table_options
|
|
paginate? = get_in(options, ["pagination", "paginate?"])
|
|
mode = get_in(table_options, [:pagination, :mode])
|
|
|
|
assigns =
|
|
assigns
|
|
|> assign(:show_pagination?, paginate? && mode != :infinite_scroll)
|
|
|> assign(:page, parse_page(get_in(options, ["pagination", "page"])))
|
|
|> assign(:has_next_page?, get_in(options, ["pagination", :has_next_page]) || false)
|
|
|
|
~H"""
|
|
<nav
|
|
:if={@show_pagination?}
|
|
class="flex items-center justify-between px-4 py-3 sm:px-6"
|
|
aria-label="Pagination"
|
|
>
|
|
<p class="hidden sm:block text-sm opacity-60">
|
|
Page <span class="font-medium text-base-content">{@page}</span>
|
|
</p>
|
|
|
|
<div class="join">
|
|
<button
|
|
type="button"
|
|
class="btn btn-sm join-item"
|
|
phx-click="sort"
|
|
phx-value-page={@page - 1}
|
|
disabled={@page == 1}
|
|
aria-label="Previous page"
|
|
>
|
|
«
|
|
</button>
|
|
<button type="button" class="btn btn-sm join-item btn-active pointer-events-none">
|
|
{@page}
|
|
</button>
|
|
<button
|
|
type="button"
|
|
class="btn btn-sm join-item"
|
|
phx-click="sort"
|
|
phx-value-page={@page + 1}
|
|
disabled={!@has_next_page?}
|
|
aria-label="Next page"
|
|
>
|
|
»
|
|
</button>
|
|
</div>
|
|
</nav>
|
|
"""
|
|
end
|
|
|
|
defp parse_page(page) when is_integer(page), do: page
|
|
defp parse_page(page) when is_binary(page), do: String.to_integer(page)
|
|
defp parse_page(_), do: 1
|
|
end
|