primevue-mirror/doc/toast/SeverityDoc.vue

141 lines
5.3 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>The <i>severity</i> option specifies the type of the message.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<div class="flex flex-wrap gap-2">
2023-03-03 12:15:20 +00:00
<Button label="Success" severity="success" @click="showSuccess" />
<Button label="Info" severity="info" @click="showInfo" />
2024-04-16 07:35:56 +00:00
<Button label="Warn" severity="warn" @click="showWarn" />
2023-03-03 12:15:20 +00:00
<Button label="Error" severity="danger" @click="showError" />
<Button label="Secondary" severity="secondary" @click="showSecondary" />
<Button label="Contrast" severity="contrast" @click="showContrast" />
2023-02-28 08:29:30 +00:00
</div>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
code: {
2023-09-22 12:54:14 +00:00
basic: `
<Toast />
2023-10-25 15:22:15 +00:00
<Button label="Success" severity="success" @click="showSuccess" />
<Button label="Info" severity="info" @click="showInfo" />
2024-04-16 07:35:56 +00:00
<Button label="Warn" severity="warn" @click="showWarn" />
2023-10-25 15:22:15 +00:00
<Button label="Error" severity="danger" @click="showError" />
<Button label="Secondary" severity="secondary" @click="showSecondary" />
<Button label="Contrast" severity="contrast" @click="showContrast" />
2023-10-15 09:38:39 +00:00
`,
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 />
<div class="flex flex-wrap gap-2">
2023-03-03 12:15:20 +00:00
<Button label="Success" severity="success" @click="showSuccess" />
<Button label="Info" severity="info" @click="showInfo" />
2024-04-16 07:35:56 +00:00
<Button label="Warn" severity="warn" @click="showWarn" />
2023-03-03 12:15:20 +00:00
<Button label="Error" severity="danger" @click="showError" />
<Button label="Secondary" severity="secondary" @click="showSecondary" />
<Button label="Contrast" severity="contrast" @click="showContrast" />
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
<script>
export default {
methods: {
showSuccess() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'success', summary: 'Success Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
},
showInfo() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'info', summary: 'Info Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
},
showWarn() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'warn', summary: 'Warn Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
},
showError() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'error', summary: 'Error Message', detail: 'Message Content', life: 3000 });
},
showSecondary() {
this.$toast.add({ severity: 'secondary', summary: 'Secondary Message', detail: 'Message Content', life: 3000 });
},
showContrast() {
this.$toast.add({ severity: 'contrast', summary: 'Contrast Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
}
}
};
2023-10-15 09:38:39 +00:00
<\/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 />
<div class="flex flex-wrap gap-2">
2023-03-03 12:15:20 +00:00
<Button label="Success" severity="success" @click="showSuccess" />
<Button label="Info" severity="info" @click="showInfo" />
2024-04-16 07:35:56 +00:00
<Button label="Warn" severity="warn" @click="showWarn" />
2023-03-03 12:15:20 +00:00
<Button label="Error" severity="danger" @click="showError" />
<Button label="Secondary" severity="secondary" @click="showSecondary" />
<Button label="Contrast" severity="contrast" @click="showContrast" />
2023-02-28 08:29:30 +00:00
</div>
</div>
</template>
<script setup>
import { useToast } from "primevue/usetoast";
const toast = useToast();
const showSuccess = () => {
2023-03-07 12:50:28 +00:00
toast.add({ severity: 'success', summary: 'Success Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
};
const showInfo = () => {
2023-03-07 12:50:28 +00:00
toast.add({ severity: 'info', summary: 'Info Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
};
const showWarn = () => {
2023-03-07 12:50:28 +00:00
toast.add({ severity: 'warn', summary: 'Warn Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
};
const showError = () => {
2023-03-07 12:50:28 +00:00
toast.add({ severity: 'error', summary: 'Error Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
};
const showSecondary = () => {
toast.add({ severity: 'secondary', summary: 'Secondary Message', detail: 'Message Content', life: 3000 });
};
const showContrast = () => {
toast.add({ severity: 'contrast', summary: 'Contrast Message', detail: 'Message Content', life: 3000 });
};
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
showSuccess() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'success', summary: 'Success Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
},
showInfo() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'info', summary: 'Info Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
},
showWarn() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'warn', summary: 'Warn Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
},
showError() {
2023-03-07 12:50:28 +00:00
this.$toast.add({ severity: 'error', summary: 'Error Message', detail: 'Message Content', life: 3000 });
},
showSecondary() {
this.$toast.add({ severity: 'secondary', summary: 'Secondary Message', detail: 'Message Content', life: 3000 });
},
showContrast() {
this.$toast.add({ severity: 'contrast', summary: 'Contrast Message', detail: 'Message Content', life: 3000 });
2023-02-28 08:29:30 +00:00
}
}
};
</script>