-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add README.md for PublishDateTimePicker
- Loading branch information
1 parent
21e7e2c
commit 6731934
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
packages/block-editor/src/components/publish-date-time-picker/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |