Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query pagination with InnerBlocks #28125

Merged
merged 5 commits into from
Jan 20, 2021
Merged

Conversation

ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Jan 12, 2021

Description

Resolves: #26557 - other follow ups for improvements will come.

In this PR Query Pagination block is implemented with InnerBlocks and can support multi query pagination in the same page. The only allowed blocks inside it are three new blocks:

  1. QueryPaginationNext- Displays a next posts link
  2. QueryPaginationPrevious - Displays a previous posts link
  3. QueryPaginationNumbers - Displays numbered pagination

In QueryPaginationNext and QueryPaginationPrevious you can edit the labels and/or background/link color. I haven't added many options yet, as this PR is big as is and beautiful things can be achieved for now with just a couple of lines of css, like adding some padding to these blocks or changing the justify-content css property in QueryPagination block.

Testing Instructions

  1. With a FSE theme go to (or create) an archive template and add Query blocks
  2. You could also add more custom Query blocks and in each of them you should add a QueryPagination block (or more if you like, ex on top and bottom)
  3. If you want to test custom Queries, don't forget to toggle the Inherit query from URL option, that is by default true
  4. Then visit an archive page (ex a category's page) and click pagination links.
  5. Observe that multi query pagination is correct and that it respects the max pages param of the Query block

Alternative Testing in pages - doesn't include the Queries that inherit from global context.

  1. Insert Query and QueryPagination blocks (don't forget to toggle the Inherit query from URL option)
  2. Test multi query pagination with custom queries only.

Notes

  1. See breaking change below.
  2. I have created a new file for Query utils in lib and I'm not sure if this is how the file should be named or in that place. The problem is that I needed a function that constructs a WP_Query args object from a Query block properties. This is needed and used by QueryLoop, QueryPaginationNumbers and QueryPaginationNext blocks in order to work properly.
  3. There is no live preview in the editor, as there are context detection problems yet and to be honest I'm not sure it solves more problems if there was. For example you I think it's more important to place/style the links (like the Previous posts) even if you are previewing the first page of your query..

Screenshots

Screenshot 2021-01-12 at 10 25 34 AM

queryPagination

Types of changes

This PR breaks previous QueryPagination, but I haven't created a deprecation as it wasn't working properly before and I don't think it was used, besides the experimental nature of it.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@github-actions
Copy link

github-actions bot commented Jan 12, 2021

Size Change: +1.4 kB (0%)

Total Size: 1.29 MB

Filename Size Change
build/block-library/editor-rtl.css 9.2 kB +137 B (+2%)
build/block-library/editor.css 9.18 kB +123 B (+1%)
build/block-library/index.js 143 kB +1 kB (+1%)
build/block-library/style-rtl.css 8.65 kB +67 B (+1%)
build/block-library/style.css 8.66 kB +70 B (+1%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.8 kB 0 B
build/api-fetch/index.js 3.42 kB 0 B
build/autop/index.js 2.84 kB 0 B
build/blob/index.js 665 B 0 B
build/block-directory/index.js 9.08 kB 0 B
build/block-directory/style-rtl.css 1.01 kB 0 B
build/block-directory/style.css 1.01 kB 0 B
build/block-editor/index.js 122 kB 0 B
build/block-editor/style-rtl.css 11.9 kB 0 B
build/block-editor/style.css 11.9 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 196 B 0 B
build/block-library/blocks/archives/editor.css 196 B 0 B
build/block-library/blocks/audio/editor-rtl.css 194 B 0 B
build/block-library/blocks/audio/editor.css 194 B 0 B
build/block-library/blocks/audio/style-rtl.css 225 B 0 B
build/block-library/blocks/audio/style.css 225 B 0 B
build/block-library/blocks/block/editor-rtl.css 283 B 0 B
build/block-library/blocks/block/editor.css 283 B 0 B
build/block-library/blocks/button/editor-rtl.css 576 B 0 B
build/block-library/blocks/button/editor.css 577 B 0 B
build/block-library/blocks/button/style-rtl.css 552 B 0 B
build/block-library/blocks/button/style.css 552 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 345 B 0 B
build/block-library/blocks/buttons/editor.css 346 B 0 B
build/block-library/blocks/buttons/style-rtl.css 419 B 0 B
build/block-library/blocks/buttons/style.css 419 B 0 B
build/block-library/blocks/calendar/style-rtl.css 319 B 0 B
build/block-library/blocks/calendar/style.css 319 B 0 B
build/block-library/blocks/categories/editor-rtl.css 210 B 0 B
build/block-library/blocks/categories/editor.css 209 B 0 B
build/block-library/blocks/categories/style-rtl.css 208 B 0 B
build/block-library/blocks/categories/style.css 208 B 0 B
build/block-library/blocks/code/style-rtl.css 216 B 0 B
build/block-library/blocks/code/style.css 216 B 0 B
build/block-library/blocks/columns/editor-rtl.css 300 B 0 B
build/block-library/blocks/columns/editor.css 299 B 0 B
build/block-library/blocks/columns/style-rtl.css 529 B 0 B
build/block-library/blocks/columns/style.css 528 B 0 B
build/block-library/blocks/cover/editor-rtl.css 524 B 0 B
build/block-library/blocks/cover/editor.css 522 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.3 kB 0 B
build/block-library/blocks/cover/style.css 1.3 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 594 B 0 B
build/block-library/blocks/embed/editor.css 595 B 0 B
build/block-library/blocks/embed/style-rtl.css 489 B 0 B
build/block-library/blocks/embed/style.css 489 B 0 B
build/block-library/blocks/file/editor-rtl.css 314 B 0 B
build/block-library/blocks/file/editor.css 313 B 0 B
build/block-library/blocks/file/style-rtl.css 352 B 0 B
build/block-library/blocks/file/style.css 352 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.55 kB 0 B
build/block-library/blocks/freeform/editor.css 2.55 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 783 B 0 B
build/block-library/blocks/gallery/editor.css 783 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.17 kB 0 B
build/block-library/blocks/gallery/style.css 1.17 kB 0 B
build/block-library/blocks/group/editor-rtl.css 433 B 0 B
build/block-library/blocks/group/editor.css 432 B 0 B
build/block-library/blocks/group/style-rtl.css 190 B 0 B
build/block-library/blocks/group/style.css 190 B 0 B
build/block-library/blocks/heading/editor-rtl.css 248 B 0 B
build/block-library/blocks/heading/editor.css 248 B 0 B
build/block-library/blocks/heading/style-rtl.css 212 B 0 B
build/block-library/blocks/heading/style.css 212 B 0 B
build/block-library/blocks/html/editor-rtl.css 384 B 0 B
build/block-library/blocks/html/editor.css 385 B 0 B
build/block-library/blocks/image/editor-rtl.css 801 B 0 B
build/block-library/blocks/image/editor.css 800 B 0 B
build/block-library/blocks/image/style-rtl.css 569 B 0 B
build/block-library/blocks/image/style.css 570 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 277 B 0 B
build/block-library/blocks/latest-comments/editor.css 275 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 382 B 0 B
build/block-library/blocks/latest-comments/style.css 382 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 254 B 0 B
build/block-library/blocks/latest-posts/editor.css 254 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 634 B 0 B
build/block-library/blocks/latest-posts/style.css 634 B 0 B
build/block-library/blocks/list/editor-rtl.css 203 B 0 B
build/block-library/blocks/list/editor.css 203 B 0 B
build/block-library/blocks/list/style-rtl.css 201 B 0 B
build/block-library/blocks/list/style.css 201 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 311 B 0 B
build/block-library/blocks/media-text/editor.css 311 B 0 B
build/block-library/blocks/media-text/style-rtl.css 642 B 0 B
build/block-library/blocks/media-text/style.css 640 B 0 B
build/block-library/blocks/more/editor-rtl.css 545 B 0 B
build/block-library/blocks/more/editor.css 545 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 503 B 0 B
build/block-library/blocks/navigation-link/editor.css 504 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 805 B 0 B
build/block-library/blocks/navigation-link/style.css 803 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.49 kB 0 B
build/block-library/blocks/navigation/editor.css 1.48 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 289 B 0 B
build/block-library/blocks/navigation/style.css 289 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 507 B 0 B
build/block-library/blocks/nextpage/editor.css 507 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 236 B 0 B
build/block-library/blocks/paragraph/editor.css 236 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 392 B 0 B
build/block-library/blocks/paragraph/style.css 392 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 329 B 0 B
build/block-library/blocks/post-author/editor.css 329 B 0 B
build/block-library/blocks/post-author/style-rtl.css 303 B 0 B
build/block-library/blocks/post-author/style.css 303 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 358 B 0 B
build/block-library/blocks/post-comments-form/style.css 358 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 262 B 0 B
build/block-library/blocks/post-content/editor.css 262 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 206 B 0 B
build/block-library/blocks/post-excerpt/editor.css 206 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 453 B 0 B
build/block-library/blocks/post-featured-image/editor.css 453 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 223 B 0 B
build/block-library/blocks/post-featured-image/style.css 223 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 193 B 0 B
build/block-library/blocks/preformatted/style.css 193 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 304 B 0 B
build/block-library/blocks/pullquote/editor.css 304 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 428 B 0 B
build/block-library/blocks/pullquote/style.css 428 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 217 B 0 B
build/block-library/blocks/query-loop/editor.css 216 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 427 B 0 B
build/block-library/blocks/query-loop/style.css 429 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 243 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 240 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 390 B 0 B
build/block-library/blocks/query-pagination/editor.css 379 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B 0 B
build/block-library/blocks/query-pagination/style.css 288 B 0 B
build/block-library/blocks/query/editor-rtl.css 279 B 0 B
build/block-library/blocks/query/editor.css 279 B 0 B
build/block-library/blocks/quote/editor-rtl.css 195 B 0 B
build/block-library/blocks/quote/editor.css 195 B 0 B
build/block-library/blocks/quote/style-rtl.css 284 B 0 B
build/block-library/blocks/quote/style.css 285 B 0 B
build/block-library/blocks/rss/editor-rtl.css 307 B 0 B
build/block-library/blocks/rss/editor.css 309 B 0 B
build/block-library/blocks/rss/style-rtl.css 394 B 0 B
build/block-library/blocks/rss/style.css 393 B 0 B
build/block-library/blocks/search/editor-rtl.css 285 B 0 B
build/block-library/blocks/search/editor.css 285 B 0 B
build/block-library/blocks/search/style-rtl.css 454 B 0 B
build/block-library/blocks/search/style.css 456 B 0 B
build/block-library/blocks/separator/editor-rtl.css 229 B 0 B
build/block-library/blocks/separator/editor.css 229 B 0 B
build/block-library/blocks/separator/style-rtl.css 352 B 0 B
build/block-library/blocks/separator/style.css 352 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 603 B 0 B
build/block-library/blocks/shortcode/editor.css 603 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 321 B 0 B
build/block-library/blocks/site-logo/editor.css 321 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 238 B 0 B
build/block-library/blocks/site-logo/style.css 238 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 283 B 0 B
build/block-library/blocks/social-link/editor.css 283 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 811 B 0 B
build/block-library/blocks/social-links/editor.css 810 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.48 kB 0 B
build/block-library/blocks/social-links/style.css 1.48 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 416 B 0 B
build/block-library/blocks/spacer/editor.css 416 B 0 B
build/block-library/blocks/spacer/style-rtl.css 184 B 0 B
build/block-library/blocks/spacer/style.css 184 B 0 B
build/block-library/blocks/subhead/editor-rtl.css 223 B 0 B
build/block-library/blocks/subhead/editor.css 223 B 0 B
build/block-library/blocks/subhead/style-rtl.css 210 B 0 B
build/block-library/blocks/subhead/style.css 210 B 0 B
build/block-library/blocks/table/editor-rtl.css 593 B 0 B
build/block-library/blocks/table/editor.css 593 B 0 B
build/block-library/blocks/table/style-rtl.css 501 B 0 B
build/block-library/blocks/table/style.css 501 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 237 B 0 B
build/block-library/blocks/tag-cloud/editor.css 235 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 221 B 0 B
build/block-library/blocks/tag-cloud/style.css 221 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 794 B 0 B
build/block-library/blocks/template-part/editor.css 794 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 220 B 0 B
build/block-library/blocks/text-columns/editor.css 220 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 283 B 0 B
build/block-library/blocks/text-columns/style.css 283 B 0 B
build/block-library/blocks/verse/editor-rtl.css 194 B 0 B
build/block-library/blocks/verse/editor.css 194 B 0 B
build/block-library/blocks/verse/style-rtl.css 215 B 0 B
build/block-library/blocks/verse/style.css 215 B 0 B
build/block-library/blocks/video/editor-rtl.css 617 B 0 B
build/block-library/blocks/video/editor.css 617 B 0 B
build/block-library/blocks/video/style-rtl.css 303 B 0 B
build/block-library/blocks/video/style.css 304 B 0 B
build/block-library/common-rtl.css 1.01 kB 0 B
build/block-library/common.css 1.01 kB 0 B
build/block-library/theme-rtl.css 860 B 0 B
build/block-library/theme.css 860 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/blocks/index.js 48.1 kB 0 B
build/components/index.js 173 kB 0 B
build/components/style-rtl.css 15.5 kB 0 B
build/components/style.css 15.5 kB 0 B
build/compose/index.js 11.3 kB 0 B
build/core-data/index.js 15.2 kB 0 B
build/data-controls/index.js 829 B 0 B
build/data/index.js 8.99 kB 0 B
build/date/index.js 31.8 kB 0 B
build/deprecated/index.js 769 B 0 B
build/dom-ready/index.js 571 B 0 B
build/dom/index.js 4.95 kB 0 B
build/edit-navigation/index.js 11.2 kB 0 B
build/edit-navigation/style-rtl.css 938 B 0 B
build/edit-navigation/style.css 944 B 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.51 kB 0 B
build/edit-post/style.css 6.5 kB 0 B
build/edit-site/index.js 24.2 kB 0 B
build/edit-site/style-rtl.css 4.01 kB 0 B
build/edit-site/style.css 4.01 kB 0 B
build/edit-widgets/index.js 23.6 kB 0 B
build/edit-widgets/style-rtl.css 3.17 kB 0 B
build/edit-widgets/style.css 3.17 kB 0 B
build/editor/editor-styles-rtl.css 543 B 0 B
build/editor/editor-styles.css 545 B 0 B
build/editor/index.js 41.9 kB 0 B
build/editor/style-rtl.css 3.89 kB 0 B
build/editor/style.css 3.89 kB 0 B
build/element/index.js 4.62 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/index.js 6.76 kB 0 B
build/format-library/style-rtl.css 620 B 0 B
build/format-library/style.css 621 B 0 B
build/hooks/index.js 2.27 kB 0 B
build/html-entities/index.js 623 B 0 B
build/i18n/index.js 3.57 kB 0 B
build/is-shallow-equal/index.js 697 B 0 B
build/keyboard-shortcuts/index.js 2.54 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.15 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/media-utils/index.js 5.32 kB 0 B
build/notices/index.js 1.85 kB 0 B
build/nux/index.js 3.42 kB 0 B
build/nux/style-rtl.css 731 B 0 B
build/nux/style.css 727 B 0 B
build/plugins/index.js 2.54 kB 0 B
build/primitives/index.js 1.43 kB 0 B
build/priority-queue/index.js 790 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/reusable-blocks/index.js 2.92 kB 0 B
build/rich-text/index.js 13.5 kB 0 B
build/server-side-render/index.js 2.77 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 3.02 kB 0 B
build/viewport/index.js 1.86 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@jasmussen
Copy link
Contributor

Here are some icons. Pagination:

Screenshot 2021-01-12 at 10 17 57

<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="10.5" width="6" height="3" rx="1.5" fill="#000"/><rect x="12" y="10.5" width="3" height="3" rx="1.5" fill="#000"/><rect x="17" y="10.5" width="3" height="3" rx="1.5" fill="#000"/></svg>

Numbers:

Screenshot 2021-01-12 at 10 22 53

<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="10.5" width="6" height="3" rx="1.5" fill="#000"/><path d="M13.5 14v-4l-1.5.5" stroke="#1E1E1E"/><path d="M19.266 9.805c-.473-.611-1.22-.51-1.702-.367a3.854 3.854 0 00-.718.307l.13 1.082c.192-.17.47-.422.782-.515.34-.1.578.025.668.141.21.27-.034.835-.16 1.055-.49.85-.93 1.594-1.45 2.492H19.5v-1h-.914c.277-.574.814-1.443.914-2.106.052-.343.02-.762-.234-1.09z" fill="#1E1E1E"/></svg>

Next:

Screenshot 2021-01-12 at 10 28 10

<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="6" y="10.5" width="3" height="3" rx="1.5" fill="#000"/><rect x="11" y="10.5" width="3" height="3" rx="1.5" fill="#000"/><path d="M16.5 9.5L19 12l-2.5 2.5" stroke="#1E1E1E" stroke-width="1.5"/></svg>

Previous:

Screenshot 2021-01-12 at 10 28 56

<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="18" y="13.5" width="3" height="3" rx="1.5" transform="rotate(-180 18 13.5)" fill="#000"/><rect x="13" y="13.5" width="3" height="3" rx="1.5" transform="rotate(-180 13 13.5)" fill="#000"/><path d="M7.5 14.5L5 12l2.5-2.5" stroke="#1E1E1E" stroke-width="1.5"/></svg>

@gziolo
Copy link
Member

gziolo commented Jan 12, 2021

Nice one, quite a good idea to use inner blocks for pagination items. Have you considered using one child block like Query Pagination Item and make everything else a block variation?

@ntsekouras
Copy link
Contributor Author

Thanks for the icons @jasmussen! I really appreciate it!

Have you considered using one child block like Query Pagination Item and make everything else a block variation?

@gziolo I think it will get quite messy quickly, as there are different implementations for each of these child blocks and will get messier when/and if we handle preview pagination.

@MaggieCabrera
Copy link
Contributor

This is really nice!

It worked fine for me on an archive page within the FSE, but I tried to make it work on a query block inside a page (in the page editor, outside FSE) and it showed up on the editor but not on the frontend. It would be nice to have it work outside FSE too.

Is it possible to have alignment rules for this block? I see how we would want to align this left/right/center and also justify the 3 elements too (such as with space-between or space-around)

@ntsekouras
Copy link
Contributor Author

Thanks for testing @MaggieCabrera !

but I tried to make it work on a query block inside a page (in the page editor, outside FSE)

It does work outside FSE. Did you forget to set the Query option not to inherit from global context? Check in my gif in the PR's description, after inserting the Query block.

I have another PR that changes the default value when outside of FSE, but is still not merged (#27972).

Is it possible to have alignment rules for this block? I see how we would want to align this left/right/center and also justify the 3 elements too (such as with space-between or space-around)

That's definitely in my mind but in a follow up, because this PR is quite big as is.

@ntsekouras ntsekouras added the New Block Suggestion for a new block label Jan 12, 2021
@MaggieCabrera
Copy link
Contributor

It does work outside FSE. Did you forget to set the Query option not to inherit from global context? Check in my gif in the PR's description, after inserting the Query block.

Oh yes, I missed that! It works perfectly then

I have another PR that changes the default value when outside of FSE, but is still not merged (#27972).

That's great, makes it less confusing for the users

That's definitely in my mind but in a follow up, because this PR is quite big as is.

Fantastic. As far as I know, space-between is not yet available for any block, but this is a clear example of a case where we would totally want to have the option

@aristath
Copy link
Member

While trying to test this PR I was getting multiple errors, in npm as well as the browser (the browser issues were including #28212 as well as phantom files due to the npm fails). I merged the master branch here just to make it easier to test things since it was almost impossible to properly test & debug otherwise. 👍

Copy link
Member

@aristath aristath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised. This is awesome! Thank you @ntsekouras

@ntsekouras ntsekouras merged commit 1c59a2c into master Jan 20, 2021
@ntsekouras ntsekouras deleted the try/query-pagination-blocks branch January 20, 2021 09:10
@github-actions github-actions bot added this to the Gutenberg 9.9 milestone Jan 20, 2021
const placeholder = __( 'Next Page' );
return (
<>
<div { ...useBlockProps() }>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this div also output in the frontend? if not, we should remove it and use the RichText as the wrapper (see Paragraph for instance)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Maybe it's not possible because "a" is inline by default though). @ellatrix do you know?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this div also output in the frontend?

It's not. I'm not sure about this though:

Maybe it's not possible because "a" is inline by default though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible, we just need to update the display property to inline-block for example.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thanks for working on this :) Maybe we need a bit more tests around these blocks.

@ntsekouras
Copy link
Contributor Author

Maybe we need a bit more tests around these blocks.

Yes, as these blocks mature more and more, tests are essential. I have this in mind.

@jasmussen
Copy link
Contributor

Not sure if it's related, but should next/previous posts be available in the block editor or only in the site editor?

Screenshot 2021-02-05 at 09 54 49

@ntsekouras
Copy link
Contributor Author

@jasmussen these two blocks shown at the screenshot are the next/previous post link of single posts/pages etc...

The one you're referring to are only available under Query Pagination block, which can only live under a Query block. Having said that, a Query block can be inserted in a page with blocks-theme.

The different wording is really subtle though: Next post - Next page link

@mtias
Copy link
Member

mtias commented Feb 5, 2021

It might be good to change the name of "Next page link" to "Next archive".

@ntsekouras
Copy link
Contributor Author

The different wording is really subtle though: Next post - Next page link

Sorry - Next page link is just the aria-label of the input in editor. The actual block names for Query Pagination are:

  1. Query Pagination Next
  2. Query Pagination Previous

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block New Block Suggestion for a new block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pagination block
8 participants