From 77df0d69b20198638e68b4fd2b6f93861bfd7dee Mon Sep 17 00:00:00 2001 From: BE-Webdesign Date: Sun, 3 Sep 2017 15:23:48 -0400 Subject: [PATCH] Splitting Metabox iFrames into sidebar. Splits metabox iframes into sidebar, and changes the partial page to handle different metabox locations. --- assets/js/metabox.js | 1 + editor/layout/index.js | 2 +- editor/metaboxes/{index.js => main.js} | 3 +- editor/metaboxes/sidebar.js | 60 ++++++++++++++++ editor/sidebar/index.js | 6 +- lib/metabox-partial-page.php | 96 +++++++++++++++++++++++--- lib/register.php | 21 ------ 7 files changed, 153 insertions(+), 36 deletions(-) rename editor/metaboxes/{index.js => main.js} (93%) create mode 100644 editor/metaboxes/sidebar.js diff --git a/assets/js/metabox.js b/assets/js/metabox.js index d276f2a5dd4b15..3c5c09fa9bb4f5 100644 --- a/assets/js/metabox.js +++ b/assets/js/metabox.js @@ -1,5 +1,6 @@ ( function( iFrameResize, $ ) { $( document ).ready( function() { iFrameResize( { resizeFrom: 'child', heightCalculationMethod: 'documentElementScroll' }, '#gutenberg-metabox-iframe' ); + iFrameResize( { resizeFrom: 'child', heightCalculationMethod: 'documentElementScroll' }, '#gutenberg-metabox-iframe-sidebar' ); } ); } )( window.iFrameResize, jQuery ); diff --git a/editor/layout/index.js b/editor/layout/index.js index 36a5878ab8c341..d6a31530e9ce13 100644 --- a/editor/layout/index.js +++ b/editor/layout/index.js @@ -21,7 +21,7 @@ import UnsavedChangesWarning from '../unsaved-changes-warning'; import DocumentTitle from '../document-title'; import AutosaveMonitor from '../autosave-monitor'; import { removeNotice } from '../actions'; -import Metaboxes from '../metaboxes'; +import Metaboxes from '../metaboxes/main.js'; import { getEditorMode, isEditorSidebarOpened, diff --git a/editor/metaboxes/index.js b/editor/metaboxes/main.js similarity index 93% rename from editor/metaboxes/index.js rename to editor/metaboxes/main.js index cb4fe652e403b0..b616c419596300 100644 --- a/editor/metaboxes/index.js +++ b/editor/metaboxes/main.js @@ -3,13 +3,12 @@ */ import classnames from 'classnames'; import { connect } from 'react-redux'; -// @TODO Should this be React or WordPress elements? -import { Component } from 'react'; /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { Component } from '@wordpress/element'; /** * Internal dependencies diff --git a/editor/metaboxes/sidebar.js b/editor/metaboxes/sidebar.js new file mode 100644 index 00000000000000..0a083d6cdc3e43 --- /dev/null +++ b/editor/metaboxes/sidebar.js @@ -0,0 +1,60 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; +import { connect } from 'react-redux'; + +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { Component } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import './style.scss'; +import { setMetaboxReference } from '../actions'; + +class SidebarMetaboxes extends Component { + constructor() { + super(); + + this.state = { + cool: 'yeah', + }; + } + + componentDidMount() { + // Sets a React Node Reference into the store. + this.props.setReference( this.props.location, this.node ); + } + + render() { + const { location, id = 'gutenberg-metabox-iframe' } = this.props; + const classes = classnames( { + 'gutenberg-metabox-iframe': true, + } ); + + return ( +