Skip to content

Commit 86bc988

Browse files
authored
Added option for toast with title (#8)
Add new feature toast title
1 parent 7e6dcfb commit 86bc988

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ const defaults = {
158158
progress: 0, // current progress
159159
reversed: false, // insert new toast to bottom of stack
160160
intro: { x: 256 }, // toast intro fly animation settings
161-
theme: {} // css var overrides
161+
theme: {}, // css var overrides
162+
title: null // insert a title for the toast (optional)
162163
}
163164
```
164165

src/SvelteToast.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const defaults = {
1212
progress: 0,
1313
reversed: false,
1414
intro: { x: 256 },
15-
theme: {}
15+
theme: {},
16+
title: null
1617
}
1718
toast._opts(defaults)
1819
$: toast._opts(options)

src/ToastItem.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ $: if (prevProgress !== item.progress) {
3535
will-change: transform,opacity;
3636
-webkit-tap-highlight-color: transparent;
3737
}
38+
._toastTitle {
39+
font-weight: bold;
40+
}
3841
._toastMsg {
3942
font: var(--toastFont);
4043
flex: 1 1 0%;
@@ -75,7 +78,12 @@ $: if (prevProgress !== item.progress) {
7578
</style>
7679

7780
<div class="_toastItem">
78-
<div class="_toastMsg">{item.msg}</div>
81+
<div class="_toastMsg">
82+
{#if item.title}
83+
<div class="_toastTitle">{item.title}</div>
84+
{/if}
85+
{item.msg}
86+
</div>
7987

8088
{#if item.dismissable}
8189
<div class="_toastBtn" role="button" tabindex="-1" on:click={() => toast.pop(item.id)}>✕</div>

0 commit comments

Comments
 (0)