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 12, 2022
1 parent e0c2b79 commit de6027c
Show file tree
Hide file tree
Showing 23 changed files with 425 additions and 286 deletions.
1 change: 1 addition & 0 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 @@ -8,6 +8,8 @@ import { useSelect } from '@wordpress/data';
* Internal dependencies
*/
import PostStatusHeader from './header';
import PostFeaturedImage from '../post-featured-image';
import PostSummary from '../post-summary';
import PostVisibility from '../post-visibility';
import PostSchedule from '../post-schedule';
import PostAuthor from '../post-author';
Expand Down Expand Up @@ -43,6 +45,8 @@ export default function PostStatus() {
{ ( fills ) => (
<>
<PostStatusHeader />
<PostFeaturedImage />
<PostSummary />
<PostVisibility />
<PostSchedule />
<PostURL />
Expand Down
15 changes: 11 additions & 4 deletions packages/edit-post/src/components/sidebar/post-status/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.edit-post-post-status__header {
margin: (-$grid-unit-20) (-$grid-unit-20) 0 (-$grid-unit-20);
padding: $grid-unit-20;

.components-dropdown-menu {
line-height: 0;
margin: -$grid-unit-05 0;
Expand All @@ -8,6 +11,14 @@
min-width: $grid-unit-30;
padding: 0;
}

& + .components-panel__row {
margin-top: 5px;
}
}

[class].edit-post-post-status__header {
box-sizing: content-box;
}

[class].edit-post-post-status__heading {
Expand All @@ -25,7 +36,3 @@
min-height: $icon-size;
min-width: $icon-size;
}

[class].edit-post-post-status__post-trash {
box-shadow: none;
}
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 de6027c

Please sign in to comment.