From a8e82c59c93080962b03ed68684922f9a9fbcf50 Mon Sep 17 00:00:00 2001 From: Sunil Prajapati <61308756+akasunil@users.noreply.github.com> Date: Fri, 14 Jun 2024 19:56:39 +0530 Subject: [PATCH] Added doc for PostSticky components (#62100) --- packages/editor/README.md | 17 +++++++++++++++-- .../editor/src/components/post-sticky/check.js | 8 ++++++++ .../editor/src/components/post-sticky/index.js | 5 +++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index f5a209274f3550..9b4ec07bfded24 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -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 diff --git a/packages/editor/src/components/post-sticky/check.js b/packages/editor/src/components/post-sticky/check.js index e31c145b9bbf0f..f504effca82c6b 100644 --- a/packages/editor/src/components/post-sticky/check.js +++ b/packages/editor/src/components/post-sticky/check.js @@ -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(); diff --git a/packages/editor/src/components/post-sticky/index.js b/packages/editor/src/components/post-sticky/index.js index f3d3085da7fd65..607e09ff507c9e 100644 --- a/packages/editor/src/components/post-sticky/index.js +++ b/packages/editor/src/components/post-sticky/index.js @@ -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 (