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

Update: Make block inspector self contain its styles #17880

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
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const BlockInspector = ( {
}

return (
<>
<div className="block-editor-block-inspector">
<BlockCard blockType={ blockType } />
{ hasBlockStyles && (
<div>
Expand Down Expand Up @@ -81,7 +81,7 @@ const BlockInspector = ( {
</InspectorAdvancedControls.Slot>
</div>
<SkipToSelectedBlock key="back" />
</>
</div>
);
};

Expand Down
18 changes: 18 additions & 0 deletions packages/block-editor/src/components/block-inspector/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
.block-editor-block-inspector {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how this simplifies things but does it still hold true if we decide to show the inspector in a Modal tomorrow instead of a sidebar panel? Will we need these styles as well in the modal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes if the inspector was in a modal these would still improve the situation.
What these styles do is the following:

  • Make sure that when we have a series of PanelBody components the borders does not appear twice (now that I think about it it would probably be a good idea to put this at the component level, I will try to see if there is a style that makes sense there).
  • Increase the spacing in fields inside base control e.g: so the fields are not very close to each other and the inspector has more space.

Both actions would also be good in a modal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, both these styles also seem to be something that can be absorbed by the UI components themselves.

.components-base-control {
margin-bottom: #{ $grid-size * 3 };

&:last-child {
margin-bottom: $grid-size;
}
}
.components-panel__body {
border: none;
border-top: $border-width solid $light-gray-500;
}

.block-editor-block-card {
padding: $grid-size-large;
}
}

.block-editor-block-inspector__no-blocks {
display: block;
font-size: $default-font-size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe( 'Navigating the block hierarchy', () => {
await columnsBlockMenuItem.click();

// Tweak the columns count.
await page.focus( '.edit-post-settings-sidebar__panel-block .components-range-control__number[aria-label="Columns"]' );
await page.focus( '.block-editor-block-inspector .components-range-control__number[aria-label="Columns"]' );
await page.keyboard.down( 'Shift' );
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.up( 'Shift' );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { Panel, PanelBody } from '@wordpress/components';
import { Panel } from '@wordpress/components';
import { compose, ifCondition } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { BlockInspector } from '@wordpress/block-editor';
Expand Down Expand Up @@ -44,9 +44,7 @@ const SettingsSidebar = ( { sidebarName } ) => (
</>
) }
{ sidebarName === 'edit-post/block' && (
<PanelBody className="edit-post-settings-sidebar__panel-block">
youknowriad marked this conversation as resolved.
Show resolved Hide resolved
<BlockInspector />
</PanelBody>
<BlockInspector />
) }
</Panel>
</Sidebar>
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/edit-post/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
@import "./components/sidebar/post-status/style.scss";
@import "./components/sidebar/post-visibility/style.scss";
@import "./components/sidebar/settings-header/style.scss";
@import "./components/sidebar/settings-sidebar/style.scss";
@import "./components/sidebar/sidebar-header/style.scss";
@import "./components/text-editor/style.scss";
@import "./components/visual-editor/style.scss";
Expand Down