-
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.
Showing
11 changed files
with
140 additions
and
144 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
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
64 changes: 23 additions & 41 deletions
64
packages/edit-post/src/components/sidebar/post-schedule/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 |
---|---|---|
@@ -1,57 +1,39 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { PanelBody } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { Button, Dropdown, PanelRow } from '@wordpress/components'; | ||
import { | ||
PostSchedule as PostScheduleForm, | ||
PostScheduleCheck, | ||
PostScheduleLabel, | ||
} from '@wordpress/editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
const PANEL_NAME = 'schedule'; | ||
|
||
export default function PostSchedule() { | ||
const { isOpened, isRemoved } = useSelect( ( select ) => { | ||
// We use isEditorPanelRemoved to hide the panel if it was | ||
// programatically removed. We don't use isEditorPanelEnabled since | ||
// this panel should not be disabled through the UI. | ||
const { isEditorPanelRemoved, isEditorPanelOpened } = select( | ||
'core/edit-post' | ||
); | ||
|
||
return { | ||
isOpened: isEditorPanelOpened( PANEL_NAME ), | ||
isRemoved: isEditorPanelRemoved( PANEL_NAME ), | ||
}; | ||
}, [] ); | ||
|
||
const { toggleEditorPanelOpened } = useDispatch( 'core/edit-post' ); | ||
|
||
if ( isRemoved ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<PostScheduleCheck> | ||
<PanelBody | ||
initialOpen={ false } | ||
opened={ isOpened } | ||
onToggle={ () => { | ||
toggleEditorPanelOpened( PANEL_NAME ); | ||
} } | ||
title={ | ||
<> | ||
{ __( 'Publish:' ) } | ||
<span className="editor-post-publish-panel__link"> | ||
<PostScheduleLabel /> | ||
</span> | ||
</> | ||
} | ||
> | ||
<PostScheduleForm /> | ||
</PanelBody> | ||
<PanelRow className="edit-post-post-schedule"> | ||
<> | ||
{ __( 'Publish date:' ) }{ ' ' } | ||
<span className="edit-post-post-schedule__current-value"> | ||
<PostScheduleLabel /> | ||
</span> | ||
<Dropdown | ||
position="bottom left" | ||
contentClassName="edit-post-post-schedule__dialog" | ||
renderToggle={ ( { onToggle, isOpen } ) => ( | ||
<Button | ||
onClick={ onToggle } | ||
aria-expanded={ isOpen } | ||
isTertiary | ||
> | ||
{ __( 'Edit publish date' ) } | ||
</Button> | ||
) } | ||
renderContent={ () => <PostScheduleForm /> } | ||
/> | ||
</> | ||
</PanelRow> | ||
</PostScheduleCheck> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/edit-post/src/components/sidebar/post-schedule/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,8 @@ | ||
.edit-post-post-schedule { | ||
display: block; | ||
} | ||
|
||
.edit-post-post-schedule__current-value { | ||
font-weight: 500; | ||
margin-right: $grid-unit; | ||
} |
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.