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 PostSchedule, PostScheduleCheck, PostSchedulePanel, PostScheduleLabel, usePostScheduleLabel components #61345

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-schedule/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-schedule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => ( {
Expand Down
15 changes: 15 additions & 0 deletions packages/editor/src/components/post-schedule/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => ( {
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-schedule/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading