primevue-mirror/doc/toast/TemplateDoc.vue

121 lines
4.5 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Custom content inside a message is defined with the <i>content</i> option.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<Toast position="bottom-center" group="bc">
<template #message="slotProps">
<div class="flex flex-column align-items-center" style="flex: 1">
<div class="text-center">
<i class="pi pi-exclamation-triangle" style="font-size: 3rem"></i>
2023-03-07 12:50:28 +00:00
<div class="font-bold text-xl my-3">{{ slotProps.message.summary }}</div>
2023-02-28 08:29:30 +00:00
</div>
<div class="flex gap-2">
2023-03-03 12:15:20 +00:00
<Button severity="success" label="Yes" @click="onConfirm()"></Button>
<Button severity="secondary" label="No" @click="onReject()"></Button>
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
</Toast>
<Button @click="showTemplate" label="Confirm" />
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
code: {
2023-09-22 12:54:14 +00:00
basic: `
<Toast position="bottom-center" group="bc">
2023-02-28 08:29:30 +00:00
<template #message="slotProps">
<div class="flex flex-column align-items-center" style="flex: 1">
<div class="text-center">
<i class="pi pi-exclamation-triangle" style="font-size: 3rem"></i>
2023-03-07 12:50:28 +00:00
<div class="font-bold text-xl my-3">{{ slotProps.message.summary }}</div>
2023-02-28 08:29:30 +00:00
</div>
<div class="flex gap-2">
2023-03-03 12:15:20 +00:00
<Button severity="success" label="Yes" @click="onConfirm()"></Button>
<Button severity="secondary" label="No" @click="onReject()"></Button>
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
</Toast>
<Button @click="showTemplate" label="Confirm" />`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex justify-content-center">
<Toast position="bottom-center" group="bc">
<template #message="slotProps">
<div class="flex flex-column align-items-center" style="flex: 1">
<div class="text-center">
<i class="pi pi-exclamation-triangle" style="font-size: 3rem"></i>
2023-03-07 12:50:28 +00:00
<div class="font-bold text-xl my-3">{{ slotProps.message.summary }}</div>
2023-02-28 08:29:30 +00:00
</div>
<div class="flex gap-2">
2023-03-03 12:15:20 +00:00
<Button severity="success" label="Yes" @click="onConfirm()"></Button>
<Button severity="secondary" label="No" @click="onReject()"></Button>
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
</Toast>
<Button @click="showTemplate" label="Confirm" />
</div>
</template>
<script>
export default {
methods: {
showTemplate() {
this.$toast.add({ severity: 'warn', summary: 'Are you sure?', detail: 'Proceed to confirm', group: 'bc' });
}
}
};
<\/script>`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex justify-content-center">
<Toast position="bottom-center" group="bc">
<template #message="slotProps">
<div class="flex flex-column align-items-center" style="flex: 1">
<div class="text-center">
<i class="pi pi-exclamation-triangle" style="font-size: 3rem"></i>
2023-03-07 12:50:28 +00:00
<div class="font-bold text-xl my-3">{{ slotProps.message.summary }}</div>
2023-02-28 08:29:30 +00:00
</div>
<div class="flex gap-2">
2023-03-03 12:15:20 +00:00
<Button severity="success" label="Yes" @click="onConfirm()"></Button>
<Button severity="secondary" label="No" @click="onReject()"></Button>
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
</Toast>
<Button @click="showTemplate" label="Confirm" />
</div>
</template>
<script setup>
import { useToast } from "primevue/usetoast";
const toast = useToast();
const showTemplate = () => {
toast.add({ severity: 'warn', summary: 'Are you sure?', detail: 'Proceed to confirm', group: 'bc' });
};
<\/script>`
}
};
},
methods: {
showTemplate() {
this.$toast.add({ severity: 'warn', summary: 'Are you sure?', detail: 'Proceed to confirm', group: 'bc' });
},
onConfirm() {
this.$toast.removeGroup('bc');
},
onReject() {
this.$toast.removeGroup('bc');
}
}
};
</script>