Skip to content

Commit

Permalink
Added doc for PostSticky components (WordPress#62100)
Browse files Browse the repository at this point in the history
  • Loading branch information
akasunil authored Jun 14, 2024
1 parent 79ffe95 commit a8e82c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1276,11 +1276,24 @@ Undocumented declaration.

### PostSticky

Undocumented declaration.
Renders the PostSticky component. It provide toggle control for the sticky post feature.

_Returns_

- `Component`: The component to be rendered.

### PostStickyCheck

Undocumented declaration.
Wrapper component that renders its children only if post has a sticky action.

_Parameters_

- _props_ `Object`: Props.
- _props.children_ `Element`: Children to be rendered.

_Returns_

- `Component`: The component to be rendered or null if post type is not 'post' or hasStickyAction is false.

### PostSwitchToDraftButton

Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-sticky/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import { useSelect } from '@wordpress/data';
*/
import { store as editorStore } from '../../store';

/**
* Wrapper component that renders its children only if post has a sticky action.
*
* @param {Object} props Props.
* @param {Element} props.children Children to be rendered.
*
* @return {Component} The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
*/
export default function PostStickyCheck( { children } ) {
const { hasStickyAction, postType } = useSelect( ( select ) => {
const post = select( editorStore ).getCurrentPost();
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-sticky/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ 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.
*
* @return {Component} The component to be rendered.
*/
export default function PostSticky() {
const postSticky = useSelect( ( select ) => {
return (
Expand Down

0 comments on commit a8e82c5

Please sign in to comment.