44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/icons.php';
|
|
|
|
function renderPaginator(array $pagination, int $totalPages): void {
|
|
if (!$pagination || $totalPages <= 1) return;
|
|
?>
|
|
|
|
<script type="module" src="/assets/scripts/components/select-pagination.js" defer></script>
|
|
<nav aria-label="Pagination" class="pagination">
|
|
<?php if (!empty($pagination['href']['previous'])): ?>
|
|
<a href="<?= $pagination['href']['previous'] ?>" aria-label="Previous page">
|
|
<?= getTablerIcon('arrow-left') ?>
|
|
</a>
|
|
<?php else: ?>
|
|
<span><?= getTablerIcon('arrow-left') ?></span>
|
|
<?php endif; ?>
|
|
|
|
<select-pagination data-base-index="1">
|
|
<select class="client-side" aria-label="Page selection">
|
|
<?php foreach ($pagination['pages'] as $i): ?>
|
|
<option value="<?= $i ?>" <?= ($pagination['pageNumber'] === $i) ? 'selected' : '' ?>>
|
|
<?= $i ?> of <?= $totalPages ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<noscript>
|
|
<p>
|
|
<span aria-current="page"><?= $pagination['pageNumber'] ?></span> of <?= $totalPages ?>
|
|
</p>
|
|
</noscript>
|
|
</select-pagination>
|
|
|
|
<?php if (!empty($pagination['href']['next'])): ?>
|
|
<a href="<?= $pagination['href']['next'] ?>" aria-label="Next page">
|
|
<?= getTablerIcon('arrow-right') ?>
|
|
</a>
|
|
<?php else: ?>
|
|
<span><?= getTablerIcon('arrow-right') ?></span>
|
|
<?php endif; ?>
|
|
</nav>
|
|
|
|
<?php
|
|
}
|