@@ -17,7 +17,7 @@ const handleClick = btn => {
17
17
selected = btn .name
18
18
code = btn .code
19
19
btn .run ()
20
- gtag (' event' , ' toast' , { event_label : btn .name } )
20
+ gtag (' event' , ` toast: ${ camelCase ( btn .name ) } ` )
21
21
}
22
22
23
23
const buttons = [
@@ -85,10 +85,7 @@ toast.pop()
85
85
86
86
// Or remove a particular one
87
87
const id = toast.push('Yo!')
88
- toast.pop(id)
89
-
90
- // Or remove all active toasts
91
- toast.pop(0)` ,
88
+ toast.pop(id)` ,
92
89
run : () => {
93
90
toast .pop ()
94
91
}
@@ -188,9 +185,47 @@ toast.set(id, { progress: 1 })`,
188
185
await tick ()
189
186
toast .push (' All themes reset!' )
190
187
}
188
+ },
189
+ {
190
+ name: ' CREATE NEW TOAST CONTAINER' ,
191
+ code: ` <style>
192
+ .wrap {
193
+ --toastContainerTop: 0.5rem;
194
+ --toastContainerRight: 2rem;
195
+ --toastContainerBottom: auto;
196
+ --toastContainerLeft: 2rem;
197
+ --toastWidth: 100%;
198
+ --toastMinHeight: 1.5rem;
199
+ --toastBackground: rgba(59,130,246,0.95);
200
+ --toastMsgPadding: 0.25rem 0.5rem;
201
+ font-size: 0.875rem;
202
+ }
203
+ </style>
204
+
205
+ <div class="wrap">
206
+ <SvelteToast target="new" options={{ initial: 0, intro: { y: -64 } }} />
207
+ </div>
208
+
209
+ <script>
210
+ // Send toast to "new" container
211
+ toast.push('NEW: Multiple toast container support', { target: 'new' })
212
+ <\/ script>` , // eslint-disable-line no-useless-escape
213
+ run : () => {
214
+ toast .push (' NEW: Multiple toast container support' , { target: ' new' })
215
+ }
216
+ },
217
+ {
218
+ name: ' REMOVE ALL TOASTS FROM CONTAINER' ,
219
+ code: ` // Remove all toasts from "new" container
220
+ toast.pop(i => i.target !== 'new')
221
+
222
+ // Or remove ALL active toasts from ALL containers
223
+ toast.pop(0)` ,
224
+ run : () => {
225
+ toast .pop (i => i .target !== ' new' )
226
+ }
191
227
}
192
228
]
193
-
194
229
</script >
195
230
196
231
<style >
@@ -205,6 +240,17 @@ toast.set(id, { progress: 1 })`,
205
240
--toastContainerBottom : 8rem ;
206
241
--toastContainerLeft : calc (50vw - 8rem );
207
242
}
243
+ .top {
244
+ --toastContainerTop : 0.5rem ;
245
+ --toastContainerRight : 2rem ;
246
+ --toastContainerBottom : auto ;
247
+ --toastContainerLeft : 2rem ;
248
+ --toastWidth : 100% ;
249
+ --toastMinHeight : 1.5rem ;
250
+ --toastBackground : rgba (59 ,130 ,246 ,0.95 );
251
+ --toastMsgPadding : 0.25rem 0.5rem ;
252
+ font-size : 0.875rem ;
253
+ }
208
254
</style >
209
255
210
256
<div class =" container" >
@@ -220,13 +266,18 @@ toast.set(id, { progress: 1 })`,
220
266
<button
221
267
class:selected ={selected === btn .name }
222
268
on:click ={() => { handleClick (btn ) }}
223
- data-btn ={camelCase (btn .name )}
224
- >{btn .name }</button >
269
+ data-btn ={camelCase (btn .name )}>
270
+ {btn .name }
271
+ </button >
225
272
{/each }
226
273
227
274
</div >
228
275
</div >
229
276
277
+ <div class =" top" >
278
+ <SvelteToast options ={{ initial : 0 , intro : { y : - 64 } }} target =" new" />
279
+ </div >
280
+
230
281
<div class:colors class:bottom >
231
282
<SvelteToast {options } />
232
283
</div >
0 commit comments