Skip to content

Commit

Permalink
Added doc for PostFeaturedImage components (#61165)
Browse files Browse the repository at this point in the history
  • Loading branch information
akasunil authored May 21, 2024
1 parent dd4e2dd commit af00619
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
40 changes: 37 additions & 3 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -974,15 +974,49 @@ Undocumented declaration.

### PostFeaturedImage

Undocumented declaration.
Renders the component for managing the featured image of a post.

_Parameters_

- _props_ `Object`: Props.
- _props.currentPostId_ `number`: ID of the current post.
- _props.featuredImageId_ `number`: ID of the featured image.
- _props.onUpdateImage_ `Function`: Function to call when the image is updated.
- _props.onRemoveImage_ `Function`: Function to call when the image is removed.
- _props.media_ `Object`: The media object representing the featured image.
- _props.postType_ `string`: Post type.
- _props.noticeUI_ `Element`: UI for displaying notices.
- _props.noticeOperations_ `Object`: Operations for managing notices.

_Returns_

- `Element`: Component to be rendered .

### PostFeaturedImageCheck

Undocumented declaration.
Wrapper component that renders its children only if the post type supports a featured image and the theme supports post thumbnails.

_Parameters_

- _props_ `Object`: Props.
- _props.children_ `Element`: Children to be rendered.

_Returns_

- `Component`: The component to be rendered.

### PostFeaturedImagePanel

Undocumented declaration.
Renders the panel for the post featured image.

_Parameters_

- _props_ `Object`: Props.
- _props.withPanelBody_ `boolean`: Whether to include the panel body. Default true.

_Returns_

- `Component|null`: The component to be rendered. Return Null if the editor panel is disabled for featured image.

### PostFormat

Expand Down
9 changes: 9 additions & 0 deletions packages/editor/src/components/post-featured-image/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
import PostTypeSupportCheck from '../post-type-support-check';
import ThemeSupportCheck from '../theme-support-check';

/**
* Wrapper component that renders its children only if the post type supports a featured image
* and the theme supports post thumbnails.
*
* @param {Object} props Props.
* @param {Element} props.children Children to be rendered.
*
* @return {Component} The component to be rendered.
*/
function PostFeaturedImageCheck( { children } ) {
return (
<ThemeSupportCheck supportKeys="post-thumbnails">
Expand Down
15 changes: 15 additions & 0 deletions packages/editor/src/components/post-featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ const applyWithDispatch = withDispatch(
}
);

/**
* Renders the component for managing the featured image of a post.
*
* @param {Object} props Props.
* @param {number} props.currentPostId ID of the current post.
* @param {number} props.featuredImageId ID of the featured image.
* @param {Function} props.onUpdateImage Function to call when the image is updated.
* @param {Function} props.onRemoveImage Function to call when the image is removed.
* @param {Object} props.media The media object representing the featured image.
* @param {string} props.postType Post type.
* @param {Element} props.noticeUI UI for displaying notices.
* @param {Object} props.noticeOperations Operations for managing notices.
*
* @return {Element} Component to be rendered .
*/
export default compose(
withNotices,
applyWithSelect,
Expand Down
9 changes: 9 additions & 0 deletions packages/editor/src/components/post-featured-image/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ import PostFeaturedImageCheck from './check';

const PANEL_NAME = 'featured-image';

/**
* Renders the panel for the post featured image.
*
* @param {Object} props Props.
* @param {boolean} props.withPanelBody Whether to include the panel body. Default true.
*
* @return {Component|null} The component to be rendered.
* Return Null if the editor panel is disabled for featured image.
*/
export default function PostFeaturedImagePanel( { withPanelBody = true } ) {
const { postType, isEnabled, isOpened } = useSelect( ( select ) => {
const {
Expand Down

1 comment on commit af00619

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in af00619.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9182054639
📝 Reported issues:

Please sign in to comment.