File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,14 @@ const toastId = toast('Event has been created');
207
207
toast .dismiss (toastId);
208
208
```
209
209
210
+ You can also use the dismiss method without the id to dismiss all toasts.
211
+
212
+ ``` jsx
213
+ // Removes all toasts
214
+
215
+ toast .dismiss ();
216
+ ```
217
+
210
218
## Keyboard focus
211
219
212
220
You can focus on the toast area by pressing ⌥/alt + T. You can override it by providing an array of event.code values for each key.
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ let toastsCounter = 0;
5
5
6
6
class Observer {
7
7
subscribers : Array < ( toast : ExternalToast | ToastToDismiss ) => void > ;
8
+ toasts : Array < ToastT | ToastToDismiss > ;
8
9
9
10
constructor ( ) {
10
11
this . subscribers = [ ] ;
12
+ this . toasts = [ ] ;
11
13
}
12
14
13
15
// We use arrow functions to maintain the correct `this` reference
@@ -22,9 +24,16 @@ class Observer {
22
24
23
25
publish = ( data : ToastT ) => {
24
26
this . subscribers . forEach ( ( subscriber ) => subscriber ( data ) ) ;
27
+ this . toasts = [ ...this . toasts , data ] ;
25
28
} ;
26
29
27
- dismiss = ( id : number ) => {
30
+ dismiss = ( id ?: number ) => {
31
+ if ( ! id ) {
32
+ this . toasts . forEach ( ( toast ) => {
33
+ this . subscribers . forEach ( ( subscriber ) => subscriber ( { id : toast . id , dismiss : true } ) ) ;
34
+ } ) ;
35
+ }
36
+
28
37
this . subscribers . forEach ( ( subscriber ) => subscriber ( { id, dismiss : true } ) ) ;
29
38
return id ;
30
39
} ;
Original file line number Diff line number Diff line change 277
277
}
278
278
279
279
[data-sonner-toast ][data-removed = 'true' ][data-front = 'false' ][data-swipe-out = 'false' ][data-expanded = 'false' ] {
280
+ --y : translateY (40% );
280
281
opacity : 0 ;
282
+ transition : transform 500ms , opacity 200ms ;
281
283
}
282
284
283
285
/* Bump up the height to make sure hover state doesn't get set to false */
You can’t perform that action at this time.
0 commit comments