-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patterns: Add user pattern categories to post editor inserter pattern…
…s tab (#53933) Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Co-authored-by: James Koster <james@jameskoster.co.uk>
- Loading branch information
1 parent
982c246
commit 6708eda
Showing
30 changed files
with
833 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
packages/block-editor/src/components/block-patterns-paging/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* 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 } | ||
className="block-editor-patterns__grid-pagination-previous" | ||
> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( 1 ) } | ||
disabled={ currentPage === 1 } | ||
aria-label={ __( 'First page' ) } | ||
> | ||
<span>«</span> | ||
</Button> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( currentPage - 1 ) } | ||
disabled={ currentPage === 1 } | ||
aria-label={ __( 'Previous page' ) } | ||
> | ||
<span>‹</span> | ||
</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 } | ||
className="block-editor-patterns__grid-pagination-next" | ||
> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( currentPage + 1 ) } | ||
disabled={ currentPage === numPages } | ||
aria-label={ __( 'Next page' ) } | ||
> | ||
<span>›</span> | ||
</Button> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( numPages ) } | ||
disabled={ currentPage === numPages } | ||
aria-label={ __( 'Last page' ) } | ||
size="default" | ||
> | ||
<span>»</span> | ||
</Button> | ||
</HStack> | ||
</HStack> | ||
</VStack> | ||
); | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/block-editor/src/components/block-patterns-paging/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.block-editor-patterns__grid-pagination { | ||
border-top: 1px solid $gray-800; | ||
padding: $grid-unit-05; | ||
|
||
.components-button.is-tertiary { | ||
width: auto; | ||
height: $button-size-compact; | ||
justify-content: center; | ||
|
||
&:disabled { | ||
color: $gray-600; | ||
background: none; | ||
} | ||
|
||
&:hover:not(:disabled) { | ||
color: $white; | ||
background-color: $gray-700; | ||
} | ||
} | ||
} | ||
|
||
.show-icon-labels { | ||
.block-editor-patterns__grid-pagination { | ||
flex-direction: column; | ||
.block-editor-patterns__grid-pagination-previous, | ||
.block-editor-patterns__grid-pagination-next { | ||
flex-direction: column; | ||
} | ||
.components-button { | ||
width: auto; | ||
// Hide the button icons when labels are set to display... | ||
span { | ||
display: none; | ||
} | ||
// ... and display labels. | ||
// Uses ::before as ::after is already used for active tab styling. | ||
&::before { | ||
content: attr(aria-label); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.