-
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.
Editor: Extract snackbars into a separate component (#33355)
* Add notices container to InterfaceSkeleton. * Move the `EditorSnackbars` component to the notices container.
- Loading branch information
1 parent
d95ef3c
commit 1c20923
Showing
6 changed files
with
45 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { filter } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SnackbarList } from '@wordpress/components'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { store as noticesStore } from '@wordpress/notices'; | ||
|
||
export default function EditorSnackbars() { | ||
const notices = useSelect( | ||
( select ) => select( noticesStore ).getNotices(), | ||
[] | ||
); | ||
const { removeNotice } = useDispatch( noticesStore ); | ||
const snackbarNotices = filter( notices, { | ||
type: 'snackbar', | ||
} ); | ||
|
||
return ( | ||
<SnackbarList | ||
notices={ snackbarNotices } | ||
className="components-editor-notices__snackbar" | ||
onRemove={ removeNotice } | ||
/> | ||
); | ||
} |
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