Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for PostFeaturedImage, PostFeaturedImageCheck, PostFeaturedImagePanel #61165

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 37 additions & 3 deletions packages/editor/README.md
Expand Up @@ -954,15 +954,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
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
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
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