99 lines
5.0 KiB
PHP
99 lines
5.0 KiB
PHP
@php
|
|
if (!isset($scrollTo)) {
|
|
$scrollTo = 'body';
|
|
}
|
|
|
|
$scrollIntoViewJsSnippet =
|
|
$scrollTo !== false
|
|
? "(\$el.closest('{$scrollTo}') || document.querySelector('{$scrollTo}')).scrollIntoView()"
|
|
: '';
|
|
@endphp
|
|
|
|
@if ($paginator->hasPages())
|
|
<div class="flex flex-col sm:flex-row items-center justify-between gap-4 mt-8">
|
|
<div class="text-sm text-home-foreground/70">
|
|
Menampilkan
|
|
<span class="font-medium">{{ $paginator->firstItem() }}</span>
|
|
-
|
|
<span class="font-medium">{{ $paginator->lastItem() }}</span>
|
|
dari
|
|
<span class="font-medium">{{ $paginator->total() }}</span>
|
|
data
|
|
</div>
|
|
|
|
<nav class="flex items-center justify-center" aria-label="Pagination">
|
|
<div class="flex items-center gap-2">
|
|
@if ($paginator->onFirstPage())
|
|
<button
|
|
class="px-3 py-2 rounded-lg border border-home-foreground/20 text-home-foreground/50 cursor-not-allowed"
|
|
disabled>
|
|
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<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>
|
|
</button>
|
|
@else
|
|
<button wire:click="previousPage('{{ $paginator->getPageName() }}')"
|
|
x-on:click="{{ $scrollIntoViewJsSnippet }}"
|
|
class="px-3 py-2 rounded-lg border border-home-foreground/20 text-home-foreground hover:bg-home-foreground/5 transition-colors">
|
|
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<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>
|
|
</button>
|
|
@endif
|
|
|
|
@foreach ($elements as $element)
|
|
@if (is_string($element))
|
|
<span class="px-4 py-2 text-home-foreground/40">
|
|
{{ $element }}
|
|
</span>
|
|
@endif
|
|
|
|
@if (is_array($element))
|
|
@foreach ($element as $page => $url)
|
|
@if ($page == $paginator->currentPage())
|
|
<button
|
|
class="px-4 py-2 rounded-lg bg-home-foreground text-white font-bold cursor-default"
|
|
aria-current="page">
|
|
{{ $page }}
|
|
</button>
|
|
@else
|
|
<button wire:click="gotoPage({{ $page }}, '{{ $paginator->getPageName() }}')"
|
|
x-on:click="{{ $scrollIntoViewJsSnippet }}"
|
|
class="px-4 py-2 rounded-lg border border-home-foreground/20 text-home-foreground hover:bg-home-foreground/5 transition-colors font-medium">
|
|
{{ $page }}
|
|
</button>
|
|
@endif
|
|
@endforeach
|
|
@endif
|
|
@endforeach
|
|
|
|
@if ($paginator->hasMorePages())
|
|
<button wire:click="nextPage('{{ $paginator->getPageName() }}')"
|
|
x-on:click="{{ $scrollIntoViewJsSnippet }}"
|
|
class="px-3 py-2 rounded-lg border border-home-foreground/20 text-home-foreground hover:bg-home-foreground/5 transition-colors">
|
|
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<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>
|
|
</button>
|
|
@else
|
|
<button
|
|
class="px-3 py-2 rounded-lg border border-home-foreground/20 text-home-foreground/50 cursor-not-allowed"
|
|
disabled>
|
|
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<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>
|
|
</button>
|
|
@endif
|
|
</div>
|
|
</nav>
|
|
</div>
|
|
@endif
|