Draw the paginators without Tailwind
Laravel's and Livewire's paginator views render data-md-pagination hooks; pagination.css draws the row, the 40px steps with their 48px targets, the selected page and the swap to "Page n of m" below 600px (plan step 36, inputs). It imports button.css for the simple paginators, now that the button is rewritten. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
co-authored by
Claude Opus 5
parent
6df034f81a
commit
2acd9ab492
@@ -2,7 +2,7 @@
|
||||
(the package puts this in front of `pagination::simple-tailwind`). --}}
|
||||
|
||||
@if ($paginator->hasPages())
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-pagination class="flex items-center justify-between gap-4">
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-md-pagination>
|
||||
@if ($paginator->onFirstPage())
|
||||
<x-livewire-material::button variant="outlined" icon="chevron_left" :label="__('Previous')" disabled />
|
||||
@else
|
||||
|
||||
@@ -1,55 +1,50 @@
|
||||
{{-- Laravel's paginator (`$items->links()` outside Livewire), drawn in M3 as Livewire's is
|
||||
(resources/views/pagination/livewire/tailwind.blade.php): links instead of actions, the current
|
||||
page in secondary-container, "Page 2 of 7" on a phone. The package puts this in front of
|
||||
`pagination::tailwind` (config `livewire-material.pagination`). --}}
|
||||
|
||||
@php
|
||||
$step = 'grid size-10 place-items-center rounded-corner-full type-label-lg tabular-nums';
|
||||
$live = $step.' state-layer focus-ring touch-target text-on-surface';
|
||||
$dead = $step.' text-on-surface/38';
|
||||
@endphp
|
||||
page in secondary-container, "Page 2 of 7" below 600px. The package puts this in front of
|
||||
`pagination::tailwind` (config `livewire-material.pagination`); the name is Laravel's, the drawing
|
||||
resources/css/components/pagination.css. --}}
|
||||
|
||||
@if ($paginator->hasPages())
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-pagination class="flex items-center justify-between gap-4">
|
||||
<p class="type-body-sm text-on-surface-variant">
|
||||
<span class="medium:hidden">{{ __('Page :page of :pages', ['page' => $paginator->currentPage(), 'pages' => $paginator->lastPage()]) }}</span>
|
||||
<span class="max-medium:hidden">{{ __(':first–:last of :total', ['first' => $paginator->firstItem(), 'last' => $paginator->lastItem(), 'total' => $paginator->total()]) }}</span>
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-md-pagination>
|
||||
<p data-md-pagination-summary>
|
||||
<span data-md-pagination-compact>{{ __('Page :page of :pages', ['page' => $paginator->currentPage(), 'pages' => $paginator->lastPage()]) }}</span>
|
||||
<span data-md-pagination-range>{{ __(':first–:last of :total', ['first' => $paginator->firstItem(), 'last' => $paginator->lastItem(), 'total' => $paginator->total()]) }}</span>
|
||||
</p>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<div data-md-pagination-steps>
|
||||
@if ($paginator->onFirstPage())
|
||||
<span class="{{ $dead }}" aria-disabled="true" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" class="size-6 rtl:-scale-x-100" />
|
||||
<span data-md-pagination-step aria-disabled="true" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" mirror-rtl />
|
||||
</span>
|
||||
@else
|
||||
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="{{ $live }}" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" class="size-6 rtl:-scale-x-100" />
|
||||
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" data-md-pagination-step class="md-state-layer md-focus-ring md-touch-target" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" mirror-rtl />
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@foreach ($elements as $element)
|
||||
@if (is_string($element))
|
||||
<span class="{{ $dead }} max-medium:hidden" aria-disabled="true">{{ $element }}</span>
|
||||
<span data-md-pagination-step data-md-pagination-page aria-disabled="true">{{ $element }}</span>
|
||||
@endif
|
||||
|
||||
@if (is_array($element))
|
||||
@foreach ($element as $page => $url)
|
||||
@if ($page == $paginator->currentPage())
|
||||
<span aria-current="page" class="{{ $step }} bg-secondary-container text-on-secondary-container max-medium:hidden">{{ $page }}</span>
|
||||
<span aria-current="page" data-md-pagination-step data-md-pagination-page>{{ $page }}</span>
|
||||
@else
|
||||
<a href="{{ $url }}" class="{{ $live }} max-medium:hidden" aria-label="{{ __('Go to page :page', ['page' => $page]) }}">{{ $page }}</a>
|
||||
<a href="{{ $url }}" data-md-pagination-step data-md-pagination-page class="md-state-layer md-focus-ring md-touch-target" aria-label="{{ __('Go to page :page', ['page' => $page]) }}">{{ $page }}</a>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@if ($paginator->hasMorePages())
|
||||
<a href="{{ $paginator->nextPageUrl() }}" rel="next" class="{{ $live }}" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" class="size-6 rtl:-scale-x-100" />
|
||||
<a href="{{ $paginator->nextPageUrl() }}" rel="next" data-md-pagination-step class="md-state-layer md-focus-ring md-touch-target" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" mirror-rtl />
|
||||
</a>
|
||||
@else
|
||||
<span class="{{ $dead }}" aria-disabled="true" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" class="size-6 rtl:-scale-x-100" />
|
||||
<span data-md-pagination-step aria-disabled="true" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" mirror-rtl />
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<div>
|
||||
@if ($paginator->hasPages())
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-pagination class="flex items-center justify-between gap-4">
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-md-pagination>
|
||||
@if ($paginator->onFirstPage())
|
||||
<x-livewire-material::button variant="outlined" icon="chevron_left" :label="__('Previous')" disabled />
|
||||
@elseif ($cursor)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{{-- Livewire's paginator, drawn in M3. The package puts this in front of Livewire's own
|
||||
`livewire::tailwind` (config `livewire-material.pagination`), whose gray and blue classes do
|
||||
not exist in an M3 theme.
|
||||
not exist in an M3 theme. The file keeps Livewire's view name; nothing in it is Tailwind — the
|
||||
drawing is resources/css/components/pagination.css.
|
||||
|
||||
The wiring is Livewire's, unchanged: `previousPage`, `nextPage` and `gotoPage` with the page
|
||||
name, and the scroll back to the top of whatever `scrollTo` names. A page number is drawn as a
|
||||
40px state layer and catches presses over M3's 48px target (`touch-target`); the current one is
|
||||
the selected state, secondary-container, never the action colour — it is where you are, not
|
||||
what to do next. On a phone the numbers give way to "Page 2 of 7". --}}
|
||||
40px state layer and catches presses over M3's 48px target (`md-touch-target`); the current one
|
||||
is the selected state, secondary-container, never the action colour — it is where you are, not
|
||||
what to do next. Below `medium` (600px) the numbers give way to "Page 2 of 7". --}}
|
||||
|
||||
@php
|
||||
if (! isset($scrollTo)) {
|
||||
@@ -18,43 +19,39 @@
|
||||
(\$el.closest('{$scrollTo}') || document.querySelector('{$scrollTo}')).scrollIntoView()
|
||||
JS
|
||||
: '';
|
||||
|
||||
$step = 'grid size-10 place-items-center rounded-corner-full type-label-lg tabular-nums';
|
||||
$live = $step.' state-layer focus-ring touch-target cursor-pointer text-on-surface';
|
||||
$dead = $step.' text-on-surface/38';
|
||||
@endphp
|
||||
|
||||
<div>
|
||||
@if ($paginator->hasPages())
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-pagination class="flex items-center justify-between gap-4">
|
||||
<p class="type-body-sm text-on-surface-variant">
|
||||
<span class="medium:hidden">{{ __('Page :page of :pages', ['page' => $paginator->currentPage(), 'pages' => $paginator->lastPage()]) }}</span>
|
||||
<span class="max-medium:hidden">{{ __(':first–:last of :total', ['first' => $paginator->firstItem(), 'last' => $paginator->lastItem(), 'total' => $paginator->total()]) }}</span>
|
||||
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" data-md-pagination>
|
||||
<p data-md-pagination-summary>
|
||||
<span data-md-pagination-compact>{{ __('Page :page of :pages', ['page' => $paginator->currentPage(), 'pages' => $paginator->lastPage()]) }}</span>
|
||||
<span data-md-pagination-range>{{ __(':first–:last of :total', ['first' => $paginator->firstItem(), 'last' => $paginator->lastItem(), 'total' => $paginator->total()]) }}</span>
|
||||
</p>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<div data-md-pagination-steps>
|
||||
@if ($paginator->onFirstPage())
|
||||
<span class="{{ $dead }}" aria-disabled="true" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" class="size-6 rtl:-scale-x-100" />
|
||||
<span data-md-pagination-step aria-disabled="true" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" mirror-rtl />
|
||||
</span>
|
||||
@else
|
||||
<button type="button" wire:click="previousPage('{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="previousPage{{ $paginator->getPageName() == 'page' ? '' : '.'.$paginator->getPageName() }}" class="{{ $live }}" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" class="size-6 rtl:-scale-x-100" />
|
||||
<button type="button" wire:click="previousPage('{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="previousPage{{ $paginator->getPageName() == 'page' ? '' : '.'.$paginator->getPageName() }}" data-md-pagination-step class="md-state-layer md-focus-ring md-touch-target" aria-label="{{ __('Previous') }}">
|
||||
<x-livewire-material::icon name="chevron_left" mirror-rtl />
|
||||
</button>
|
||||
@endif
|
||||
|
||||
@foreach ($elements as $element)
|
||||
@if (is_string($element))
|
||||
<span class="{{ $dead }} max-medium:hidden" aria-disabled="true">{{ $element }}</span>
|
||||
<span data-md-pagination-step data-md-pagination-page aria-disabled="true">{{ $element }}</span>
|
||||
@endif
|
||||
|
||||
@if (is_array($element))
|
||||
@foreach ($element as $page => $url)
|
||||
<span wire:key="paginator-{{ $paginator->getPageName() }}-page{{ $page }}" class="max-medium:hidden">
|
||||
<span wire:key="paginator-{{ $paginator->getPageName() }}-page{{ $page }}" data-md-pagination-page>
|
||||
@if ($page == $paginator->currentPage())
|
||||
<span aria-current="page" class="{{ $step }} bg-secondary-container text-on-secondary-container">{{ $page }}</span>
|
||||
<span aria-current="page" data-md-pagination-step>{{ $page }}</span>
|
||||
@else
|
||||
<button type="button" wire:click="gotoPage({{ $page }}, '{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" class="{{ $live }}" aria-label="{{ __('Go to page :page', ['page' => $page]) }}">{{ $page }}</button>
|
||||
<button type="button" wire:click="gotoPage({{ $page }}, '{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" data-md-pagination-step class="md-state-layer md-focus-ring md-touch-target" aria-label="{{ __('Go to page :page', ['page' => $page]) }}">{{ $page }}</button>
|
||||
@endif
|
||||
</span>
|
||||
@endforeach
|
||||
@@ -62,12 +59,12 @@
|
||||
@endforeach
|
||||
|
||||
@if ($paginator->hasMorePages())
|
||||
<button type="button" wire:click="nextPage('{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="nextPage{{ $paginator->getPageName() == 'page' ? '' : '.'.$paginator->getPageName() }}" class="{{ $live }}" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" class="size-6 rtl:-scale-x-100" />
|
||||
<button type="button" wire:click="nextPage('{{ $paginator->getPageName() }}')" x-on:click="{{ $scrollIntoViewJsSnippet }}" wire:loading.attr="disabled" dusk="nextPage{{ $paginator->getPageName() == 'page' ? '' : '.'.$paginator->getPageName() }}" data-md-pagination-step class="md-state-layer md-focus-ring md-touch-target" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" mirror-rtl />
|
||||
</button>
|
||||
@else
|
||||
<span class="{{ $dead }}" aria-disabled="true" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" class="size-6 rtl:-scale-x-100" />
|
||||
<span data-md-pagination-step aria-disabled="true" aria-label="{{ __('Next') }}">
|
||||
<x-livewire-material::icon name="chevron_right" mirror-rtl />
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user