From a7b61c0d4569db4324d8308cb7a90b4fa9f17acb Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 26 Jul 2025 13:25:09 -0700 Subject: [PATCH] [Design System] `Toast` supports `actions` - Add an optional prop to the existing `toast` object. - `actions` is typed as a one-tuple or two-tuple (accepting either one CTA or two). Each item must be a React node, allowing composition. - If `title` is not specified, the single-line design is used. The `message` is truncated, while actions and icon remain full-width. --- packages/ui/src/components/Toast.tsx | 137 ++++++++++++++++++++++---- packages/ui/stories/Toast.stories.tsx | 100 +++++++++++++++++++ 2 files changed, 218 insertions(+), 19 deletions(-) diff --git a/packages/ui/src/components/Toast.tsx b/packages/ui/src/components/Toast.tsx index 76a8af735..ca25d51bd 100644 --- a/packages/ui/src/components/Toast.tsx +++ b/packages/ui/src/components/Toast.tsx @@ -1,9 +1,10 @@ 'use client'; -import { ReactNode } from 'react'; +import React from 'react'; import { LuCircleAlert, LuCircleCheck, LuX } from 'react-icons/lu'; import { Toaster as Sonner, toast as sonnerToast } from 'sonner'; +import { cn } from '../lib/utils'; import { Button } from './Button'; export const Toast = () => { @@ -15,9 +16,13 @@ export const Toast = () => { visibleToasts={3} duration={3000} icons={{ - success: , - close: , - error: , + success: ( + + ), + close: , + error: ( + + ), }} toastOptions={{ classNames: { @@ -39,13 +44,20 @@ const ToastWrapper = ({ id, dismissable = false, children, + isSingleLine = false, }: { id: string | number; dismissable?: boolean; children: React.ReactNode; + isSingleLine?: boolean; }) => { return ( -
+
{children} {dismissable && (
); + +export const ToastWithActions = () => ( +
+ +
+ ], + }) + } + > + Toast with One Action + + + , + , + ], + }) + } + > + Toast with Two Actions + +
+
+); + +export const SingleLineToasts = () => ( +
+ +
+ , + ], + }) + } + > + Single Line Success with Action + + + , + , + ], + }) + } + > + Single Line Success with Two Actions + + + + + +
+
+);