@@ -32,26 +32,44 @@ export const ToastTrigger = (props: ToasterProps) => {
3232 // Show toast using Sonner - Sonner handles deduplication via ID automatically
3333 const duration = props . timeout || 2000
3434 const showCloseButton = duration > 5000
35+ const showLoadingIcon = duration > 2000
3536
3637 if ( typeof props . message === 'string' ) {
37- const toastId = toast ( props . message , {
38- id : props . id ,
39- unstyled : true ,
40- duration,
41- closeButton : showCloseButton ,
42- onDismiss : ( ) => {
43- props . handleHide && props . handleHide ( )
44- } ,
45- onAutoClose : ( ) => {
46- props . handleHide && props . handleHide ( )
38+ const toastId = toast . custom (
39+ ( ) => (
40+ < div >
41+ { showLoadingIcon && (
42+ < span className = "spinner-border spinner-border-sm me-2" role = "status" >
43+ < span className = "visually-hidden" > Loading...</ span >
44+ </ span >
45+ ) }
46+ { props . message }
47+ </ div >
48+ ) ,
49+ {
50+ id : props . id ,
51+ unstyled : true ,
52+ duration,
53+ closeButton : showCloseButton ,
54+ onDismiss : ( ) => {
55+ props . handleHide && props . handleHide ( )
56+ } ,
57+ onAutoClose : ( ) => {
58+ props . handleHide && props . handleHide ( )
59+ }
4760 }
48- } )
61+ )
4962 console . log ( 'toastId' , toastId , props . id )
5063 } else {
5164 // For JSX elements, use toast.custom
5265 const toastId = toast . custom (
5366 ( ) => (
54- < div className = "remixui_sonner_toast alert alert-info bg-light" >
67+ < div >
68+ { showLoadingIcon && (
69+ < span className = "spinner-border spinner-border-sm me-2" role = "status" >
70+ < span className = "visually-hidden" > Loading...</ span >
71+ </ span >
72+ ) }
5573 { props . message }
5674 </ div >
5775 ) ,
@@ -104,29 +122,47 @@ export const Toaster = (props: ToasterProps) => {
104122 // Show toast using Sonner
105123 const duration = props . timeout || 2000
106124 const showCloseButton = duration > 5000
125+ const showLoadingIcon = duration > 2000
107126
108127 let toastId : string | number
109128
110129 if ( typeof props . message === 'string' ) {
111-
112- toastId = toast ( props . message , {
113- id : props . id ,
114- unstyled : true ,
115- duration,
116- closeButton : showCloseButton ,
117- onDismiss : ( ) => {
118- props . handleHide && props . handleHide ( )
119- } ,
120- onAutoClose : ( ) => {
121- props . handleHide && props . handleHide ( )
130+
131+ toastId = toast . custom (
132+ ( ) => (
133+ < div className = "remixui_sonner_toast alert alert-info bg-light" >
134+ { showLoadingIcon && (
135+ < span className = "spinner-border spinner-border-sm me-2" role = "status" >
136+ < span className = "visually-hidden" > Loading...</ span >
137+ </ span >
138+ ) }
139+ { props . message }
140+ </ div >
141+ ) ,
142+ {
143+ id : props . id ,
144+ unstyled : true ,
145+ duration,
146+ closeButton : showCloseButton ,
147+ onDismiss : ( ) => {
148+ props . handleHide && props . handleHide ( )
149+ } ,
150+ onAutoClose : ( ) => {
151+ props . handleHide && props . handleHide ( )
152+ }
122153 }
123- } )
154+ )
124155 console . log ( 'toastId' , toastId , props . id )
125156 } else {
126157 // For JSX elements, use toast.custom
127158 toastId = toast . custom (
128159 ( ) => (
129160 < div className = "remixui_sonner_toast alert alert-info bg-light" >
161+ { showLoadingIcon && (
162+ < span className = "spinner-border spinner-border-sm me-2" role = "status" >
163+ < span className = "visually-hidden" > Loading...</ span >
164+ </ span >
165+ ) }
130166 { props . message }
131167 </ div >
132168 ) ,
0 commit comments