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 a description to list view in the post editor #40230

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import {
useInstanceId,
useMergeRefs,
} from '@wordpress/compose';
import { useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { useDispatch, useSelect } from '@wordpress/data';
import { __, _x, sprintf } from '@wordpress/i18n';
import { closeSmall } from '@wordpress/icons';
import { ESCAPE } from '@wordpress/keycodes';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -35,6 +36,16 @@ export default function ListViewSidebar() {
const instanceId = useInstanceId( ListViewSidebar );
const labelId = `edit-post-editor__list-view-panel-label-${ instanceId }`;

const { documentLabel, isTemplateMode } = useSelect( ( select ) => {
const postTypeLabel = select( editorStore ).getPostTypeLabel();

return {
// translators: Default label for the document in the list view description.
documentLabel: postTypeLabel || _x( 'document', 'noun' ),
isTemplateMode: select( editPostStore ).isEditingTemplate(),
};
}, [] );

return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div
Expand All @@ -46,7 +57,21 @@ export default function ListViewSidebar() {
className="edit-post-editor__list-view-panel-header"
ref={ headerFocusReturnRef }
>
<strong id={ labelId }>{ __( 'List View' ) }</strong>
<div>
<strong id={ labelId }>{ __( 'List View' ) }</strong>

<p>
{ sprintf(
// translators: List view description. %s: Document label.
__(
'Manage and reorder blocks and groups of blocks used in your %s.'
),
isTemplateMode
? _x( 'template', 'noun' )
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this context, we can simplify the text to something that would work for all the editors

: documentLabel.toLowerCase()
) }
</p>
</div>
<Button
icon={ closeSmall }
label={ __( 'Close List View Sidebar' ) }
Expand Down
14 changes: 11 additions & 3 deletions packages/edit-post/src/components/secondary-sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@
}

.edit-post-editor__list-view-panel-header {
align-items: center;
border-bottom: $border-width solid $gray-300;
display: flex;
justify-content: space-between;
height: $grid-unit-60;
padding-left: $grid-unit-20;
padding-right: $grid-unit-05;

strong {
padding-top: $grid-unit-20;
display: block;
}

p {
margin-top: $grid-unit-10;
margin-bottom: $grid-unit-20;
max-width: 300px;
}
}

.edit-post-editor__list-view-panel-content {
Expand Down