Skip to content

Commit

Permalink
Add Featured Image, Title and Excerpt to top of the settings sidebar
Browse files Browse the repository at this point in the history
- Moves the Featured Image panel to the top of the sidebar.
    - Uses a new dropdown-based flow for selecting a featured image.
    - Adds the ability to upload a featured image using the native file picker.
- Adds a new Summary component to top of the sidebar containing fields
  for modifying the post's title and excerpt.
- Removes the Excerpt panel in favour of excerpt field in Summary
  component.
  • Loading branch information
noisysocks committed Jul 13, 2022
1 parent 233142b commit 4dbafb2
Show file tree
Hide file tree
Showing 23 changed files with 420 additions and 288 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
Expand All @@ -13,13 +18,20 @@ import { closeSmall } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

export default function InspectorPopoverHeader( {
className,
title,
help,
actions = [],
onClose,
} ) {
return (
<VStack className="block-editor-inspector-popover-header" spacing={ 4 }>
<VStack
className={ classnames(
'block-editor-inspector-popover-header',
className
) }
spacing={ 4 }
>
<HStack alignment="center">
<Heading
className="block-editor-inspector-popover-header__heading"
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/menu-item/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
opacity: 0.3;
}
}

// Don't show red outline on destructive menu items.
&.is-destructive {
box-shadow: none;
}
}

.components-menu-item__info-wrapper {
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@wordpress/editor": "file:../editor",
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
"@wordpress/interface": "file:../interface",
Expand Down
14 changes: 0 additions & 14 deletions packages/edit-post/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
import { useMemo } from '@wordpress/element';
import {
PostTaxonomies,
PostExcerptCheck,
PageAttributesCheck,
PostFeaturedImageCheck,
PostTypeSupportCheck,
store as editorStore,
} from '@wordpress/editor';
Expand Down Expand Up @@ -205,18 +203,6 @@ export default function EditPostPreferencesModal() {
/>
) }
/>
<PostFeaturedImageCheck>
<EnablePanelOption
label={ __( 'Featured image' ) }
panelName="featured-image"
/>
</PostFeaturedImageCheck>
<PostExcerptCheck>
<EnablePanelOption
label={ __( 'Excerpt' ) }
panelName="post-excerpt"
/>
</PostExcerptCheck>
<PostTypeSupportCheck
supportKeys={ [ 'comments', 'trackbacks' ] }
>
Expand Down
73 changes: 0 additions & 73 deletions packages/edit-post/src/components/sidebar/featured-image/index.js

This file was deleted.

56 changes: 0 additions & 56 deletions packages/edit-post/src/components/sidebar/post-excerpt/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* WordPress dependencies
*/
import {
PostFeaturedImageCheck,
PostFeaturedImage as PostFeaturedImageForm,
} from '@wordpress/editor';
import { MediaUploadCheck } from '@wordpress/block-editor';

export default function PostFeaturedImage() {
return (
<PostFeaturedImageCheck>
<MediaUploadCheck>
<PostFeaturedImageForm className="edit-post-post-featured-image" />
</MediaUploadCheck>
</PostFeaturedImageCheck>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.edit-post-post-featured-image {
.editor-post-featured-image__container {
margin-left: -$grid-unit-20;
margin-right: -$grid-unit-20;
}

.editor-post-featured-image__toggle {
border-bottom: $border-width solid $gray-200;
border-top: $border-width solid $gray-200;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { compose, ifCondition } from '@wordpress/compose';
/**
* Internal dependencies
*/
import PostFeaturedImage from '../post-featured-image';
import PostSummary from '../post-summary';
import PostVisibility from '../post-visibility';
import PostTrash from '../post-trash';
import PostSchedule from '../post-schedule';
Expand Down Expand Up @@ -38,6 +40,8 @@ function PostStatus( { isOpened, onTogglePanel } ) {
<PluginPostStatusInfo.Slot>
{ ( fills ) => (
<>
<PostFeaturedImage />
<PostSummary />
<PostVisibility />
<PostSchedule />
<PostURL />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.edit-post-post-status .edit-post-post-publish-dropdown__switch-to-draft {
margin-top: 15px;
width: 100%;
text-align: center;
.edit-post-post-status {
[class].components-panel__body-title {
margin-bottom: 0;
}
}
26 changes: 26 additions & 0 deletions packages/edit-post/src/components/sidebar/post-summary/excerpt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* WordPress dependencies
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';
import { PlainText } from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';

export default function PostSummaryExcerpt() {
const excerpt = useSelect(
( select ) => select( editorStore ).getEditedPostAttribute( 'excerpt' ),
[]
);

const { editPost } = useDispatch( editorStore );

return (
<PlainText
__experimentalVersion={ 2 }
className="edit-post-post-summary__excerpt"
placeholder={ __( 'Add excerpt' ) }
value={ excerpt }
onChange={ ( value ) => editPost( { excerpt: value } ) }
/>
);
}
23 changes: 23 additions & 0 deletions packages/edit-post/src/components/sidebar/post-summary/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* WordPress dependencies
*/
import { PostTypeSupportCheck, PostExcerptCheck } from '@wordpress/editor';

/**
* Internal dependencies
*/
import PostSummaryTitle from './title';
import PostSummaryExcerpt from './excerpt';

export default function PostSummary() {
return (
<div className="edit-post-post-summary">
<PostTypeSupportCheck supportKeys="title">
<PostSummaryTitle />
</PostTypeSupportCheck>
<PostExcerptCheck>
<PostSummaryExcerpt />
</PostExcerptCheck>
</div>
);
}
21 changes: 21 additions & 0 deletions packages/edit-post/src/components/sidebar/post-summary/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.edit-post-post-summary {
border-bottom: $border-width solid $gray-200;
border-top: $border-width solid $gray-200;
margin-left: -$grid-unit-20;
margin-right: -$grid-unit-20;
padding: $grid-unit-10 $grid-unit-20 $grid-unit-20;

.edit-post-post-featured-image + & {
margin-top: -1px;
}
}

.edit-post-post-summary__title,
.edit-post-post-summary__excerpt {
margin-top: $grid-unit-10;
}

.edit-post-post-summary__title {
font-size: 16px;
font-weight: 600;
}
Loading

0 comments on commit 4dbafb2

Please sign in to comment.