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

Add documentation for PostSticky and PostStickyCheck component #62100

Merged
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
17 changes: 15 additions & 2 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,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
Loading