Skip to content

Commit

Permalink
Fix model after rebasing master
Browse files Browse the repository at this point in the history
  • Loading branch information
boblinthorst committed Apr 18, 2018
1 parent 33c029e commit 82b5cc5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 855 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export default class EditorScreenTakeover extends Component {

render() {
const { height } = this.state;
const { icon, title, children, isOpen, onClose } = this.props;
const { icon, title, children, onClose } = this.props;
return <Modal
isOpen={ isOpen }
isOpen={ true }
className={ 'edit-post-plugin-screen-takeover__editor-screen-takeover' }
overlayClassName={ 'edit-post-plugin-screen-takeover__editor-screen-takeover-overlay' }
parentSelector={ () => document.getElementsByClassName( 'gutenberg' )[ 0 ] }
Expand Down
38 changes: 21 additions & 17 deletions edit-post/components/plugin-screen-takeover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* WordPress dependencies
*/
import { compose } from '@wordpress/element';
import { Slot, Fill, withContext } from '@wordpress/components';
import { Slot, Fill } from '@wordpress/components';
import { withDispatch, withSelect } from '@wordpress/data';
import { PluginContext } from '@wordpress/plugins';

/**
* Internal dependencies
Expand All @@ -18,28 +19,31 @@ import EditorScreenTakeover from './editor-screen-takeover';
*/
const SLOT_NAME = 'PluginScreenTakeover';

let PluginScreenTakeover = ( { pluginName, name, icon, children, isOpen, onClose } ) => (
<Fill name={ [ SLOT_NAME, pluginName, name ].join( '/' ) }>
<EditorScreenTakeover
icon={ icon }
title={ 'Screen Takeover Title' }
isOpen={ isOpen }
onClose={ onClose }
>
{ children }
</EditorScreenTakeover>
</Fill>
let PluginScreenTakeover = ( { name, icon, children, onClose, title } ) => (
<PluginContext.Consumer>
{ ( { pluginName } ) => {
return (
<Fill name={ [ SLOT_NAME, pluginName, name ].join( '/' ) }>
<EditorScreenTakeover
icon={ icon }
title={ title }
onClose={ onClose }
>
{ children }
</EditorScreenTakeover>
</Fill>
);
} }
</PluginContext.Consumer>
);

PluginScreenTakeover = compose( [
withContext( 'pluginName' )(),
withDispatch( ( dispatch ) => ( {
onClose: dispatch( 'core/edit-post' ).closeScreenTakeover,
} ) ),
withSelect( ( select, ownProps ) => {
const { name, pluginName } = ownProps;
withSelect( ( select ) => {
return {
isOpen: select( 'core/edit-post' ).getActiveScreenTakeoverName() === `${ pluginName }/${ name }`,
activeScreenTakeoverName: select( 'core/edit-post' ).getActiveScreenTakeoverName(),
};
} ),
] )( PluginScreenTakeover );
Expand All @@ -52,4 +56,4 @@ PluginScreenTakeover.Slot = withSelect( select => ( {
activeScreenTakeoverName: select( 'core/edit-post' ).getActiveScreenTakeoverName(),
} ) )( PluginScreenTakeover.Slot );

export default PluginScreenTakeover;
export default PluginScreenTakeover;
Loading

0 comments on commit 82b5cc5

Please sign in to comment.