Skip to content

Commit

Permalink
Post Sticky Toggle: Improve the design (#62012)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: joedolson <[email protected]>
Co-authored-by: huzaifaalmesbah <[email protected]>
  • Loading branch information
6 people authored May 28, 2024
1 parent f174441 commit 486a381
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
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

1 comment on commit 486a381

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 486a381.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9269541560
📝 Reported issues:

Please sign in to comment.