From b7c633cb2321039a047aa5cd25519f3fab859001 Mon Sep 17 00:00:00 2001 From: Sunil Prajapati <61308756+sunil25393@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:24:27 +0530 Subject: [PATCH] Added doc for components PageAttributesCheck, PageAttributesPanel, PageAttributesOrder, PageAttributesParent (#60977) Co-authored-by: sunil25393 Co-authored-by: youknowriad --- packages/editor/README.md | 29 ++++++++++++++++--- .../src/components/page-attributes/check.js | 8 +++++ .../src/components/page-attributes/order.js | 6 ++++ .../src/components/page-attributes/panel.js | 5 ++++ .../src/components/page-attributes/parent.js | 6 ++++ 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index 673d3d100a956e..5c363c27058f36 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -444,19 +444,40 @@ _Parameters_ ### PageAttributesCheck -Undocumented declaration. +Wrapper component that renders its children only if the post type supports page attributes. + +_Parameters_ + +- _props_ `Object`: - The component props. +- _props.children_ `Element`: - The child components to render. + +_Returns_ + +- `Component|null`: The rendered child components or null if page attributes are not supported. ### PageAttributesOrder -Undocumented declaration. +Renders the Page Attributes Order component. A number input in an editor interface for setting the order of a given page. + +_Returns_ + +- `Component`: The component to be rendered. ### PageAttributesPanel -Undocumented declaration. +Renders the Page Attributes Panel component. + +_Returns_ + +- `Component`: The component to be rendered. ### PageAttributesParent -Undocumented declaration. +Renders the Page Attributes Parent component. A dropdown menu in an editor interface for selecting the parent page of a given page. + +_Returns_ + +- `Component|null`: The component to be rendered. Return null if post type is not hierarchical. ### PageTemplate diff --git a/packages/editor/src/components/page-attributes/check.js b/packages/editor/src/components/page-attributes/check.js index 828b91b13f595f..bed2b1a353842a 100644 --- a/packages/editor/src/components/page-attributes/check.js +++ b/packages/editor/src/components/page-attributes/check.js @@ -9,6 +9,14 @@ import { store as coreStore } from '@wordpress/core-data'; */ import { store as editorStore } from '../../store'; +/** + * Wrapper component that renders its children only if the post type supports page attributes. + * + * @param {Object} props - The component props. + * @param {Element} props.children - The child components to render. + * + * @return {Component|null} The rendered child components or null if page attributes are not supported. + */ export function PageAttributesCheck( { children } ) { const supportsPageAttributes = useSelect( ( select ) => { const { getEditedPostAttribute } = select( editorStore ); diff --git a/packages/editor/src/components/page-attributes/order.js b/packages/editor/src/components/page-attributes/order.js index 4a751c0b151aba..d8a22f0cc949fb 100644 --- a/packages/editor/src/components/page-attributes/order.js +++ b/packages/editor/src/components/page-attributes/order.js @@ -53,6 +53,12 @@ function PageAttributesOrder() { ); } +/** + * Renders the Page Attributes Order component. A number input in an editor interface + * for setting the order of a given page. + * + * @return {Component} The component to be rendered. + */ export default function PageAttributesOrderWithChecks() { return ( diff --git a/packages/editor/src/components/page-attributes/panel.js b/packages/editor/src/components/page-attributes/panel.js index d6fb9294748ab0..5fb2638b517310 100644 --- a/packages/editor/src/components/page-attributes/panel.js +++ b/packages/editor/src/components/page-attributes/panel.js @@ -52,6 +52,11 @@ function AttributesPanel() { ); } +/** + * Renders the Page Attributes Panel component. + * + * @return {Component} The component to be rendered. + */ export default function PageAttributesPanel() { return ( diff --git a/packages/editor/src/components/page-attributes/parent.js b/packages/editor/src/components/page-attributes/parent.js index b1f9e15ff45e87..900f6f8a7c66b2 100644 --- a/packages/editor/src/components/page-attributes/parent.js +++ b/packages/editor/src/components/page-attributes/parent.js @@ -40,6 +40,12 @@ export const getItemPriority = ( name, searchValue ) => { return Infinity; }; +/** + * Renders the Page Attributes Parent component. A dropdown menu in an editor interface + * for selecting the parent page of a given page. + * + * @return {Component|null} The component to be rendered. Return null if post type is not hierarchical. + */ export function PageAttributesParent() { const { editPost } = useDispatch( editorStore ); const [ fieldValue, setFieldValue ] = useState( false );