Add new UX Pagination component - #3753
Conversation
📊 Packages dist files size differenceThanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
|
|||||||||
There was a problem hiding this comment.
Sshipping default styles is indeed super useful, but I'm a little worried about what will happen when users want to make more significant changes to styles. What if users use CSS layers, etc..
This is also a subject of BC.
I'm not sure if we should ship default styles like that or not, what about moving it in a dedicated Flex recipe?
There was a problem hiding this comment.
Having one is like having a default theme, it allows to work out of the box, but this is clearly documented to be something user would need/want to override or probably even rewrite themselves...
Here it's really about "plug and play and basic working behaviour".
Problem with a recipe is also it cannot differenciate "first install" and update, so it would bring the same problems (if not worst, as we cannot control we does or does not its recipe:updates out there)...
Maybe though this is something we can solve later on, providing URL / commands to get theme from ux toolkit or something ?
| .. code-block:: text | ||
| Does the UI need page numbers or an exact total? | ||
| | | ||
| + -> yes -> offset | ||
| | | ||
| + -> no -> Can rows be inserted or removed while users browse? | ||
| | | ||
| + -> yes -> cursor | ||
| | | ||
| + -> no -> lookahead | ||
There was a problem hiding this comment.
Does symfony.com documentation supports diagram? Like mermaid syntax?
There was a problem hiding this comment.
You really should watch the repository I suggested you to watch 😆
| "ux-leaflet-map": "src/Map/src/Bridge/Leaflet", | ||
| "ux-native": "src/Native", | ||
| "ux-notify": "src/Notify", | ||
| "ux-pagination": "src/Pagination", |
There was a problem hiding this comment.
Remember to ping Fabien for creating the repo on GitHub/Packagist
|
In the three templates under Example: {% set linkClass = 'px-3 py-2 text-sm font-medium rounded-lg text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 focus:ring-2 focus:ring-blue-500 transition-colors duration-150' %}
{% set userClass = attributes.class|default('') %}
{% set rootAttributes = {
'aria-label': 'Pagination'|trans({}, 'UXPaginationBundle'),
}|merge(attributes)|merge({
class: ('ux-pagination-tailwind ' ~ userClass)|trim,
}) %}
{% set userNavigationClass = navigationAttributes.class|default('') %}
{% set navigationAttributes = navigationAttributes|merge({
class: ('flex flex-wrap items-center justify-center gap-1 sm:gap-2 ' ~ userNavigationClass)|trim,
}) %} |
`jq -r '.peerDependencies | keys[]'` errors out with exit code 5 when the key is absent, and the step runs under `bash -e`. Every published package so far ships a Stimulus controller, so all of them declare at least one peer dependency and the case never showed up. Fall back to an empty object so packages with no peer dependency, such as a CSS-only one, are skipped instead of killing the job.
|
Doctrine 3.7 will be release with a new CursorPaginator |
Yes, but there's currently a blocking issue for the release of cursor-based pagination in Doctrine ORM 3.7. |
Great, and as I see it some of this PR API inspired some changes on Doctrine PR.. and this is why I love Open Source ! 🤝 |
Kocal
left a comment
There was a problem hiding this comment.
LGTM, waiting for your PR on ux.symfony.com :D
|
Thank you very much for the review @Kocal ! |
This PR adds
symfony/ux-pagination, an experimental bundle that providescursor and numbered pagination behind one request-aware
PaginatorInterfaceservice.
PHP owns the query. Twig renders accessible navigation. The browser
follows ordinary links: no JavaScript, no Stimulus, no Turbo required.
{% for event in pagination %} <article>{{ event.name }}</article> {% endfor %} {{ ux_pagination(pagination) }}What is included
PaginatorInterfaceentry point:paginate(),query(),cursor(),and
fromCallbacks(), plus named paginator profiles injectable byargument name,
#[Target], or service id.cursor.
Custom adapters register through one interface and a service tag.
path, query-string policy, fragment, and lazy application-provided totals.
ux_pagination()Twig function and the<twig:ux:pagination>component, with default, Bootstrap, and Tailwind themes, structural
blocks, validated attribute hooks, and accessible markup:
navlandmark,aria-current,relprev/next, translated labels.like core validators: without symfony/translation, the identity
translator renders readable English,
%count%pluralization included.prev/nextlinks.ComponentWithPaginationTrait:one
createPagination()method to implement, real-link fallback, URLsynchronization that follows the configured page parameter (path mapping
included), and link URLs that stay on the page route during re-renders,
never on the internal component endpoint.
Test\PaginatorFactoryfor deterministic application tests, includingsigned-cursor round trips.
Design decisions reviewers may want to check
count($pagination)returns the items on the current page, not thetotal. This matches iteration;
getTotalItems()returns the total. Themethod documents it.
%kernel.secret%, likeLiveComponent. Offset pagination works without any secret: the codec is a
lazy proxy that fails only when signing is needed.
getMetadata(),getLinks()) and URL conveniences live on the concrete classes only.