Skip to content

Commit

Permalink
Added doc for PostSchedule components (WordPress#61345)
Browse files Browse the repository at this point in the history
  • Loading branch information
akasunil authored and bph committed May 20, 2024
1 parent e99d6c3 commit a33b6fc
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 5 deletions.
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

0 comments on commit a33b6fc

Please sign in to comment.