2
2
import { tick } from ' svelte'
3
3
import { SvelteToast , toast } from ' ../src'
4
4
import Prism from ' ./Prism.svelte'
5
+ import DummyComponent from ' ./Dummy.svelte'
5
6
import camelCase from ' camelcase'
6
7
7
8
// Hoist to `window` for debug
@@ -175,6 +176,28 @@ toast.set(id, { progress: 1 })`,
175
176
toast .push (' Bottoms up!' )
176
177
}
177
178
},
179
+ {
180
+ name: ' USE COMPONENT' ,
181
+ code: `
182
+ toast.push({
183
+ component: {
184
+ src: DummyComponent,
185
+ props: {
186
+ foo: 'bar'
187
+ }
188
+ }
189
+ })` ,
190
+ run: async () => {
191
+ toast .push ({
192
+ component: {
193
+ src: DummyComponent,
194
+ props: {
195
+ foo: ' bar'
196
+ }
197
+ }
198
+ })
199
+ }
200
+ },
178
201
{
179
202
name: ' RESTORE DEFAULTS' ,
180
203
code: ' // All default settings restored!' ,
@@ -189,29 +212,36 @@ toast.set(id, { progress: 1 })`,
189
212
{
190
213
name: ' CREATE NEW TOAST CONTAINER' ,
191
214
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
- }
215
+ .wrap {
216
+ --toastContainerTop: 0.5rem;
217
+ --toastContainerRight: 2rem;
218
+ --toastContainerBottom: auto;
219
+ --toastContainerLeft: 2rem;
220
+ --toastWidth: 100%;
221
+ --toastMinHeight: 1.5rem;
222
+ --toastBackground: rgba(59,130,246,0.95);
223
+ --toastMsgPadding: 0.25rem 0.5rem;
224
+ font-size: 0.875rem;
225
+ }
203
226
</style>
204
227
205
228
<div class="wrap">
206
229
<SvelteToast target="new" options={{ initial: 0, intro: { y: -64 } }} />
207
230
</div>
208
231
232
+ <div>
233
+ <SvelteToast options={{ initial: 0, intro: { y: -64 } }} />
234
+ </div>
235
+
209
236
<script>
210
237
// Send toast to "new" container
211
- toast.push('NEW: Multiple toast container support', { target: 'new' })
238
+ toast.push('NEW: Multiple toast container support', { target: 'new' });
239
+ // Send toast to "default" container
240
+ toast.push('Default container toast')
212
241
<\/ script>` , // eslint-disable-line no-useless-escape
213
242
run : () => {
214
243
toast .push (' NEW: Multiple toast container support' , { target: ' new' })
244
+ toast .push (' Default container toast' )
215
245
}
216
246
},
217
247
{
@@ -252,32 +282,32 @@ toast.pop(0)`,
252
282
font-size : 0.875rem ;
253
283
}
254
284
</style >
255
-
256
- <div class =" container" >
257
- <div class =" w-full h-64 px-2 mt-4 mb-8" >
258
- <Prism classes =" w-full h-full bg-gray-700 text-gray-200 font-mono shadow rounded-sm overflow-scroll p-4" >
259
- {code }
260
- </Prism >
285
+
286
+ <div class =" container" >
287
+ <div class =" w-full h-64 px-2 mt-4 mb-8" >
288
+ <Prism classes =" w-full h-full bg-gray-700 text-gray-200 font-mono shadow rounded-sm overflow-scroll p-4" >
289
+ {code }
290
+ </Prism >
291
+ </div >
292
+
293
+ <div class =" flex flex-row flex-wrap items-center justify-center" >
294
+
295
+ {#each buttons as btn }
296
+ <button
297
+ class:selected ={selected === btn .name }
298
+ on:click ={() => { handleClick (btn ) }}
299
+ data-btn ={camelCase (btn .name )}>
300
+ {btn .name }
301
+ </button >
302
+ {/each }
303
+
304
+ </div >
261
305
</div >
262
-
263
- <div class =" flex flex-row flex-wrap items-center justify-center" >
264
-
265
- {#each buttons as btn }
266
- <button
267
- class:selected ={selected === btn .name }
268
- on:click ={() => { handleClick (btn ) }}
269
- data-btn ={camelCase (btn .name )}>
270
- {btn .name }
271
- </button >
272
- {/each }
273
-
306
+
307
+ <div class =" top" >
308
+ <SvelteToast options ={{ initial : 0 , intro : { y : - 64 } }} target =" new" />
274
309
</div >
275
- </div >
276
-
277
- <div class =" top" >
278
- <SvelteToast options ={{ initial : 0 , intro : { y : - 64 } }} target =" new" />
279
- </div >
280
-
281
- <div class:colors class:bottom >
282
- <SvelteToast {options } />
283
- </div >
310
+
311
+ <div class:colors class:bottom >
312
+ <SvelteToast {options } />
313
+ </div >
0 commit comments