From 807020b9f7ca5530c48ddbcae1933ed95b763da8 Mon Sep 17 00:00:00 2001 From: sunil25393 Date: Fri, 3 May 2024 10:14:07 +0530 Subject: [PATCH] Added doc for PostSchedule components --- packages/editor/README.md | 49 +++++++++++++++++-- .../src/components/post-schedule/check.js | 8 +++ .../src/components/post-schedule/index.js | 8 +++ .../src/components/post-schedule/label.js | 15 ++++++ .../src/components/post-schedule/panel.js | 5 ++ 5 files changed, 80 insertions(+), 5 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index 48a5e52cc47aa4..14ec88d86fc344 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -1031,19 +1031,49 @@ _Returns_ ### PostSchedule -Undocumented declaration. +Renders the PostSchedule component. It allows the user to schedule a post. + +_Parameters_ + +- _props_ `Object`: Props. +- _props.onClose_ `Function`: Function to close the component. + +_Returns_ + +- `Component`: The component to be rendered. ### PostScheduleCheck -Undocumented declaration. +Wrapper component that renders its children only if post has a publish action. + +_Parameters_ + +- _props_ `Object`: Props. +- _props.children_ `Element`: Children to be rendered. + +_Returns_ + +- `Component`: - The component to be rendered or null if there is no publish action. ### PostScheduleLabel -Undocumented declaration. +Renders the PostScheduleLabel component. + +_Parameters_ + +- _props_ `Object`: Props. + +_Returns_ + +- `Component`: The component to be rendered. ### PostSchedulePanel -Undocumented declaration. +Renders the Post Schedule Panel component. + +_Returns_ + +- `Component`: The component to be rendered. ### PostSlug @@ -1258,7 +1288,16 @@ Undocumented declaration. ### usePostScheduleLabel -Undocumented declaration. +Custom hook to get the label for post schedule. + +_Parameters_ + +- _options_ `Object`: Options for the hook. +- _options.full_ `boolean`: Whether to get the full label or not. Default is false. + +_Returns_ + +- `string`: The label for post schedule. ### usePostURLLabel diff --git a/packages/editor/src/components/post-schedule/check.js b/packages/editor/src/components/post-schedule/check.js index 716d75efc9d407..28456b90371cc3 100644 --- a/packages/editor/src/components/post-schedule/check.js +++ b/packages/editor/src/components/post-schedule/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 publish action. + * + * @param {Object} props Props. + * @param {Element} props.children Children to be rendered. + * + * @return {Component} - The component to be rendered or null if there is no publish action. + */ export default function PostScheduleCheck( { children } ) { const hasPublishAction = useSelect( ( select ) => { return ( diff --git a/packages/editor/src/components/post-schedule/index.js b/packages/editor/src/components/post-schedule/index.js index 98a22a992113d5..af32cc46c67ace 100644 --- a/packages/editor/src/components/post-schedule/index.js +++ b/packages/editor/src/components/post-schedule/index.js @@ -17,6 +17,14 @@ import { store as coreStore } from '@wordpress/core-data'; */ import { store as editorStore } from '../../store'; +/** + * Renders the PostSchedule component. It allows the user to schedule a post. + * + * @param {Object} props Props. + * @param {Function} props.onClose Function to close the component. + * + * @return {Component} The component to be rendered. + */ export default function PostSchedule( { onClose } ) { const { postDate, postType } = useSelect( ( select ) => ( { diff --git a/packages/editor/src/components/post-schedule/label.js b/packages/editor/src/components/post-schedule/label.js index 223eaaca06343e..89e7d02d69ce7f 100644 --- a/packages/editor/src/components/post-schedule/label.js +++ b/packages/editor/src/components/post-schedule/label.js @@ -10,10 +10,25 @@ import { useSelect } from '@wordpress/data'; */ import { store as editorStore } from '../../store'; +/** + * Renders the PostScheduleLabel component. + * + * @param {Object} props Props. + * + * @return {Component} The component to be rendered. + */ export default function PostScheduleLabel( props ) { return usePostScheduleLabel( props ); } +/** + * Custom hook to get the label for post schedule. + * + * @param {Object} options Options for the hook. + * @param {boolean} options.full Whether to get the full label or not. Default is false. + * + * @return {string} The label for post schedule. + */ export function usePostScheduleLabel( { full = false } = {} ) { const { date, isFloating } = useSelect( ( select ) => ( { diff --git a/packages/editor/src/components/post-schedule/panel.js b/packages/editor/src/components/post-schedule/panel.js index af7488561a1de2..47819ea1ed8938 100644 --- a/packages/editor/src/components/post-schedule/panel.js +++ b/packages/editor/src/components/post-schedule/panel.js @@ -28,6 +28,11 @@ const DESIGN_POST_TYPES = [ NAVIGATION_POST_TYPE, ]; +/** + * Renders the Post Schedule Panel component. + * + * @return {Component} The component to be rendered. + */ export default function PostSchedulePanel() { const [ popoverAnchor, setPopoverAnchor ] = useState( null ); const postType = useSelect(