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

Move Sticky toggle to status popover #62782

Merged
merged 6 commits into from
Jun 25, 2024
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
2 changes: 1 addition & 1 deletion packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ _Returns_

### PostSticky

Renders the PostSticky component. It provide toggle control for the sticky post feature.
Renders the PostSticky component. It provides a checkbox control for the sticky post feature.

_Returns_

Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/post-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
NAVIGATION_POST_TYPE,
} from '../../store/constants';
import PostPanelRow from '../post-panel-row';
import PostSticky from '../post-sticky';
import { PrivatePostSchedule } from '../post-schedule';
import { store as editorStore } from '../../store';

Expand Down Expand Up @@ -281,6 +282,7 @@ export default function PostStatus() {
) }
</VStack>
) }
<PostSticky />
</VStack>
</form>
</>
Expand Down
23 changes: 10 additions & 13 deletions packages/editor/src/components/post-sticky/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { ToggleControl, VisuallyHidden } from '@wordpress/components';
import { CheckboxControl } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import PostStickyCheck from './check';
import { store as editorStore } from '../../store';
import PostPanelRow from '../post-panel-row';

/**
* Renders the PostSticky component. It provide toggle control for the sticky post feature.
* Renders the PostSticky component. It provides a checkbox control for the sticky post feature.
*
* @return {Component} The component to be rendered.
*/
Expand All @@ -27,16 +26,14 @@ export default function PostSticky() {

return (
<PostStickyCheck>
<PostPanelRow label={ __( 'Sticky' ) }>
<ToggleControl
className="editor-post-sticky__toggle-control"
label={
<VisuallyHidden>{ __( 'Sticky' ) }</VisuallyHidden>
}
checked={ postSticky }
onChange={ () => editPost( { sticky: ! postSticky } ) }
/>
</PostPanelRow>
<CheckboxControl
className="editor-post-sticky__checkbox-control"
label={ __( 'Sticky' ) }
help={ __( 'Pin this post to the top of the blog' ) }
checked={ postSticky }
onChange={ () => editPost( { sticky: ! postSticky } ) }
__nextHasNoMarginBottom
/>
</PostStickyCheck>
);
}
5 changes: 3 additions & 2 deletions packages/editor/src/components/post-sticky/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.editor-post-sticky__toggle-control {
padding: 6px 12px;
.editor-post-sticky__checkbox-control {
border-top: $border-width solid $gray-200;
padding-top: $grid-unit-20;
}
2 changes: 0 additions & 2 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import PostLastEditedPanel from '../post-last-edited-panel';
import PostPanelSection from '../post-panel-section';
import PostSchedulePanel from '../post-schedule/panel';
import PostStatusPanel from '../post-status';
import PostStickyPanel from '../post-sticky';
import PostSyncStatus from '../post-sync-status';
import PostTemplatePanel from '../post-template/panel';
import PostURLPanel from '../post-url/panel';
Expand Down Expand Up @@ -84,7 +83,6 @@ export default function PostSummary( { onActionPerformed } ) {
<PostsPerPage />
<SiteDiscussion />
<PostFormatPanel />
<PostStickyPanel />
</VStack>
<TemplateAreas />
{ fills }
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/specs/editor/various/sidebar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ test.describe( 'Sidebar', () => {
const postDiscussionPanel = page.getByRole( 'button', {
name: 'Change discussion options',
} );
const postSummarySection = page.getByRole( 'checkbox', {
name: 'Sticky',
const postAuthorPanel = page.getByRole( 'button', {
name: 'admin',
} );

await expect( postExcerptPanel ).toBeVisible();
await expect( postFeaturedImagePanel ).toBeVisible();
await expect( postSummarySection ).toBeVisible();
await expect( postAuthorPanel ).toBeVisible();
await expect( postDiscussionPanel ).toHaveCount( 1 );

await page.evaluate( () => {
Expand All @@ -149,7 +149,7 @@ test.describe( 'Sidebar', () => {
await expect( documentSettingsPanels ).toHaveCount( 1 );
await expect( postExcerptPanel ).toBeHidden();
await expect( postFeaturedImagePanel ).toBeHidden();
await expect( postSummarySection ).toBeHidden();
await expect( postAuthorPanel ).toBeHidden();
await expect( postDiscussionPanel ).toHaveCount( 0 );
} );
} );
Loading