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.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.tsx')
-rw-r--r-- | src/components/Toast/index.tsx | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/components/Toast/index.tsx b/src/components/Toast/index.tsx index 0d1c661d2..d70a8ad16 100644 --- a/src/components/Toast/index.tsx +++ b/src/components/Toast/index.tsx @@ -6,15 +6,15 @@ import {toast as sonner, Toaster} from 'sonner-native' import {atoms as a} from '#/alf' import {DURATION} from '#/components/Toast/const' import { - Default as DefaultToast, + Icon as ToastIcon, Outer as BaseOuter, - type ToastComponentProps, + Text as ToastText, ToastConfigProvider, } from '#/components/Toast/Toast' import {type BaseToastOptions} from '#/components/Toast/types' export {DURATION} from '#/components/Toast/const' -export {Action, Icon, Text} from '#/components/Toast/Toast' +export {Action, Icon, Text, ToastConfigProvider} from '#/components/Toast/Toast' export {type ToastType} from '#/components/Toast/types' /** @@ -25,27 +25,10 @@ export function ToastOutlet() { return <Toaster pauseWhenPageIsHidden gap={a.gap_sm.gap} /> } -/** - * The toast UI component - */ -export function Default({type, content}: ToastComponentProps) { +export function Outer({children}: {children: React.ReactNode}) { return ( <View style={[a.px_xl, a.w_full]}> - <DefaultToast content={content} type={type} /> - </View> - ) -} - -export function Outer({ - children, - type = 'default', -}: { - children: React.ReactNode - type?: ToastComponentProps['type'] -}) { - return ( - <View style={[a.px_xl, a.w_full]}> - <BaseOuter type={type}>{children}</BaseOuter> + <BaseOuter>{children}</BaseOuter> </View> ) } @@ -60,14 +43,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.custom( - <ToastConfigProvider id={id}> - <Default content={content} type={type} /> + <ToastConfigProvider id={id} type={type}> + <Outer> + <ToastIcon /> + <ToastText>{content}</ToastText> + </Outer> </ToastConfigProvider>, { ...options, @@ -77,7 +63,9 @@ export function show( ) } else if (React.isValidElement(content)) { sonner.custom( - <ToastConfigProvider id={id}>{content}</ToastConfigProvider>, + <ToastConfigProvider id={id} type={type}> + {content} + </ToastConfigProvider>, { ...options, id, |