-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Patterns: merge unsynced into inserter patterns tab and add paging and filtering #54007
Changes from 16 commits
fc921a7
8ca644b
9be8084
a098a7b
fda3f16
59a2e0c
f99c31d
516341c
d4705b7
39f33b2
4aa0623
81165ec
476ef8f
ce2aae9
f64f043
a8c0785
684e57e
2ad6587
a9c4ae7
f60beb8
71271f3
c62b4fd
de814a6
48dcd35
bb6cec5
cec2b9a
96b9459
26f486b
e2292a1
2f53ea2
bf74886
b8eadf5
2153343
1b4f30a
39e5f82
48c36e5
351204d
fc40fe7
5199163
6fbc699
4487351
616066d
f845d66
720d3cb
0ee4b81
8839f7a
5951dad
3a920f9
546026f
389285f
5fd5edc
2cb5cfc
f69a88f
57d54db
275e01e
f1f4edc
a37cdd3
da77818
8b94003
8458d29
c293dc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalVStack as VStack, | ||
__experimentalHStack as HStack, | ||
__experimentalText as Text, | ||
Button, | ||
} from '@wordpress/components'; | ||
import { __, _x, _n, sprintf } from '@wordpress/i18n'; | ||
|
||
export default function Pagination( { | ||
currentPage, | ||
numPages, | ||
changePage, | ||
totalItems, | ||
} ) { | ||
return ( | ||
<VStack> | ||
<Text variant="muted"> | ||
{ | ||
// translators: %s: Total number of patterns. | ||
sprintf( | ||
// translators: %s: Total number of patterns. | ||
_n( '%s item', '%s items', totalItems ), | ||
totalItems | ||
) | ||
} | ||
</Text> | ||
<HStack | ||
expanded={ false } | ||
spacing={ 3 } | ||
justify="flex-start" | ||
className="block-editor-patterns__grid-pagination" | ||
> | ||
<HStack expanded={ false } spacing={ 1 }> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( 1 ) } | ||
disabled={ currentPage === 1 } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder where we should move the focus after navigating to a different page. Should we retain the focus on the prev/next button? Or should we move the focus to the first pattern to match the visual jump? If we decide to retain the focus then we probably want to change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be good to look at this as a follow-up combined with the site editor pagination - ideally we should finalise the |
||
aria-label={ __( 'First page' ) } | ||
> | ||
« | ||
</Button> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( currentPage - 1 ) } | ||
disabled={ currentPage === 1 } | ||
aria-label={ __( 'Previous page' ) } | ||
> | ||
‹ | ||
</Button> | ||
</HStack> | ||
<Text variant="muted"> | ||
{ sprintf( | ||
// translators: %1$s: Current page number, %2$s: Total number of pages. | ||
_x( '%1$s of %2$s', 'paging' ), | ||
currentPage, | ||
numPages | ||
) } | ||
</Text> | ||
<HStack expanded={ false } spacing={ 1 }> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( currentPage + 1 ) } | ||
disabled={ currentPage === numPages } | ||
aria-label={ __( 'Next page' ) } | ||
> | ||
› | ||
</Button> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( numPages ) } | ||
disabled={ currentPage === numPages } | ||
aria-label={ __( 'Last page' ) } | ||
> | ||
» | ||
</Button> | ||
</HStack> | ||
</HStack> | ||
</VStack> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.block-editor-patterns__grid-pagination { | ||
border-top: 1px solid $gray-800; | ||
padding: $grid-unit-05; | ||
|
||
.components-button.is-tertiary { | ||
width: $button-size-compact; | ||
height: $button-size-compact; | ||
justify-content: center; | ||
|
||
&:disabled { | ||
color: $gray-600; | ||
background: none; | ||
} | ||
|
||
&:hover:not(:disabled) { | ||
background-color: $gray-700; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This icon is not tabbable and thus won't announce this text for screen readers. Maybe we should merge this into the description above? (And yep probably it's also an issue in the patterns page in the site editor? 😅 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be more annoying than useful to hit that for every pattern, especially if tabbing through a filtered list of just synced patterns? Do you think we could look at this as a follow up and cover site editor and post inserter together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I meant as a follow-up to look into in the future!