Skip to content
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

Add standard notices to nav menu page #22374

Merged
merged 3 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions packages/edit-navigation/src/components/notices/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
/**
* External dependencies
*/
import { filter } from 'lodash';

/**
* WordPress dependencies
*/
import { NoticeList, SnackbarList } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { SnackbarList } from '@wordpress/components';

export default function Notices() {
export default function EditNavigationNotices() {
const { removeNotice } = useDispatch( 'core/notices' );
const notices = useSelect(
( select ) =>
select( 'core/notices' )
.getNotices()
.filter( ( notice ) => notice.type === 'snackbar' ),
( select ) => select( 'core/notices' ).getNotices(),
[]
);
const { removeNotice } = useDispatch( 'core/notices' );
const dismissibleNotices = filter( notices, {
isDismissible: true,
type: 'default',
} );
const nonDismissibleNotices = filter( notices, {
isDismissible: false,
type: 'default',
} );
const snackbarNotices = filter( notices, {
type: 'snackbar',
} );

return (
<SnackbarList
className="edit-navigation-notices"
notices={ notices }
onRemove={ removeNotice }
/>
<>
<NoticeList
notices={ nonDismissibleNotices }
className="edit-navigation-notices__notice-list"
/>
<NoticeList
notices={ dismissibleNotices }
className="edit-navigation-notices__notice-list"
onRemove={ removeNotice }
/>
<SnackbarList
notices={ snackbarNotices }
className="edit-navigation-notices__snackbar-list"
onRemove={ removeNotice }
/>
</>
);
}
23 changes: 22 additions & 1 deletion packages/edit-navigation/src/components/notices/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
.components-snackbar-list.edit-navigation-notices {
.edit-navigation-notices__snackbar-list {
position: fixed;
bottom: 20px;
}

.edit-navigation-notices__notice-list {
// The page has a 10px left margin at narrower widths, reverse that so that the notice sits flush.
margin-left: -10px;

@include break-medium {
// The page has a 20px left margin at wider widths, reverse that so that the notice sits flush.
margin-left: -20px;
}

// Notices have some unusual margin and padding by default, reset that.
.components-notice {
margin: 0;
padding-right: 12px;

// Make sure the close button is centered.
.components-button {
align-self: initial;
}
}
}