-
Notifications
You must be signed in to change notification settings - Fork 44
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 #280 from 10up/feature/content-search-with-searchc…
…ontrol-component Replace `TextControl` with `SearchControl` in `ContentSearch` Component
- Loading branch information
Showing
10 changed files
with
95 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"apiVersion": 2, | ||
"name": "example/content-picker", | ||
"title": "Content Picker", | ||
"description": "Example Block to show the Content Picker in usage", | ||
"icon": "excerpt-view", | ||
"category": "common", | ||
"example": {}, | ||
"supports": { | ||
"html": false | ||
}, | ||
"attributes": { | ||
"selectedPosts": { | ||
"type": "array" | ||
} | ||
}, | ||
"variations": [], | ||
"editorScript": "file:./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,49 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; | ||
import { PanelBody, Placeholder } from '@wordpress/components'; | ||
|
||
import { ContentPicker } from '@10up/block-components'; | ||
|
||
export const BlockEdit = (props) => { | ||
const { | ||
attributes: {selectedPosts}, | ||
setAttributes | ||
} = props; | ||
|
||
function handlePostSelection(posts) { | ||
setAttributes({ selectedPosts: posts }) | ||
} | ||
|
||
const blockProps = useBlockProps(); | ||
|
||
return ( | ||
<> | ||
<InspectorControls> | ||
<PanelBody title={__('Content Picker', 'example')}> | ||
<ContentPicker | ||
label={__('Select a Post or Page', 'example')} | ||
contentTypes={['page', 'post']} | ||
onPickChange={handlePostSelection} | ||
fetchInitialResults | ||
value={selectedPosts} | ||
content={selectedPosts} | ||
maxContentItems={5} | ||
/> | ||
</PanelBody> | ||
</InspectorControls> | ||
<div {...blockProps}> | ||
<Placeholder label={__('Content Picker', 'example')} instructions={__('Use the text field to search for a post', 'example')}> | ||
<ContentPicker | ||
label={__('Select a Post or Page', 'example')} | ||
contentTypes={['page', 'post']} | ||
onPickChange={handlePostSelection} | ||
fetchInitialResults | ||
value={selectedPosts} | ||
content={selectedPosts} | ||
maxContentItems={5} | ||
/> | ||
</Placeholder> | ||
</div> | ||
</> | ||
) | ||
} |
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,8 @@ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
import metadata from './block.json'; | ||
import { BlockEdit } from './edit'; | ||
|
||
registerBlockType( metadata, { | ||
edit: BlockEdit, | ||
save: () => null | ||
} ); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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