-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Design updates to the Publish popover (DateTimePicker)
#41097
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9dd249d
Re-organise date-time dir to have component subdirs
noisysocks 8337339
Update design of DateTimePicker and convert to Emotion
noisysocks f7e9d5d
Add deprecated warning for when __nextRemoveHelpButton and __nextRemo…
noisysocks 845c91a
Target component instead of classname
noisysocks 4214131
Use space() instead of hardcoded widths
noisysocks 82779ca
Update CSS selectors used in E2E tests
noisysocks 353b9a2
Update changelog
noisysocks cbe79b0
Update scheduling e2e test
noisysocks d93ff2b
Use relative URLs in README.md
noisysocks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 ) } | ||
ramonjd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| > | ||
| { __( '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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.