forked from WordPress/gutenberg
-
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.
- Loading branch information
Showing
18 changed files
with
88 additions
and
43 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 +1,68 @@ | ||
# PluginSidebar | ||
|
||
This slot allows for adding items into the Gutenberg Toolbar. | ||
Using this slot will add an icon to the bar that, when clicked, will open a sidebar with the content of the items wrapped in the `<PluginSidebar />` component. | ||
This slot allows adding items to the tool bar of either the Post or Site editor screens. | ||
Using this slot will add an icon to the toolbar that, when clicked, opens a panel with containing the items wrapped in the `<PluginSidebar />` component. | ||
|
||
## Example | ||
|
||
```js | ||
import { registerPlugin } from '@wordpress/plugins'; | ||
```jsx | ||
import { __ } from '@wordpress/i18n'; | ||
import { PluginSidebar } from '@wordpress/editor'; | ||
import { image } from '@wordpress/icons'; | ||
import { | ||
PanelBody, | ||
Button, | ||
TextControl, | ||
SelectControl, | ||
} from '@wordpress/components'; | ||
import { registerPlugin } from '@wordpress/plugins'; | ||
import { useState } from '@wordpress/element'; | ||
|
||
const PluginSidebarExample = () => { | ||
const [ text, setText ] = useState( '' ); | ||
const [ select, setSelect ] = useState( 'a' ); | ||
|
||
const PluginSidebarTest = () => ( | ||
<PluginSidebar name="plugin-sidebar-test" title="My Plugin" icon={ image }> | ||
<p>Plugin Sidebar</p> | ||
</PluginSidebar> | ||
); | ||
return ( | ||
<PluginSidebar | ||
name="plugin-sidebar-example" | ||
title={ __( 'My PluginSidebar' ) } | ||
icon={ 'smiley' } | ||
> | ||
<PanelBody> | ||
<h2> | ||
{ __( 'This is a heading for the PluginSidebar example.' ) } | ||
</h2> | ||
<p> | ||
{ __( | ||
'This is some example text for the PluginSidebar example.' | ||
) } | ||
</p> | ||
<TextControl | ||
label={ __( 'Text Control' ) } | ||
value={ text } | ||
onChange={ ( newText ) => setText( newText ) } | ||
/> | ||
<SelectControl | ||
label={ __( 'Select Control' ) } | ||
value={ select } | ||
options={ [ | ||
{ value: 'a', label: 'Option A' }, | ||
{ value: 'b', label: 'Option B' }, | ||
{ value: 'c', label: 'Option C' }, | ||
] } | ||
onChange={ ( newSelect ) => setSelect( newSelect ) } | ||
/> | ||
<Button variant="primary">{ __( 'Primary Button' ) } </Button> | ||
</PanelBody> | ||
</PluginSidebar> | ||
); | ||
}; | ||
|
||
registerPlugin( 'plugin-sidebar-test', { render: PluginSidebarTest } ); | ||
// Register the plugin. | ||
registerPlugin( 'plugin-sidebar-example', { render: PluginSidebarExample } ); | ||
``` | ||
|
||
## Location | ||
|
||
### Closed State | ||
|
||
![Closed State](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/assets/plugin-sidebar-closed-state.png?raw=true) | ||
|
||
### Open State | ||
|
||
![Open State](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/assets/plugin-sidebar-open-state.png?raw=true) |
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
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
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
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 was deleted.
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