Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slot to render block settings in the inspector. #731

Merged
merged 1 commit into from
May 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion editor/modes/visual-editor/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { connect } from 'react-redux';
import classnames from 'classnames';
import { Slot } from 'react-slot-fill';
import { Fill, Slot } from 'react-slot-fill';
import { partial } from 'lodash';

/**
Expand Down Expand Up @@ -237,6 +237,16 @@ class VisualEditorBlock extends wp.element.Component {
mergeWithPrevious={ this.mergeWithPrevious }
/>
</div>
{ isSelected &&
<Fill name="Sidebar.Inspector">
<div>{ block.blockType } settings...</div>
<ul>
{ Object.keys( block.attributes ).map( ( attribute, index ) => (
<li key={ index }>{ attribute }: { block.attributes[ attribute ] }</li>
) ) }
</ul>
</Fill>
}
</div>
);
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */
Expand Down
11 changes: 11 additions & 0 deletions editor/sidebar/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { Slot } from 'react-slot-fill';

/**
* Internal Dependencies
*/
Expand All @@ -6,6 +11,12 @@ import './style.scss';
const Sidebar = () => {
return (
<div className="editor-sidebar">
<div className="editor-sidebar__header">
<span className="editor-sidebar__select-post">Post</span> → Block
</div>
<div className="editor-sidebar__content">
<Slot name="Sidebar.Inspector" />
</div>
</div>
);
};
Expand Down
16 changes: 16 additions & 0 deletions editor/sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@
.editor-layout.is-sidebar-opened .editor-text-editor__formatting {
margin-right: $sidebar-width;
}

.editor-sidebar__header {
padding: 16px;
}

.editor-sidebar__select-post {
font-weight: 600;
text-decoration: underline;
}

.editor-sidebar__content {
background: $white;
border-bottom: 1px solid $light-gray-500;
border-top: 1px solid $light-gray-500;
padding: 16px;
}