Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabiankaegy/gutenberg-post-picker
A simple Post Picker Component build with the core gutenberg components
https://github.com/fabiankaegy/gutenberg-post-picker
component gutenberg wordpress
Last synced: 24 days ago
JSON representation
A simple Post Picker Component build with the core gutenberg components
- Host: GitHub
- URL: https://github.com/fabiankaegy/gutenberg-post-picker
- Owner: fabiankaegy
- License: gpl-3.0
- Created: 2020-10-31T13:07:24.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-26T13:00:45.000Z (over 3 years ago)
- Last Synced: 2024-10-04T15:34:22.081Z (about 1 month ago)
- Topics: component, gutenberg, wordpress
- Language: JavaScript
- Homepage:
- Size: 291 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PostPicker
A simple Post Picker Component build with the core gutenberg components. This component does not include any build files and does not bundle the WordPress components. Therefore this needs to be used in an environemt where the [`Dependency Extraction Webpack Plugin`](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin) is used and the `import { component } from '@wordpress/package';` is supported.
## Usage
```js
import { PostPicker } from 'gutenberg-post-picker';function MyComponent( props ) {
return (
)
}
```### Props
| Name | Type | Default | Description |
| ---------------- | ---------- | --------------------- | ---------------------------------------------------------------------- |
| `onSelectPost` | `function` | `undefined` | Callback function that gets called with the post object upon selection |
| `label` | `string` | `''` | Renders a label for the Search Field. |
| `placeholder` | `string` | `''` | Renders placeholder text inside the Search Field. |
| `postTypes` | `array` | `[ 'posts', 'pages' ]` | Names of the post types that should get searched |The `postTypes` will get used like this:
```js
wp.apiFetch( {
path: `/wp/v2/${postType}?search=${searchTerm}`
} )
```