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 { useToastProvider } from ":/components/Toast/ToastProvider"; import { VariantType } from ":/utils/VariantUtils"; 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 = [ VariantType.INFO, VariantType.SUCCESS, VariantType.WARNING, VariantType.ERROR, VariantType.NEUTRAL, ]; useEffect(() => { toast(faker.lorem.sentence({ min: 5, max: 10 }), VariantType.SUCCESS, { primaryLabel: "Read more", primaryOnClick: () => { // eslint-disable-next-line no-alert alert("Clicked here !"); }, }); }, []); return (
); }, }; export const Info: Story = { args: { type: VariantType.INFO, }, }; export const InfoWithButton: Story = { args: { type: VariantType.INFO, primaryLabel: "Primary", }, }; export const InfoCustom: Story = { args: { type: VariantType.INFO, actions: ( <> ), }, }; export const Success: Story = { args: { type: VariantType.SUCCESS, }, }; export const Warning: Story = { args: { type: VariantType.WARNING, }, }; export const Error: Story = { args: { type: VariantType.ERROR, }, }; export const Neutral: Story = { args: { type: VariantType.NEUTRAL, }, }; export const ProgressBarExample: Story = { render: () => { return (
); }, };