From 1db8a4a80ab5660fa0702029ea4ac91321b60f68 Mon Sep 17 00:00:00 2001 From: Andrew Holloway Date: Tue, 26 Mar 2024 10:21:01 -0500 Subject: [PATCH] feat(Toast)!: introduce 2.0 component - unmark as deprecated - add tests and 2.0 version --- .../BannerNotification.module.css | 3 - .../BannerNotification/BannerNotification.tsx | 6 +- src/components/Toast/Toast-v2.module.css | 35 ++++++ src/components/Toast/Toast-v2.stories.ts | 39 +++++++ src/components/Toast/Toast-v2.test.ts | 8 ++ src/components/Toast/Toast-v2.tsx | 103 ++++++++++++++++++ .../Toast/__snapshots__/Toast-v2.test.ts.snap | 100 +++++++++++++++++ 7 files changed, 288 insertions(+), 6 deletions(-) create mode 100644 src/components/Toast/Toast-v2.module.css create mode 100644 src/components/Toast/Toast-v2.stories.ts create mode 100644 src/components/Toast/Toast-v2.test.ts create mode 100644 src/components/Toast/Toast-v2.tsx create mode 100644 src/components/Toast/__snapshots__/Toast-v2.test.ts.snap diff --git a/src/components/BannerNotification/BannerNotification.module.css b/src/components/BannerNotification/BannerNotification.module.css index 566143f22..4b62c1158 100644 --- a/src/components/BannerNotification/BannerNotification.module.css +++ b/src/components/BannerNotification/BannerNotification.module.css @@ -8,9 +8,6 @@ * Message of information, success, caution, or warning to the user. */ .banner { - /* Position is relative to allow for absolute-positioned close button. */ - position: relative; - /* Grid is used to separate the icon from the text with correct spacing. */ display: flex; gap: 1rem; padding: 1rem; diff --git a/src/components/BannerNotification/BannerNotification.tsx b/src/components/BannerNotification/BannerNotification.tsx index bdb28bcd9..a6272a727 100644 --- a/src/components/BannerNotification/BannerNotification.tsx +++ b/src/components/BannerNotification/BannerNotification.tsx @@ -21,7 +21,7 @@ export type BannerNotificationProps = { */ className?: string; /** - * Callback when banner is dismissed. When passed in, renders banner with a close icon in the top right. + * Callback when notification is dismissed. When passed in, renders banner with a close icon in the top right. */ onDismiss?: () => void; // Design API @@ -42,7 +42,7 @@ export type BannerNotificationProps = { */ subTitle?: string; /** - * The title/heading of the banner + * The title/heading of the notification */ title?: string; }; @@ -125,7 +125,7 @@ export const BannerNotification = ({ )} - + {/* TODO-AH: Use `Button` properly */} {onDismiss && ( + )} + + ); +}; diff --git a/src/components/Toast/__snapshots__/Toast-v2.test.ts.snap b/src/components/Toast/__snapshots__/Toast-v2.test.ts.snap new file mode 100644 index 000000000..9c242381b --- /dev/null +++ b/src/components/Toast/__snapshots__/Toast-v2.test.ts.snap @@ -0,0 +1,100 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` (v2) Error story renders snapshot 1`] = ` +
+
+ + + error + + + +

+ You've got toast! +

+
+
+`; + +exports[` (v2) NotDismissable story renders snapshot 1`] = ` +
+
+ + + success + + + +

+ You've got toast! +

+
+
+`; + +exports[` (v2) Success story renders snapshot 1`] = ` +
+
+ + + success + + + +

+ You've got toast! +

+
+
+`;