tests / lint (push) Successful in 1m0s
tests / feature (8.4) (push) Successful in 1m10s
tests / feature (8.5) (push) Successful in 1m6s
tests / browser (chrome, chromium) (push) Successful in 3m28s
tests / browser (firefox, firefox) (push) Successful in 4m20s
tests / browser (safari, webkit) (push) Failing after 6m16s
A data table styled from descendant selectors, a Livewire sort header with aria-sort, and Laravel's and Livewire's full and simple paginators drawn in M3, put in front of their own views. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
41 lines
2.5 KiB
PHP
41 lines
2.5 KiB
PHP
{{-- Livewire's simple and cursor paginator, drawn in M3: previous and next as outlined buttons
|
|
(the package puts this in front of `livewire::simple-tailwind`). --}}
|
|
|
|
@php
|
|
if (! isset($scrollTo)) {
|
|
$scrollTo = 'body';
|
|
}
|
|
|
|
$scrollIntoViewJsSnippet = ($scrollTo !== false)
|
|
? <<<JS
|
|
(\$el.closest('{$scrollTo}') || document.querySelector('{$scrollTo}')).scrollIntoView()
|
|
JS
|
|
: '';
|
|
|
|
$cursor = method_exists($paginator, 'getCursorName');
|
|
@endphp
|
|
|
|
<div>
|
|
@if ($paginator->hasPages())
|
|
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-pagination class="flex items-center justify-between gap-4">
|
|
@if ($paginator->onFirstPage())
|
|
<x-button variant="outlined" icon="chevron_left" :label="__('Previous')" disabled />
|
|
@elseif ($cursor)
|
|
@php($previousCursor = $paginator->previousCursor() ?? $paginator->cursor())
|
|
<x-button variant="outlined" icon="chevron_left" :label="__('Previous')" wire:key="cursor-{{ $paginator->getCursorName() }}-{{ $previousCursor?->encode() }}" wire:click="setPage('{{ $previousCursor?->encode() }}', '{{ $paginator->getCursorName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="previousPage" />
|
|
@else
|
|
<x-button variant="outlined" icon="chevron_left" :label="__('Previous')" wire:click="previousPage('{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="previousPage" />
|
|
@endif
|
|
|
|
@if (! $paginator->hasMorePages())
|
|
<x-button variant="outlined" icon-right="chevron_right" :label="__('Next')" disabled />
|
|
@elseif ($cursor)
|
|
@php($nextCursor = $paginator->nextCursor() ?? $paginator->cursor())
|
|
<x-button variant="outlined" icon-right="chevron_right" :label="__('Next')" wire:key="cursor-{{ $paginator->getCursorName() }}-{{ $nextCursor?->encode() }}" wire:click="setPage('{{ $nextCursor?->encode() }}', '{{ $paginator->getCursorName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="nextPage" />
|
|
@else
|
|
<x-button variant="outlined" icon-right="chevron_right" :label="__('Next')" wire:click="nextPage('{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="nextPage" />
|
|
@endif
|
|
</nav>
|
|
@endif
|
|
</div>
|