@@ -112,7 +112,7 @@ export namespace INotification {
112
112
* Autoclosing behavior - undefined (not closing automatically)
113
113
* or number (time in milliseconds before closing a toast)
114
114
*/
115
- autoClose ?: number ;
115
+ autoClose ?: number | false ;
116
116
}
117
117
118
118
/**
@@ -154,8 +154,7 @@ export namespace INotification {
154
154
async function createToast (
155
155
message : React . ReactNode ,
156
156
buttons ?: IButton [ ] ,
157
- options ?: ToastOptions ,
158
- icon ?: JSX . Element
157
+ options ?: ToastOptions
159
158
) : Promise < React . ReactText > {
160
159
let _resolve : ( value : React . ReactText ) => void ;
161
160
const toast = await Private . toast ( ) ;
@@ -169,10 +168,11 @@ export namespace INotification {
169
168
message ,
170
169
closeToast ,
171
170
buttons ,
172
- icon || Private . type2Icon . get ( theOptions . type )
171
+ Private . type2Icon . get ( theOptions . type || "in-progress" )
173
172
) ,
174
173
{
175
174
...options ,
175
+ className : `jp-toast-${ theOptions . type || "in-progress" } ` ,
176
176
onOpen : ( ) => _resolve ( toastId )
177
177
}
178
178
) ;
@@ -194,7 +194,6 @@ export namespace INotification {
194
194
) : Promise < React . ReactText > => {
195
195
return createToast ( message , options && options . buttons , {
196
196
type : "error" ,
197
- className : "jp-toast-error" ,
198
197
autoClose : ( options && options . autoClose ) || false
199
198
} ) ;
200
199
} ;
@@ -212,7 +211,6 @@ export namespace INotification {
212
211
) : Promise < React . ReactText > => {
213
212
return createToast ( message , options && options . buttons , {
214
213
type : "warning" ,
215
- className : "jp-toast-warning" ,
216
214
autoClose : ( options && options . autoClose ) || false
217
215
} ) ;
218
216
} ;
@@ -236,7 +234,6 @@ export namespace INotification {
236
234
( buttons && buttons . length > 0 ? false : undefined ) ;
237
235
return createToast ( message , buttons , {
238
236
type : "info" ,
239
- className : "jp-toast-info" ,
240
237
autoClose : autoClose
241
238
} ) ;
242
239
} ;
@@ -260,7 +257,6 @@ export namespace INotification {
260
257
( buttons && buttons . length > 0 ? false : undefined ) ;
261
258
return createToast ( message , buttons , {
262
259
type : "success" ,
263
- className : "jp-toast-success" ,
264
260
autoClose : autoClose
265
261
} ) ;
266
262
} ;
@@ -277,21 +273,9 @@ export namespace INotification {
277
273
message : React . ReactNode ,
278
274
options ?: IOptions
279
275
) : Promise < React . ReactText > => {
280
- return createToast (
281
- message ,
282
- options && options . buttons ,
283
- {
284
- type : "default" ,
285
- className : "jp-toast-inprogress" ,
286
- autoClose : ( options && options . autoClose ) || false
287
- } ,
288
- < FontAwesomeIcon
289
- icon = { faSpinner }
290
- pull = "left"
291
- spin
292
- style = { { color : "var(--jp-inverse-layout-color3)" } }
293
- />
294
- ) ;
276
+ return createToast ( message , options && options . buttons , {
277
+ autoClose : ( options && options . autoClose ) || false
278
+ } ) ;
295
279
} ;
296
280
297
281
/** Options needed to update an existing toast */
@@ -341,7 +325,8 @@ export namespace INotification {
341
325
args . message ,
342
326
closeToast ,
343
327
args . buttons ,
344
- Private . type2Icon . get ( options . type )
328
+ // If not type specified, assumes it is `in progress`
329
+ Private . type2Icon . get ( options . type || "in-progress" )
345
330
)
346
331
} ) ;
347
332
} else {
@@ -350,9 +335,7 @@ export namespace INotification {
350
335
// If not type specified, assumes it is `in progress`
351
336
const newOptions : ToastOptions = {
352
337
autoClose : false ,
353
- className : "jp-toast-inprogress" ,
354
338
toastId : args . toastId ,
355
- type : "default" ,
356
339
...options
357
340
} ;
358
341
@@ -467,8 +450,17 @@ interface IToast {
467
450
}
468
451
469
452
namespace Private {
470
- export const type2Icon = new Map < TypeOptions , JSX . Element > ( [
453
+ export const type2Icon = new Map < TypeOptions | "in-progress" , JSX . Element > ( [
471
454
[ "default" , null ] ,
455
+ [
456
+ "in-progress" ,
457
+ < FontAwesomeIcon
458
+ icon = { faSpinner }
459
+ pull = "left"
460
+ spin
461
+ style = { { color : "var(--jp-inverse-layout-color3)" } }
462
+ />
463
+ ] ,
472
464
[
473
465
"error" ,
474
466
< FontAwesomeIcon
0 commit comments