Skip to content

Commit

Permalink
Add README.md for PublishDateTimePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed May 19, 2022
1 parent 21e7e2c commit 6731934
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# `PublishDateTimePicker`

`<PublishDateTimePicker />` is a component used to select the date and time that
a post will be published. It wraps the `<DateTimePicker />` component found in
`@wordpress/components` and adds additional post-specific controls.

See [the documentation for
DateTimePicker](https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/date-time)
for more information.

## Usage

```jsx
import { Dropdown, Button } from '@wordpress/components';
import { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';
import { useState } from '@wordpress/element';

const MyDateTimePicker = () => {
const [ date, setDate ] = useState( new Date() );

return (
<Dropdown
renderToggle={ ( { isOpen, onToggle } ) => (
<Button
onClick={ onToggle }
aria-expanded={ isOpen }
>
Select post date
</Button>
) }
renderContent={ ( { onClose } ) => (
<PublishDateTimePicker
currentDate={ date }
onChange={ ( newDate ) => setDate( newDate ) }
onClose={ onClose }
/>
) }
/>
);
};
```

## Props

`PublishDateTimePicker` supports all of the props that
[`DateTimePicker`](https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/date-time#Props)
supports, plus:

### onClose

Called when the user presses the close button.

- Type: `Function`
- Required: Yes

0 comments on commit 6731934

Please sign in to comment.