Feat: Add paginator template for boxes

This commit is contained in:
Björn Fromme
2023-10-20 13:39:02 +02:00
parent f5bba20633
commit b0bf854b97
3 changed files with 48 additions and 4 deletions
@@ -0,0 +1,44 @@
{% if pageCount > 0 %}
<div class="bg-gray-100 border border-gray-200 rounded-md px-4 py-3 flex items-center justify-between sm:px-4">
<div class="flex-1 flex items-center justify-between">
<div>
<p class="text-sm leading-5 text-gray-700">{{ 'paginator.info'|trans({ '{from}': firstItemNumber, '{to}': lastItemNumber, '{total}': totalCount })|raw }}</p>
</div>
<div>
<nav class="relative z-0 inline-flex">
{% if pageCount > 1 %}
{% if previous is defined %}
<a href="{{ path(route, query|merge({(pageParameterName): previous})) }}" class="relative inline-flex items-center px-2 py-2 border border-gray-300 bg-white text-sm leading-5 font-medium hover:bg-secondary hover:text-white" aria-label="Previous">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd"/>
</svg>
</a>
{% endif %}
{% if current > 3 %}
<span class="-ml-px relative inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-sm leading-5 font-medium text-gray-700">
...
</span>
{% endif %}
{% for page in pagesInRange %}
<a href="{{ path(route, query|merge({(pageParameterName): page})) }}" class="-ml-px relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm leading-5 font-medium focus:z-10 hover:bg-secondary {% if page == current %}bg-primary text-white hover:text-white{% else %}bg-white text-gray-700 hover:text-white{% endif %}">
{{ page }}
</a>
{% endfor %}
{% if current < pageCount - 3 %}
<span class="-ml-px relative inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-sm leading-5 font-medium text-gray-700">
...
</span>
{% endif %}
{% if next is defined %}
<a href="{{ path(route, query|merge({(pageParameterName): next})) }}" class="-ml-px relative inline-flex items-center px-2 py-2 border border-gray-300 bg-white text-sm leading-5 font-medium hover:bg-secondary hover:text-white" aria-label="Next">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"/>
</svg>
</a>
{% endif %}
{% endif %}
</nav>
</div>
</div>
</div>
{% endif %}
+2 -2
View File
@@ -6,7 +6,7 @@
<h1 class="text-2xl font-bold pb-8"> <h1 class="text-2xl font-bold pb-8">
Meine Merkliste Meine Merkliste
</h1> </h1>
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-4 pb-2"> <div class="grid sm:grid-cols-2 md:grid-cols-3 gap-4 pb-4">
{% for assignment in pagination %} {% for assignment in pagination %}
<div class="flex flex-col justify-between rounded-md border border-gray-200 bg-gray-100 p-4"> <div class="flex flex-col justify-between rounded-md border border-gray-200 bg-gray-100 p-4">
<div class="flex flex-col space-y-2 pb-2"> <div class="flex flex-col space-y-2 pb-2">
@@ -61,5 +61,5 @@
... ist leer ... ist leer
{% endfor %} {% endfor %}
</div> </div>
{{ knp_pagination_render(pagination) }} {{ knp_pagination_render(pagination, 'paginator/sliding_boxes.html.twig') }}
{% endblock %} {% endblock %}
+2 -2
View File
@@ -18,7 +18,7 @@
</div> </div>
{% endif %} {% endif %}
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-4 pb-2"> <div class="grid sm:grid-cols-2 md:grid-cols-3 gap-4 pb-4">
{% for assignment in pagination %} {% for assignment in pagination %}
<div class="relative flex flex-col justify-between rounded-md border border-gray-200 bg-gray-100 p-4"> <div class="relative flex flex-col justify-between rounded-md border border-gray-200 bg-gray-100 p-4">
<div class="flex flex-col space-y-2 pb-2"> <div class="flex flex-col space-y-2 pb-2">
@@ -74,5 +74,5 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
{{ knp_pagination_render(pagination) }} {{ knp_pagination_render(pagination, 'paginator/sliding_boxes.html.twig') }}
{% endblock %} {% endblock %}