Skip to content

Commit

Permalink
Post Sticky Toggle: Improve the design (WordPress#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 and patil-vipul committed Jun 17, 2024
1 parent 4c921f0 commit 99ab9b5
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

0 comments on commit 99ab9b5

Please sign in to comment.