-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a global save button to the site editor (#47142)
- Loading branch information
1 parent
b13b4a5
commit 7d8946d
Showing
13 changed files
with
166 additions
and
98 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button, Modal } from '@wordpress/components'; | ||
import { EntitiesSavedStates } from '@wordpress/editor'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { NavigableRegion } from '@wordpress/interface'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../store'; | ||
import { unlock } from '../../experiments'; | ||
|
||
export default function SavePanel() { | ||
const { isSaveViewOpen, canvasMode } = useSelect( ( select ) => { | ||
const { isSaveViewOpened, getCanvasMode } = unlock( | ||
select( editSiteStore ) | ||
); | ||
|
||
// The currently selected entity to display. | ||
// Typically template or template part in the site editor. | ||
return { | ||
isSaveViewOpen: isSaveViewOpened(), | ||
canvasMode: getCanvasMode(), | ||
}; | ||
}, [] ); | ||
const { setIsSaveViewOpened } = useDispatch( editSiteStore ); | ||
const onClose = () => setIsSaveViewOpened( false ); | ||
|
||
if ( canvasMode === 'view' ) { | ||
return isSaveViewOpen ? ( | ||
<Modal | ||
className="edit-site-save-panel__modal" | ||
onRequestClose={ onClose } | ||
__experimentalHideHeader | ||
> | ||
<EntitiesSavedStates close={ onClose } /> | ||
</Modal> | ||
) : null; | ||
} | ||
|
||
return ( | ||
<NavigableRegion | ||
className="edit-site-layout__actions" | ||
ariaLabel={ __( 'Save sidebar' ) } | ||
> | ||
{ isSaveViewOpen ? ( | ||
<EntitiesSavedStates close={ onClose } /> | ||
) : ( | ||
<div className="edit-site-editor__toggle-save-panel"> | ||
<Button | ||
variant="secondary" | ||
className="edit-site-editor__toggle-save-panel-button" | ||
onClick={ () => setIsSaveViewOpened( true ) } | ||
aria-expanded={ false } | ||
> | ||
{ __( 'Open save panel' ) } | ||
</Button> | ||
</div> | ||
) } | ||
</NavigableRegion> | ||
); | ||
} |
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,5 @@ | ||
.edit-site-save-panel__modal { | ||
@include break-small() { | ||
width: 600px; | ||
} | ||
} |
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.