-
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.
very rough addition of filter and paging in order to get designs
- Loading branch information
1 parent
903ee91
commit 076a7a5
Showing
9 changed files
with
185 additions
and
34 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
80 changes: 80 additions & 0 deletions
80
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,80 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__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 ( | ||
<HStack | ||
expanded={ false } | ||
spacing={ 3 } | ||
justify="flex-start" | ||
className="block-editor-patterns__grid-pagination" | ||
> | ||
<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={ 1 }> | ||
<Button | ||
variant="tertiary" | ||
onClick={ () => changePage( 1 ) } | ||
disabled={ currentPage === 1 } | ||
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> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
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,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; | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/block-editor/src/components/block-patterns-sync-filter/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,45 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalToggleGroupControl as ToggleGroupControl, | ||
__experimentalToggleGroupControlOption as ToggleGroupControlOption, | ||
} from '@wordpress/components'; | ||
|
||
import { __ } from '@wordpress/i18n'; | ||
|
||
const SYNC_TYPES = { | ||
full: 'fully', | ||
unsynced: 'unsynced', | ||
}; | ||
const SYNC_FILTERS = { | ||
all: __( 'All' ), | ||
[ SYNC_TYPES.full ]: __( 'Synced' ), | ||
[ SYNC_TYPES.unsynced ]: __( 'Standard' ), | ||
}; | ||
|
||
export default function BlockPatternsSyncFilter( { | ||
setSyncFilter, | ||
syncFilter, | ||
} ) { | ||
return ( | ||
<ToggleGroupControl | ||
className="block-editor-patterns__sync-status-filter" | ||
hideLabelFromVision | ||
label={ __( 'Filter by sync status' ) } | ||
value={ syncFilter } | ||
isBlock | ||
onChange={ ( value ) => setSyncFilter( value ) } | ||
__nextHasNoMarginBottom | ||
> | ||
{ Object.entries( SYNC_FILTERS ).map( ( [ key, optionLabel ] ) => ( | ||
<ToggleGroupControlOption | ||
className="block-editor-patterns__sync-status-filter-option" | ||
key={ key } | ||
value={ key } | ||
label={ optionLabel } | ||
/> | ||
) ) } | ||
</ToggleGroupControl> | ||
); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/block-editor/src/components/block-patterns-sync-filter/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,3 @@ | ||
.block-editor-patterns__sync-status-filter { | ||
margin-bottom: $grid-unit-10; | ||
} |
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
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