petalframework / petal_components

Phoenix + Live View HEEX Components
https://petal.build/components
MIT License
768 stars 84 forks source link

Add option to send events in pagination component #241

Closed RobinBoers closed 11 months ago

RobinBoers commented 11 months ago

This PR adds the event flag to the pagination component. If enabled, the link_type and path options will be overwritten, and clicking the buttons in the component will send events to the parent LiveView. Here's an example:

<.pagination event={true} current_page={@page} total_pages={@total_pages} />
@impl true
def handle_event("goto-page", %{"page" => page}, socket) do
  {:noreply, push_patch(socket, to: ~p"/posts/#{page}")}
end

This PR is a replacement for #240

nhobes commented 11 months ago

Released in 1.4.2!