-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from humanmade/post-picker-modifications-2
Post picker: Design updates, manage current selection, re-order selection.
- Loading branch information
Showing
4 changed files
with
353 additions
and
96 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,81 @@ | ||
# PostPicker | ||
|
||
The `PostPicker` control allows a user to select one or more posts from a given post type, which can be filtered by a taxonomy. | ||
There are several `PostPicker` controls. | ||
|
||
TODO: Implement multiple taxonomy filters. | ||
* `PostPickerButton` A simple button. | ||
* `PostPickerToolbarButton` A button for use within `BlockControls` toolbar. | ||
* `PostPickerModal` The actual modal interface, that can be integrated into your own UI. | ||
|
||
## Props | ||
## `PostPickerButton` | ||
|
||
- title | ||
- postType | ||
- taxonomies | ||
- values | ||
- onChange | ||
``` | ||
import { PostPickerButton } from '@humanmade/block-editor-components'; | ||
... | ||
<PostPickerButton | ||
taxonomies={ [ 'category', 'post_tag' ] } | ||
onChange={ newValue => setAttributes( { postIds: newValue } ) } | ||
values={ attributes.postIds || [] } | ||
/> | ||
``` | ||
|
||
### Props | ||
|
||
The `LinkToolbar` component does not have any custom props other than `opensInNewTab`, `value` and `onChange`, which are all passed on as is to the nested [`LinkControl`](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/link-control/index.js) component. | ||
|
||
#### `values` | ||
|
||
The saved values. Array of post IDs. | ||
|
||
| Type | Required | Default | | ||
|--------------------------------------|--------------------------------------|--------------------------------------| | ||
| `Array` | yes | `undefined` | | ||
|
||
|
||
#### `onChange` | ||
|
||
The callback to use for handling changing the selected posts. `onChange` will receive an array of post IDs. | ||
|
||
| Type | Required | Default | | ||
|--------------------------------------|--------------------------------------|--------------------------------------| | ||
| `Function` | yes | `undefined` | | ||
|
||
#### `title` | ||
|
||
The title, used by button and modal title. | ||
|
||
| Type | Required | Default | | ||
|--------------------------------------|--------------------------------------|--------------------------------------| | ||
| `String` | no | `Select Posts` | ||
|
||
#### `postType` | ||
|
||
Post type to select from. | ||
|
||
| Type | Required | Default | | ||
|--------------------------------------|--------------------------------------|--------------------------------------| | ||
| `String` | no | `post` | ||
|
||
#### `taxonomies` | ||
|
||
Taxonomies that results can be filtered by. Array of taxonomy slugs. e.g. `[ 'category', 'post_tag' ]`. | ||
|
||
| Type | Required | Default | | ||
|--------------------------------------|--------------------------------------|--------------------------------------| | ||
| `Array` | no | `[]` | ||
|
||
|
||
## Post Picker Toolbar Button | ||
|
||
There is also a `PostPickerToolbarButton` component available if you import it directly from the source file, which is intended for use within the BlockControls. It supports all the same props as the PostPicker component, with the addition of an `icon`. | ||
|
||
## props | ||
|
||
#### `icon` | ||
|
||
Button icon. Passed through to `ToolbarButton`, refer to the documentation of that component for more info. | ||
|
||
| Type | Required | Default | | ||
|--------------------------------------|--------------------------------------|--------------------------------------| | ||
| `string` | no | `edit` |
Oops, something went wrong.