import { Meta, StoryObj } from "@storybook/react"; import React, { useEffect } from "react"; import { faker } from "@faker-js/faker"; import { ProgressBar, Toast } from ":/components/Toast/index"; import { Button } from ":/components/Button"; import { ToastType, useToastProvider } from ":/components/Toast/ToastProvider"; const meta: Meta = { title: "Components/Toast", component: Toast, args: { children: "Corrupti vestigium aiunt aeneus demulceo consequatur.", duration: 30000, disableAnimate: true, }, }; export default meta; type Story = StoryObj; export const Demo: Story = { render: () => { const { toast } = useToastProvider(); const TYPES = [ ToastType.INFO, ToastType.SUCCESS, ToastType.WARNING, ToastType.ERROR, ToastType.NEUTRAL, ]; useEffect(() => { toast(faker.lorem.sentence({ min: 5, max: 10 }), ToastType.SUCCESS, { primaryLabel: "Read more", primaryOnClick: () => { // eslint-disable-next-line no-alert alert("Clicked here !"); }, }); }, []); return (
); }, }; export const Info: Story = { args: { type: ToastType.INFO, }, }; export const InfoWithButton: Story = { args: { type: ToastType.INFO, primaryLabel: "Primary", }, }; export const InfoCustom: Story = { args: { type: ToastType.INFO, actions: ( <> ), }, }; export const Success: Story = { args: { type: ToastType.SUCCESS, }, }; export const Warning: Story = { args: { type: ToastType.WARNING, }, }; export const Error: Story = { args: { type: ToastType.ERROR, }, }; export const Neutral: Story = { args: { type: ToastType.NEUTRAL, }, }; export const ProgressBarExample: Story = { render: () => { return (
); }, };