diff options
author | Eric Bailey <git@esb.lol> | 2025-08-26 16:54:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-26 16:54:43 -0500 |
commit | 9f7c920346f3e650f530930cd22ca241fc6cbd7f (patch) | |
tree | 8b93e3b299030379d2af425cd825196199fffe7f /src/components/Toast/index.web.tsx | |
parent | 0555d3623cf5eea744bd26b4343c60ec66e43aa3 (diff) | |
download | voidsky-9f7c920346f3e650f530930cd22ca241fc6cbd7f.tar.zst |
Fix toast type (#8909)
* Fix confusing toast API * Provide all exports to e2e file * Fix first usage in Composer * Loosen type, add Trans tag
Diffstat (limited to 'src/components/Toast/index.web.tsx')
-rw-r--r-- | src/components/Toast/index.web.tsx | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/components/Toast/index.web.tsx b/src/components/Toast/index.web.tsx index c4db20dca..8b2028db9 100644 --- a/src/components/Toast/index.web.tsx +++ b/src/components/Toast/index.web.tsx @@ -5,7 +5,9 @@ import {toast as sonner, Toaster} from 'sonner' import {atoms as a} from '#/alf' import {DURATION} from '#/components/Toast/const' import { - Default as DefaultToast, + Icon as ToastIcon, + Outer as ToastOuter, + Text as ToastText, ToastConfigProvider, } from '#/components/Toast/Toast' import {type BaseToastOptions} from '#/components/Toast/types' @@ -39,14 +41,17 @@ export const api = sonner */ export function show( content: React.ReactNode, - {type, ...options}: BaseToastOptions = {}, + {type = 'default', ...options}: BaseToastOptions = {}, ) { const id = nanoid() if (typeof content === 'string') { sonner( - <ToastConfigProvider id={id}> - <DefaultToast content={content} type={type} /> + <ToastConfigProvider id={id} type={type}> + <ToastOuter> + <ToastIcon /> + <ToastText>{content}</ToastText> + </ToastOuter> </ToastConfigProvider>, { ...options, @@ -56,12 +61,17 @@ export function show( }, ) } else if (React.isValidElement(content)) { - sonner(<ToastConfigProvider id={id}>{content}</ToastConfigProvider>, { - ...options, - unstyled: true, // required on web - id, - duration: options?.duration ?? DURATION, - }) + sonner( + <ToastConfigProvider id={id} type={type}> + {content} + </ToastConfigProvider>, + { + ...options, + unstyled: true, // required on web + id, + duration: options?.duration ?? DURATION, + }, + ) } else { throw new Error( `Toast can be a string or a React element, got ${typeof content}`, |