1
1
<script >
2
+ /* eslint no-useless-escape: "off"*/
2
3
import { tick } from ' svelte'
3
4
import { SvelteToast , toast } from ' ../src'
4
5
import Prism from ' ./Prism.svelte'
@@ -24,7 +25,7 @@ const handleClick = (btn) => {
24
25
const buttons = [
25
26
{
26
27
name: ' DEFAULT' ,
27
- code: ` toast.push('Hello world!')` , // eslint-disable-line quotes
28
+ code: ` toast.push('Hello world!')` ,
28
29
run : () => {
29
30
toast .push (' Hello world!' )
30
31
}
@@ -34,12 +35,12 @@ const buttons = [
34
35
code: ` toast.push('Success!', {
35
36
theme: {
36
37
'--toastBackground': '#48BB78',
37
- '--toastProgressBackground ': '#2F855A'
38
+ '--toastBarBackground ': '#2F855A'
38
39
}
39
40
})` ,
40
41
run : () => {
41
42
toast .push (' Success!' , {
42
- theme: { ' --toastBackground' : ' #48BB78' , ' --toastProgressBackground ' : ' #2F855A' }
43
+ theme: { ' --toastBackground' : ' #48BB78' , ' --toastBarBackground ' : ' #2F855A' }
43
44
})
44
45
}
45
46
},
@@ -48,12 +49,12 @@ const buttons = [
48
49
code: ` toast.push('Danger!', {
49
50
theme: {
50
51
'--toastBackground': '#F56565',
51
- '--toastProgressBackground ': '#C53030'
52
+ '--toastBarBackground ': '#C53030'
52
53
}
53
54
})` ,
54
55
run : () => {
55
56
toast .push (' Danger!' , {
56
- theme: { ' --toastBackground' : ' #F56565' , ' --toastProgressBackground ' : ' #C53030' }
57
+ theme: { ' --toastBackground' : ' #F56565' , ' --toastBarBackground ' : ' #C53030' }
57
58
})
58
59
}
59
60
},
@@ -62,14 +63,12 @@ const buttons = [
62
63
code: ` toast.push(\` <strong>You won the jackpot!</strong><br>
63
64
Click <a href="#" target="_blank">here</a> for details! 😛\` )` ,
64
65
run : () => {
65
- toast .push (
66
- ' <strong>You won the jackpot!</strong><br>Click <a href="#" target="_blank">here</a> for details! 😛'
67
- )
66
+ toast .push (' <strong>You won the jackpot!</strong><br>Click <a href="#" target="_blank">here</a> for details! 😛' )
68
67
}
69
68
},
70
69
{
71
70
name: ' LONG DURATION' ,
72
- code: ` toast.push('Watching the paint dry...', { duration: 20000 })` , // eslint-disable-line quotes
71
+ code: ` toast.push('Watching the paint dry...', { duration: 20000 })` ,
73
72
run : () => {
74
73
toast .push (' Watching the paint dry...' , { duration: 20000 })
75
74
}
@@ -150,15 +149,15 @@ toast.set(id, { next: 1 })`,
150
149
name: ' CHANGE DEFAULT COLORS' ,
151
150
code: ` <style>
152
151
:root {
153
- --toastBackground: rgba(255,255,255, 0.95);
152
+ --toastBackground: rgba(245, 208, 254, 0.95);
154
153
--toastColor: #424242;
155
- --toastProgressBackground: aquamarine ;
154
+ --toastBarBackground: fuchsia ;
156
155
}
157
156
</style>
158
157
159
158
<script>
160
159
toast.push('Changed some colors')
161
- <\/ script>` , // eslint-disable-line no-useless-escape
160
+ <\/ script>` ,
162
161
run : () => {
163
162
colors = true
164
163
toast .push (' Changed some colors' )
@@ -179,7 +178,7 @@ toast.set(id, { next: 1 })`,
179
178
180
179
<script>
181
180
toast.push('Bottoms up!')
182
- <\/ script>` , // eslint-disable-line no-useless-escape
181
+ <\/ script>` ,
183
182
run: async () => {
184
183
bottom = true
185
184
options = { reversed: true , intro: { y: 128 } }
@@ -200,30 +199,36 @@ toast.set(id, { next: 1 })`,
200
199
},
201
200
{
202
201
name: ' CREATE NEW TOAST CONTAINER' ,
203
- code: ` <style>
202
+ code: ` <div class="wrap">
203
+ <SvelteToast target="new" options={{ initial: 0, intro: { y: -64 } }} />
204
+ </div>
205
+
206
+ <script>
207
+ // Send toast to "new" container
208
+ toast.push('NEW: Multiple toast container support!', { target: 'new' })
209
+ <\/ script>
210
+
211
+ <style>
204
212
.wrap {
205
213
--toastContainerTop: 0.5rem;
206
- --toastContainerRight: 2rem ;
214
+ --toastContainerRight: 0.5rem ;
207
215
--toastContainerBottom: auto;
208
- --toastContainerLeft: 2rem ;
216
+ --toastContainerLeft: 0.5rem ;
209
217
--toastWidth: 100%;
210
- --toastMinHeight: 1.5rem;
211
- --toastBackground: rgba(59,130,246,0.95);
212
- --toastMsgPadding: 0.25rem 0.5rem;
218
+ --toastMinHeight: 2rem;
219
+ --toastPadding: 0 0.5rem;
213
220
font-size: 0.875rem;
214
221
}
215
- </style>
216
-
217
- <div class="wrap">
218
- <SvelteToast target="new" options={{ initial: 0, intro: { y: -64 } }} />
219
- </div>
220
-
221
- <script>
222
- // Send toast to "new" container
223
- toast.push('NEW: Multiple toast container support', { target: 'new' })
224
- <\/ script>` , // eslint-disable-line no-useless-escape
222
+ @media (min-width: 40rem) {
223
+ .wrap {
224
+ --toastContainerRight: auto;
225
+ --toastContainerLeft: calc(50vw - 20rem);
226
+ --toastWidth: 40rem;
227
+ }
228
+ }
229
+ </style>` ,
225
230
run : () => {
226
- toast .push (' NEW: Multiple toast container support' , { target: ' new' })
231
+ toast .push (' <strong> NEW:</strong> Multiple toast container support! ' , { target: ' new' })
227
232
}
228
233
},
229
234
{
@@ -250,6 +255,7 @@ toast.pop(0)`,
250
255
dismissable: false,
251
256
initial: 0,
252
257
theme: {
258
+ '--toastPadding': '0',
253
259
'--toastMsgPadding': '0'
254
260
}
255
261
})` ,
@@ -260,27 +266,48 @@ toast.pop(0)`,
260
266
props: { title: ' A Dummy Cookie Component' },
261
267
sendIdTo: ' toastId'
262
268
},
269
+ target: ' new' ,
263
270
dismissable: false ,
264
271
initial: 0 ,
265
- theme: { ' --toastMsgPadding' : ' 0' }
272
+ theme: {
273
+ ' --toastPadding' : ' 0' ,
274
+ ' --toastMsgPadding' : ' 0' ,
275
+ ' --toastBackground' : ' transparent' ,
276
+ ' --toastBorderRadius' : ' 1rem'
277
+ }
266
278
})
267
279
}
268
280
},
269
281
{
270
282
name: ' PAUSE ON MOUSE HOVER' ,
271
- code: ` toast.push('Hover me!', { pausable: true })` , // eslint-disable-line
283
+ code: ` toast.push('Hover me!', { pausable: true })` ,
272
284
run : () => {
273
285
toast .push (' Hover me!' , { pausable: true })
274
286
}
287
+ },
288
+ {
289
+ name: ' RUN CALLBACK ON TOAST REMOVAL' ,
290
+ code: ` toast.push('Wait for it...', {
291
+ onpop: () => {
292
+ toast.push('onpop() callback has been executed.', { target: 'new' })
293
+ }
294
+ })` ,
295
+ run : () => {
296
+ toast .push (' Wait for it...' , {
297
+ onpop : () => {
298
+ toast .push (` <strong><tt>onpop()</tt></strong> callback has been executed.` , { target: ' new' })
299
+ }
300
+ })
301
+ }
275
302
}
276
303
]
277
304
</script >
278
305
279
306
<style >
280
307
.colors {
281
- --toastBackground : rgba (255 , 255 , 255 , 0.95 );
308
+ --toastBackground : rgba (245 , 208 , 254 , 0.95 );
282
309
--toastColor : #424242 ;
283
- --toastProgressBackground : aquamarine ;
310
+ --toastBarBackground : fuchsia ;
284
311
}
285
312
.bottom {
286
313
--toastContainerTop : auto ;
@@ -290,22 +317,26 @@ toast.pop(0)`,
290
317
}
291
318
.top {
292
319
--toastContainerTop : 0.5rem ;
293
- --toastContainerRight : 2 rem ;
320
+ --toastContainerRight : 0.5 rem ;
294
321
--toastContainerBottom : auto ;
295
- --toastContainerLeft : 2 rem ;
322
+ --toastContainerLeft : 0.5 rem ;
296
323
--toastWidth : 100% ;
297
- --toastMinHeight : 1.5rem ;
298
- --toastBackground : rgba (59 , 130 , 246 , 0.95 );
299
- --toastMsgPadding : 0.25rem 0.5rem ;
324
+ --toastMinHeight : 2rem ;
325
+ --toastPadding : 0 0.5rem ;
300
326
font-size : 0.875rem ;
301
327
}
328
+ @media (min-width : 40rem ) {
329
+ .top {
330
+ --toastContainerRight : auto ;
331
+ --toastContainerLeft : calc (50vw - 20rem );
332
+ --toastWidth : 40rem ;
333
+ }
334
+ }
302
335
</style >
303
336
304
337
<div class =" container" >
305
338
<div class =" w-full h-64 px-2 mt-4 mb-8" >
306
- <Prism
307
- classes =" w-full h-full bg-gray-700 text-gray-200 font-mono shadow rounded-sm overflow-scroll p-4"
308
- >
339
+ <Prism classes =" w-full h-full bg-gray-700 text-gray-200 font-mono shadow rounded-sm overflow-scroll p-4" >
309
340
{code }
310
341
</Prism >
311
342
</div >
0 commit comments