Skip to content

Commit

Permalink
Publish sidebar extensibility: utilizing new createSlotFill factory
Browse files Browse the repository at this point in the history
Replacing repetitious code with newly created createSlotFill factory function
for PluginPrePublishPanel and PluginPostPublishPanel slots.

props @gziolo
  • Loading branch information
c-shultz committed Apr 12, 2018
1 parent f0acdcf commit 658fdc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 72 deletions.
39 changes: 3 additions & 36 deletions edit-post/components/plugin-post-publish-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,12 @@
* (which appears after a user fully publishes a post).
*
* @file This files defines the PluginPostPublishPanel extension
* @since 2.6.0
* @since 2.7.0
*/

/**
* WordPress dependencies
*/
import { Slot, Fill } from '@wordpress/components';

/**
* Internal dependencies
*/
import { createSlotFill } from '../../../components/slot-fill';

/**
* Name of slot to fill.
*
* @type {String}
*/
const SLOT_NAME = 'PluginPostPublishPanel';

/**
* Renders the plugin sidebar fill.
*
* @return {WPElement} Plugin sidebar fill.
*/
function PluginPostPublishPanel( { children } ) {
return (
<Fill name={ SLOT_NAME } >
{ children }
</Fill>
);
}

/**
* The plugin sidebar slot.
*
* @return {WPElement} The plugin sidebar slot.
*/
PluginPostPublishPanel.Slot = () => (
<Slot name={ SLOT_NAME } />
);

export default PluginPostPublishPanel;
export default createSlotFill( 'PluginPostPublishPanel' );
39 changes: 3 additions & 36 deletions edit-post/components/plugin-pre-publish-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,12 @@
* (which appears when a user pushes "Publish" from the main editor).
*
* @file This files defines the PluginPrePublishPanel extension
* @since 2.6.0
* @since 2.7.0
*/

/**
* WordPress dependencies
*/
import { Slot, Fill } from '@wordpress/components';

/**
* Internal dependencies
*/
import { createSlotFill } from '../../../components/slot-fill';

/**
* Name of slot to fill.
*
* @type {String}
*/
const SLOT_NAME = 'PluginPrePublishPanel';

/**
* Renders the plugin sidebar fill.
*
* @return {WPElement} Plugin sidebar fill.
*/
function PluginPrePublishPanel( { children } ) {
return (
<Fill name={ SLOT_NAME } >
{ children }
</Fill>
);
}

/**
* The plugin sidebar slot.
*
* @return {WPElement} The plugin sidebar slot.
*/
PluginPrePublishPanel.Slot = () => (
<Slot name={ SLOT_NAME } />
);

export default PluginPrePublishPanel;
export default createSlotFill( 'PluginPrePublishPanel' );

0 comments on commit 658fdc4

Please sign in to comment.