-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Block Library - Query Loop]: Reorganise inspector controls +
order
…
… selection bug (#37949) * [Block Library - Query Loop]: Reorganise inspector controls * fix typo
- Loading branch information
1 parent
3a4fe34
commit e781ffe
Showing
3 changed files
with
48 additions
and
11 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
41 changes: 41 additions & 0 deletions
41
packages/block-library/src/query/edit/inspector-controls/order-control.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,41 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SelectControl } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
const orderOptions = [ | ||
{ | ||
label: __( 'Newest to oldest' ), | ||
value: 'date/desc', | ||
}, | ||
{ | ||
label: __( 'Oldest to newest' ), | ||
value: 'date/asc', | ||
}, | ||
{ | ||
/* translators: label for ordering posts by title in ascending order */ | ||
label: __( 'A → Z' ), | ||
value: 'title/asc', | ||
}, | ||
{ | ||
/* translators: label for ordering posts by title in descending order */ | ||
label: __( 'Z → A' ), | ||
value: 'title/desc', | ||
}, | ||
]; | ||
function OrderControl( { order, orderBy, onChange } ) { | ||
return ( | ||
<SelectControl | ||
label={ __( 'Order by' ) } | ||
value={ `${ orderBy }/${ order }` } | ||
options={ orderOptions } | ||
onChange={ ( value ) => { | ||
const [ newOrderBy, newOrder ] = value.split( '/' ); | ||
onChange( { order: newOrder, orderBy: newOrderBy } ); | ||
} } | ||
/> | ||
); | ||
} | ||
|
||
export default OrderControl; |