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

Post Sticky Toggle: Improve the design #62012

Merged
merged 2 commits into from
May 28, 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
19 changes: 12 additions & 7 deletions packages/editor/src/components/post-sticky/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { CheckboxControl } from '@wordpress/components';
import { ToggleControl, VisuallyHidden } 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';

export default function PostSticky() {
const postSticky = useSelect( ( select ) => {
Expand All @@ -21,12 +22,16 @@ export default function PostSticky() {

return (
<PostStickyCheck>
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Stick to the top of the blog' ) }
checked={ postSticky }
onChange={ () => editPost( { sticky: ! postSticky } ) }
/>
<PostPanelRow label={ __( 'Sticky' ) }>
<ToggleControl
className="editor-post-sticky__toggle-control"
label={
<VisuallyHidden>{ __( 'Sticky' ) }</VisuallyHidden>
}
checked={ postSticky }
onChange={ () => editPost( { sticky: ! postSticky } ) }
/>
</PostPanelRow>
</PostStickyCheck>
);
}
3 changes: 3 additions & 0 deletions packages/editor/src/components/post-sticky/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.editor-post-sticky__toggle-control {
padding: 6px 12px;
}
2 changes: 1 addition & 1 deletion packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export default function PostSummary( { onActionPerformed } ) {
<BlogTitle />
<PostsPerPage />
<SiteDiscussion />
<PostStickyPanel />
</VStack>
<PostStickyPanel />
<PostFormatPanel />
<TemplateAreas />
{ fills }
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@import "./components/post-schedule/style.scss";
@import "./components/post-slug/style.scss";
@import "./components/post-status/style.scss";
@import "./components/post-sticky/style.scss";
@import "./components/post-sync-status/style.scss";
@import "./components/post-taxonomies/style.scss";
@import "./components/post-template/style.scss";
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/sidebar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test.describe( 'Sidebar', () => {
name: 'Change discussion options',
} );
const postSummarySection = page.getByRole( 'checkbox', {
name: 'Stick to the top of the blog',
name: 'Sticky',
} );

await expect( postExcerptPanel ).toBeVisible();
Expand Down
Loading