petalframework / petal_components

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

Allow custom slots in pagination component + format project using styler #240

Closed RobinBoers closed 11 months ago

RobinBoers commented 11 months ago

Hi! I extended the pagination component to allow custom slots, like this:

<.pagination class="mb-5" current_page={@page} total_pages={@total_pages}>
  <:prev>
    <span phx-click="prev-page" class="pc-pagination__item__previous">
      <Heroicons.chevron_left solid class="pc-pagination__item__previous__chevron" />
    </span>
  </:prev>
  <:page :let={page}>
    <span phx-click="to-page" phx-value-page={page}>
      <%= page %>
    </span>
  </:page>
  <:next>
    <span phx-click="next-page" class="pc-pagination__item__next">
      <Heroicons.chevron_right solid class="pc-pc-pagination__item__next__chevron" />
    </span>
  </:next>
</.pagination>

It is completely optional. If the slots don't exist, they won't be used. I also added an test to test this change.

I removed the brackets in attrs for a lot of components too, and formatted the project using styler.

RobinBoers commented 11 months ago

Nvm, I'll put formatting in an seperate PR.