Skip to content

Commit

Permalink
Added doc for components PageAttributesCheck, PageAttributesPanel, Pa…
Browse files Browse the repository at this point in the history
…geAttributesOrder, PageAttributesParent (#60977)

Co-authored-by: sunil25393 <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Apr 26, 2024
1 parent 6a0120b commit b7c633c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
29 changes: 25 additions & 4 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/page-attributes/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 6 additions & 0 deletions packages/editor/src/components/page-attributes/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<PostTypeSupportCheck supportKeys="page-attributes">
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/page-attributes/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ function AttributesPanel() {
);
}

/**
* Renders the Page Attributes Panel component.
*
* @return {Component} The component to be rendered.
*/
export default function PageAttributesPanel() {
return (
<PageAttributesCheck>
Expand Down
6 changes: 6 additions & 0 deletions packages/editor/src/components/page-attributes/parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit b7c633c

Please sign in to comment.