-
Hi, I'm trying to replicate the table UI component with pagination from Flowbite Flowbite provides the HTML and Tailwind code, but it includes spans within spans This is more or less what I want to replicate from their code
There are also different use cases where Flowbite uses 1 - How can I use pagination_opt to achieve what I need or is there any other approach that accepts any html tag or tailwind? My current opts are:
2 - How do I get the values or the total number of records, page_size and current page number so I can somehow construct the part ? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
You can add a wrapper around the pagination component and derive values from the attr :meta, Flop.Meta, required: true
attr :path, :any, default: nil
attr :on_paginate, JS, default: nil
attr :target, :any, default: nil
def pagination(%{meta: meta} = assigns) do
assigns =
assign(assigns,
from: meta.current_offset + 1,
to: min(meta.current_offset + meta.page_size, meta.total_count)
)
~H"""
<div :if={@meta.total_pages > 1}>
<div>Showing {@from}-{@to} of {@meta.total_count}</div>
<Flop.Phoenix.pagination
meta={@meta}
path={@path}
on_paginate={@on_paginate}
target={@target}
/>
</div>
"""
end Page links can be hidden with |
Beta Was this translation helpful? Give feedback.
-
In case anyone needs the table UI including streams here it goes too. NOTE: This UI needs Flowbite library installed, but it'll work with any Tailwind I guess.
|
Beta Was this translation helpful? Give feedback.
You can add a wrapper around the pagination component and derive values from the
Flop.Meta
struct. Roughly: