-
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.
Design updates to the Publish popover (
DateTimePicker
) (#41097)
* Re-organise date-time dir to have component subdirs * Update design of DateTimePicker and convert to Emotion - Updates the design of DateTimePicker, DatePicker and TimePicker. - Converts CSS in DateTimePicker, DatePicker and TimePicker to Emotion where it makes sense to do so. - Allows removal of Reset button and Help functionality from DateTimePicker. - Adds PublishDateTimePicker to block-editor. This exposes a specialised DateTimePicker that is good for choosing a post publish date. * Add deprecated warning for when __nextRemoveHelpButton and __nextRemoveResetButton are not given * Target component instead of classname * Use space() instead of hardcoded widths * Update CSS selectors used in E2E tests * Update changelog * Update scheduling e2e test * Use relative URLs in README.md
- Loading branch information
1 parent
ef6c2fe
commit 43d9c82
Showing
34 changed files
with
1,082 additions
and
845 deletions.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
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,52 @@ | ||
# `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](/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`](/packages/components/src/date-time#Props) supports, plus: | ||
|
||
### onClose | ||
|
||
Called when the user presses the close button. | ||
|
||
- Type: `Function` | ||
- Required: Yes |
50 changes: 50 additions & 0 deletions
50
packages/block-editor/src/components/publish-date-time-picker/index.js
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,50 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
DateTimePicker, | ||
__experimentalHStack as HStack, | ||
__experimentalSpacer as Spacer, | ||
Button, | ||
} from '@wordpress/components'; | ||
import { closeSmall } from '@wordpress/icons'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { forwardRef } from '@wordpress/element'; | ||
|
||
function PublishDateTimePicker( | ||
{ onClose, onChange, ...additionalProps }, | ||
ref | ||
) { | ||
return ( | ||
<div ref={ ref } className="block-editor-publish-date-time-picker"> | ||
{ /* TODO: This header is essentially the same as the one in <PostVisiblity />. DRY it up. */ } | ||
<HStack className="block-editor-publish-date-time-picker__header"> | ||
<h2 className="block-editor-publish-date-time-picker__heading"> | ||
{ __( 'Publish' ) } | ||
</h2> | ||
<Spacer /> | ||
<Button | ||
className="block-editor-publish-date-time-picker__reset" | ||
variant="tertiary" | ||
onClick={ () => onChange?.( null ) } | ||
> | ||
{ __( 'Now' ) } | ||
</Button> | ||
<Button | ||
className="block-editor-publish-date-time-picker__close" | ||
icon={ closeSmall } | ||
label={ __( 'Close' ) } | ||
onClick={ onClose } | ||
/> | ||
</HStack> | ||
<DateTimePicker | ||
__nextRemoveHelpButton | ||
__nextRemoveResetButton | ||
onChange={ onChange } | ||
{ ...additionalProps } | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default forwardRef( PublishDateTimePicker ); |
20 changes: 20 additions & 0 deletions
20
packages/block-editor/src/components/publish-date-time-picker/style.scss
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,20 @@ | ||
.block-editor-publish-date-time-picker__header { | ||
margin-bottom: 1em; | ||
} | ||
|
||
.block-editor-publish-date-time-picker__heading { | ||
font-size: $default-font-size; | ||
margin: 0; | ||
} | ||
|
||
.block-editor-publish-date-time-picker__reset { | ||
height: $icon-size; | ||
margin: 0; | ||
text-decoration: underline; | ||
} | ||
|
||
[class].block-editor-publish-date-time-picker__close { | ||
height: $icon-size; | ||
min-width: $icon-size; | ||
padding: 0; | ||
} |
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
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
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
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
Oops, something went wrong.