Skip to content

Commit 83e4f12

Browse files
authored
Merge pull request #354 from Efficy/main
Fix toast examples
2 parents 1eff702 + 859e969 commit 83e4f12

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

docs/components/Toast.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Use `toast.show()` method to generate your toasts. The method accepts the follow
7676

7777
## Variants
7878

79-
Toasts can be displayed as variants thru various helper methods or be set in `ToastOptions.varaint`
79+
Toasts can be displayed as variants thru various helper methods or be set in `ToastOptions.variant`
8080

8181
```html
8282
<b-container
@@ -96,16 +96,25 @@ Toasts can be displayed as variants thru various helper methods or be set in `To
9696
import {useToast} from 'bootstrap-vue-3'
9797
let toast = useToast()
9898
let variantshow1 = () => {
99-
toast.danger({title: 'Item Deleted'}, {pos: 'bottom-center'})
99+
toast.show({title: 'Item Deleted'}, {pos: 'bottom-center', variant: 'danger'})
100100
}
101101
let variantshow2 = () => {
102-
toast.info({title: 'New Message', body: 'This is a toast'}, {pos: 'bottom-right'})
102+
toast.show(
103+
{title: 'New Message', body: 'This is a toast'},
104+
{pos: 'bottom-right', variant: 'info'}
105+
)
103106
}
104107
let variantshow3 = () => {
105-
toast.warning({title: 'Warning for Item', body: 'Please check list'}, {pos: 'bottom-right'})
108+
toast.show(
109+
{title: 'Warning for Item', body: 'Please check list'},
110+
{pos: 'bottom-right', variant: 'warning'}
111+
)
106112
}
107113
let variantshow4 = () => {
108-
toast.success({title: 'Event Created!', body: 'Bootstrap Event'}, {pos: 'bottom-right'})
114+
toast.show(
115+
{title: 'Event Created!', body: 'Bootstrap Event'},
116+
{pos: 'bottom-right', variant: 'success'}
117+
)
109118
}
110119
</script>
111120
```
@@ -128,17 +137,17 @@ Toasts can be displayed as variants thru various helper methods or be set in `To
128137
<ClientOnly>
129138

130139
<script lang='ts' setup>
131-
import {ref, computed} from 'vue'
132-
import {useToast} from 'bootstrap-vue-3'
140+
import {ref, computed} from 'vue';
141+
import {useToast} from 'bootstrap-vue-3';
133142

134143

135-
let show1 = () => {toast.show({title: 'example title'})}
136-
let show2 = () => {toast.info({title: 'example title', body: "This is a toast"})}
144+
let show1 = () => {toast.show({title: 'example title'})};
145+
let show2 = () => {toast.show({title: 'example title', body: "This is a toast"}, {variant: 'info'})};
137146

138-
let variantshow1 = () => {toast.danger({title: 'Item Deleted'}, {pos: 'bottom-center'})}
139-
let variantshow2 = () => {toast.info({title: 'New Message', body: "This is a toast"}, {pos: 'bottom-right'})}
140-
let variantshow3 = () => {toast.warning({title: 'Warning for Item', body: "Please check list"},{pos: 'bottom-right'})}
141-
let variantshow4 = () => {toast.success({title: 'Event Created!', body: "Bootstrap Event"},{pos: 'bottom-right'})}
147+
let variantshow1 = () => {toast.show({title: 'Item Deleted'}, {pos: 'bottom-center', variant: 'danger'})};
148+
let variantshow2 = () => {toast.show({title: 'New Message', body: "This is a toast"}, {pos: 'bottom-right', variant: 'info'})};
149+
let variantshow3 = () => {toast.show({title: 'Warning for Item', body: "Please check list"},{pos: 'bottom-right', variant: 'warning'})};
150+
let variantshow4 = () => {toast.show({title: 'Event Created!', body: "Bootstrap Event"},{pos: 'bottom-right', variant: 'success'})};
142151
</script>
143152

144153
</ClientOnly>

src/App.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@
18421842
<b-toast v-model="showToast" title="Hello" body="cow"></b-toast>
18431843
<b-button class="mt-3" @click="createToast()">Show Toast</b-button>
18441844
<b-button class="mt-3" @click="createToast2()">Show Toast 2</b-button>
1845-
1845+
<b-button class="mt-3" @click="createToastError()">Show a danger Toast</b-button>
18461846
<b-button class="mt-3" @click="consoleLog">Hide Toast</b-button>
18471847
<div id="demo"></div>
18481848
</b-container>
@@ -2039,6 +2039,15 @@ export default defineComponent({
20392039
)
20402040
}
20412041
2042+
const createToastError = () => {
2043+
c?.show(
2044+
{
2045+
body: 'This is a danger toast!!',
2046+
},
2047+
{variant: 'danger'}
2048+
)
2049+
}
2050+
20422051
function tagValidator(tag: string) {
20432052
// Individual tag validator function
20442053
return tag === tag.toLowerCase() && tag.length > 2 && tag.length < 6
@@ -2061,6 +2070,7 @@ export default defineComponent({
20612070
loading,
20622071
createToast,
20632072
createToast2,
2073+
createToastError,
20642074
password,
20652075
showPassword,
20662076
description,

0 commit comments

Comments
 (0)