Skip to content

Commit 0dcb673

Browse files
committed
toast
1 parent 9f74da6 commit 0dcb673

File tree

9 files changed

+55
-125
lines changed

9 files changed

+55
-125
lines changed

docs/api/toast.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Toasts can be swiped to dismiss by using the `swipeGesture` property. This featu
7979
import SwipeGesture from '@site/static/usage/v7/toast/swipe-gesture/index.md';
8080

8181
<SwipeGesture />
82-
82+
8383
## Layout
8484

8585
Button containers within the toast can be displayed either on the same line as the message or stacked on separate lines using the `layout` property. The stacked layout should be used with buttons that have long text values. Additionally, buttons in a stacked toast layout can use a `side` value of either `start` or `end`, but not both.

static/usage/v7/toast/buttons/vue.md

+24-33
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,32 @@
1010
></ion-toast>
1111
</template>
1212

13-
<script lang="ts">
13+
<script lang="ts" setup>
1414
import { IonButton, IonToast } from '@ionic/vue';
15-
import { defineComponent, ref } from 'vue';
15+
import { ref } from 'vue';
1616
17-
export default defineComponent({
18-
components: { IonButton, IonToast },
19-
setup() {
20-
const handlerMessage = ref('');
21-
const roleMessage = ref('');
22-
const toastButtons = [
23-
{
24-
text: 'More Info',
25-
role: 'info',
26-
handler: () => {
27-
console.log('More Info clicked');
28-
},
29-
},
30-
{
31-
text: 'Dismiss',
32-
role: 'cancel',
33-
handler: () => {
34-
console.log('Dismiss clicked');
35-
},
36-
},
37-
];
38-
const handleDismiss = (ev: CustomEvent) => {
39-
const { role } = ev.detail;
40-
console.log(`Dismissed with role: ${role}`);
41-
};
42-
43-
return {
44-
toastButtons,
45-
handleDismiss,
46-
};
17+
const handlerMessage = ref('');
18+
const roleMessage = ref('');
19+
const toastButtons = [
20+
{
21+
text: 'More Info',
22+
role: 'info',
23+
handler: () => {
24+
console.log('More Info clicked');
25+
},
26+
},
27+
{
28+
text: 'Dismiss',
29+
role: 'cancel',
30+
handler: () => {
31+
console.log('Dismiss clicked');
32+
},
4733
},
48-
});
34+
];
35+
36+
const handleDismiss = (ev: CustomEvent) => {
37+
const { role } = ev.detail;
38+
console.log(`Dismissed with role: ${role}`);
39+
};
4940
</script>
5041
```

static/usage/v7/toast/icon/vue.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,8 @@
44
<ion-toast trigger="open-toast" message="Hello World!" :duration="3000" :icon="globe"></ion-toast>
55
</template>
66

7-
<script lang="ts">
7+
<script lang="ts" setup>
88
import { IonButton, IonToast } from '@ionic/vue';
99
import { globe } from 'ionicons/icons';
10-
11-
import { defineComponent } from 'vue';
12-
13-
export default defineComponent({
14-
components: { IonButton, IonToast },
15-
setup() {
16-
return { globe };
17-
},
18-
});
1910
</script>
2011
```

static/usage/v7/toast/inline/basic/vue.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,7 @@
1212
</ion-content>
1313
</template>
1414

15-
<script lang="ts">
15+
<script lang="ts" setup>
1616
import { IonButton, IonHeader, IonContent, IonToolbar, IonTitle, IonToast } from '@ionic/vue';
17-
import { defineComponent } from 'vue';
18-
19-
export default defineComponent({
20-
components: {
21-
IonButton,
22-
IonHeader,
23-
IonContent,
24-
IonToolbar,
25-
IonTitle,
26-
IonToast,
27-
},
28-
});
2917
</script>
3018
```

static/usage/v7/toast/inline/is-open/vue.md

+6-13
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@
1616
</ion-content>
1717
</template>
1818

19-
<script lang="ts">
19+
<script lang="ts" setup>
2020
import { IonButton, IonHeader, IonToolbar, IonContent, IonTitle, IonToast } from '@ionic/vue';
21-
import { defineComponent, ref } from 'vue';
21+
import { ref } from 'vue';
2222
23-
export default defineComponent({
24-
components: { IonButton, IonHeader, IonToolbar, IonContent, IonTitle, IonToast },
25-
setup() {
26-
const isOpen = ref(false);
27-
const setOpen = (state: boolean) => {
28-
isOpen.value = state;
29-
};
30-
31-
return { isOpen, setOpen };
32-
},
33-
});
23+
const isOpen = ref(false);
24+
const setOpen = (state: boolean) => {
25+
isOpen.value = state;
26+
};
3427
</script>
3528
```

static/usage/v7/toast/layout/vue.md

+6-14
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@
1717
></ion-toast>
1818
</template>
1919

20-
<script lang="ts">
20+
<script lang="ts" setup>
2121
import { IonButton, IonToast } from '@ionic/vue';
22-
import { defineComponent } from 'vue';
2322
24-
export default defineComponent({
25-
components: { IonButton, IonToast },
26-
setup() {
27-
const toastButtons = [
28-
{
29-
text: 'Action With Long Text'
30-
}
31-
]
32-
33-
return toastButtons }
34-
}
35-
});
23+
const toastButtons = [
24+
{
25+
text: 'Action With Long Text',
26+
},
27+
];
3628
</script>
3729
```

static/usage/v7/toast/position-anchor/vue.md

+1-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,7 @@
3333
</ion-footer>
3434
</template>
3535

36-
<script lang="ts">
36+
<script lang="ts" setup>
3737
import { IonButton, IonContent, IonFooter, IonHeader, IonTitle, IonToast, IonToolbar } from '@ionic/vue';
38-
import { defineComponent } from 'vue';
39-
40-
export default defineComponent({
41-
components: {
42-
IonButton,
43-
IonContent,
44-
IonFooter,
45-
IonHeader,
46-
IonTitle,
47-
IonToast,
48-
IonToolbar,
49-
},
50-
});
5138
</script>
5239
```

static/usage/v7/toast/presenting/controller/vue.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@
55
<ion-button expand="block" @click="presentToast('bottom')">Present Toast At the Bottom</ion-button>
66
</template>
77

8-
<script lang="ts">
8+
<script lang="ts" setup>
99
import { IonButton, toastController } from '@ionic/vue';
1010
11-
export default {
12-
components: { IonButton },
13-
methods: {
14-
async presentToast(position: 'top' | 'middle' | 'bottom') {
15-
const toast = await toastController.create({
16-
message: 'Hello World!',
17-
duration: 1500,
18-
position: position,
19-
});
11+
async function presentToast(position: 'top' | 'middle' | 'bottom') {
12+
const toast = await toastController.create({
13+
message: 'Hello World!',
14+
duration: 1500,
15+
position: position,
16+
});
2017
21-
await toast.present();
22-
},
23-
},
24-
};
18+
await toast.present();
19+
}
2520
</script>
2621
```

static/usage/v7/toast/theming/vue.md

+6-13
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,15 @@
1010
></ion-toast>
1111
</template>
1212

13-
<script lang="ts">
13+
<script lang="ts" setup>
1414
import { IonButton, IonToast } from '@ionic/vue';
1515
16-
export default {
17-
components: { IonButton, IonToast },
18-
setup() {
19-
const toastButtons = [
20-
{
21-
text: 'Dismiss',
22-
role: 'cancel',
23-
},
24-
];
25-
26-
return { toastButtons };
16+
const toastButtons = [
17+
{
18+
text: 'Dismiss',
19+
role: 'cancel',
2720
},
28-
};
21+
];
2922
</script>
3023

3124
<style>

0 commit comments

Comments
 (0)