Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Update notice type
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Mar 10, 2023
1 parent 9fec361 commit 28df6f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
16 changes: 11 additions & 5 deletions assets/js/base/components/snackbar-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type SnackbarListProps = {
// Class name to be added to the container.
className?: string | undefined;
// List of notices to be rendered.
notices: Partial< NoticeType >[];
notices: NoticeType[];
// Callback to be called when a notice is dismissed.
onRemove: ( id: string ) => void;
};
Expand Down Expand Up @@ -50,16 +50,22 @@ const SnackbarList = ( {
{ notices.map( ( notice ) => {
const { content, ...restNotice } = notice;

return (
return isReducedMotion ? (
<Snackbar
{ ...restNotice }
onRemove={ removeNotice( notice ) }
listRef={ listRef }
>
{ notice.content }
</Snackbar>
) : (
<motion.div
layout={ ! isReducedMotion }
initial={ 'init' }
animate={ 'open' }
exit={ 'exit' }
key={ notice.id }
variants={
isReducedMotion ? undefined : SNACKBAR_VARIANTS
}
variants={ SNACKBAR_VARIANTS }
>
<Snackbar
{ ...restNotice }
Expand Down
8 changes: 6 additions & 2 deletions assets/js/types/type-defs/notices.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/**
* External dependencies
*/
import type { Notice, Options } from '@wordpress/notices';
import type { Notice } from '@wordpress/notices';

export interface NoticeType extends Omit< Notice, 'status' >, Options {
export interface NoticeType extends Partial< Omit< Notice, 'status' > > {
id: string;
content: string;
status: 'success' | 'error' | 'info' | 'warning' | 'default';
isDismissible: boolean;
context?: string | undefined;
}

0 comments on commit 28df6f9

Please sign in to comment.