Skip to content

Commit c382ef5

Browse files
author
Dotan Tailman
committed
slot option added for more flexible uses and reactivity
1 parent 18e2110 commit c382ef5

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/components/Toast.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77
v-on:mouseover="onMouseOver"
88
v-on:mouseout="onMouseOut"
99
>
10-
<toast-progress v-if="progressbar" :percent="progressBarPercent" ref="progressBar"></toast-progress>
11-
<div class="toast-title" v-html="data.title"></div>
12-
<div class="toast-message" v-html="data.msg"></div>
10+
<toast-progress
11+
v-if="progressbar"
12+
:percent="progressBarPercent"
13+
ref="progressBar"
14+
></toast-progress>
15+
<div v-if="data.title" class="toast-title" v-html="data.title"></div>
16+
<div
17+
v-if="data.msg && !$slots.default"
18+
class="toast-message"
19+
v-html="data.msg"
20+
></div>
21+
<div v-if="$slots.default" class="toast-message">
22+
<slot></slot>
23+
</div>
1324
</div>
1425
</template>
1526
<script>

src/components/Toastr.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
v-for="(toasts, position) in list"
66
:key="position"
77
>
8-
<toast :data="toast" v-for="(toast, index) in toasts" :key="index"></toast>
8+
<toast :data="toast" v-for="(toast, index) in toasts" :key="index">
9+
<slot></slot>
10+
</toast>
911
</div>
1012
</div>
1113
</template>

0 commit comments

Comments
 (0)