import MtToast from "./mt-toast.vue"; import MtButton from "@/components/form/mt-button/mt-button.vue"; import MtSelect from "@/components/form/mt-select/mt-select.vue"; import MtTextField from "@/components/form/mt-text-field/mt-text-field.vue"; import MtCheckbox from "@/components/form/mt-checkbox/mt-checkbox.vue"; import type { Toast } from "./mt-toast.vue"; import type { StoryObj } from "@storybook/vue3"; import type { SlottedMeta } from "@/_internal/story-helper"; import { createId } from "@/utils/id"; export type MtToastMeta = SlottedMeta; export default { title: "Components/Feedback Indicator/mt-toast", component: MtToast, render: (args) => ({ components: { MtToast, MtButton, MtSelect, MtTextField, MtCheckbox }, template: `

Spawn some toasts 🍞

Add critical toast Add positive toast Add informal toast
`, setup: () => { return { args, }; }, data(): { toasts: Toast[]; msg: string; displayIcon: boolean; dismissible: boolean; action: boolean; } { return { toasts: [], msg: "Max three words", displayIcon: false, dismissible: false, action: false, }; }, methods: { onAddToast(type: string) { let icon = "regular-bug"; if (type === "positive") { icon = "regular-checkmark"; } if (type === "informal") { icon = "regular-lightbulb"; } this.toasts = [ { id: createId(), // auto generated at the sdk // Provided by the user msg: this.msg, type, dismissible: this.dismissible, icon: this.displayIcon ? icon : undefined, action: this.action ? { label: "action", callback: () => console.log("action") } : undefined, }, ...this.toasts, ]; }, removeToast(id: number) { this.toasts = this.toasts.filter((toast: Toast) => toast.id !== id); }, }, }), } as MtToastMeta; export type MtToastStory = StoryObj; export const Default: MtToastStory = { name: "mt-toast", };