feat(*): refactor dynamic vs. static structure and distinctions; make additional elements dynamic

This commit is contained in:
Cory Dransfeldt 2025-06-13 16:31:36 -07:00
parent 7a0b808f24
commit 4d76a3ba1e
No known key found for this signature in database
138 changed files with 998 additions and 970 deletions

41
app/Utils/paginator.php Normal file
View file

@ -0,0 +1,41 @@
<?php
if (!function_exists('renderPaginator')) {
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
}
}