From 9e903fe9093c6e8374ec51349745a05a20d72421 Mon Sep 17 00:00:00 2001 From: CatsJuice Date: Tue, 5 Nov 2024 07:47:57 +0000 Subject: [PATCH] fix(component): optimize stack notification with different height (#8700) ![CleanShot 2024-11-05 at 09.10.54.gif](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/LakojjjzZNf6ogjOVwKE/ed74d2ad-3044-4df3-9207-69a891435ea3.gif) --- .../desktop/notification-center.tsx | 17 ++-- .../src/ui/notification/desktop/styles.css.ts | 9 ++- .../notification-center.stories.tsx | 77 +++++++++++++++++++ 3 files changed, 92 insertions(+), 11 deletions(-) diff --git a/packages/frontend/component/src/ui/notification/desktop/notification-center.tsx b/packages/frontend/component/src/ui/notification/desktop/notification-center.tsx index f40db359e..185e0243d 100644 --- a/packages/frontend/component/src/ui/notification/desktop/notification-center.tsx +++ b/packages/frontend/component/src/ui/notification/desktop/notification-center.tsx @@ -4,6 +4,14 @@ import { type CSSProperties, useMemo } from 'react'; import { Toaster } from 'sonner'; import type { NotificationCenterProps } from '../types'; +import { cardWrapper } from './styles.css'; + +const toastOptions = { + style: { + width: '100%', + }, + className: cardWrapper, +}; export function DesktopNotificationCenter({ width = 380, @@ -21,15 +29,6 @@ export function DesktopNotificationCenter({ } satisfies CSSProperties; }, [width]); - const toastOptions = useMemo( - () => ({ - style: { - width: '100%', - }, - }), - [] - ); - return ( { ); }; + +export const DifferentSize: StoryFn = () => { + const openTiny = () => { + notify({ title: 'Tiny' }, { duration: 60000 }); + }; + const openNormal = () => + notify( + { + title: 'Normal Size', + message: 'With basic title and one line message', + }, + { duration: 60000 } + ); + + const openLarge = () => { + notify( + { + title: 'Large Size', + message: ( +
+

Large Size

+

+ With long title and long message to test the size of the + notification; The content may be multiline and the card will be + larger. +

+
+ ), + }, + { duration: 60000 } + ); + }; + const openWithThumb = () => { + notify( + { + thumb: ( +
+ Hack thumb +
+ ), + title: 'Card with thumb', + message: 'With basic title and one line message', + }, + { duration: 60000 } + ); + }; + const openWithFooter = () => { + notify( + { + title: 'With footer', + message: 'With basic title and one line message', + footer: ( + + ), + }, + { duration: 60000 } + ); + }; + return ( + + + + + + + + ); +};