import { type Meta, type StoryObj } from '@storybook/react-vite' import React from 'react' import { DocsTemplate } from '../../../.storybook' import Button from '../Button/Button' import PatternToastContainer from './PatternToastContainer' import { toast } from './Toast' const meta = { title: 'Components/Toast', component: PatternToastContainer, parameters: { design: { type: 'figma', url: 'https://www.figma.com/design/RvhKD82948FMQnh5MyCi0o/Web-Design-System?node-id=121-353&t=CdMnrLNv0lNFwXr0-0', }, docs: { page: () => ( The Toast component provides non-intrusive feedback and notifications to users. It appears temporarily and can be configured with different styles, behaviors, and interactive elements. Toasts are perfect for displaying success messages, errors, warnings, or general information without interrupting the user's workflow. } infoBullets={[ 'Supports four notification types: success, error, warning, and info', 'Can display text, HTML content, or React components as messages', 'Optional interactive buttons (up to 2) for user actions', 'Configurable auto-dismiss behavior (errors persist by default)', 'Customizable duration and animation settings', 'Supports queuing multiple notifications', 'Can be manually dismissed', ]} /> ), }, }, } satisfies Meta export default meta type Story = StoryObj // Basic Toast Examples export const BasicSuccess: Story = { render: () => ( ), parameters: { docs: { source: { code: "toast({ type: 'success', message: 'Operation completed successfully!' })", }, }, }, } export const BasicError: Story = { render: () => ( ), parameters: { docs: { source: { code: "toast({ type: 'error', message: 'An error occurred. Please try again.' })", }, }, }, } export const BasicWarning: Story = { render: () => ( ), parameters: { docs: { source: { code: "toast({ type: 'warning', message: 'Please review your changes before continuing.' })", }, }, }, } export const BasicInfo: Story = { render: () => ( ), parameters: { docs: { source: { code: "toast({ type: 'info', message: 'New features are available!' })", }, }, }, } // Long Text Content Example export const LongTextContent: Story = { render: () => ( ), parameters: { docs: { source: { code: "toast({ type: 'info', message: 'This toast contains significantly more text content to demonstrate how the toast width dynamically adjusts based on the content. The width will expand to fit the text up to a maximum width of 520px, after which it will wrap to additional lines.' })", }, }, }, } // Rich Content Example export const RichContent: Story = { render: () => ( ), parameters: { docs: { source: { code: `toast({ type: 'info', message: (
Update Available

Version 2.0 is now available with new features:

  • Enhanced performance
  • New UI components
  • Bug fixes
), })`, }, }, }, } // Interactive Toast Examples export const WithButtons: Story = { render: () => ( ), parameters: { docs: { source: { code: `toast({ type: 'warning', message: 'You have unsaved changes.', buttons: [ { children: 'Save', onClick: () => toast({ message: 'Changes saved!', type: 'success' }), }, { children: 'Discard', onClick: () => toast({ message: 'Changes discarded', type: 'info' }), }, ], })`, }, }, }, } // Custom Configuration Example export const CustomConfig: Story = { render: () => ( ), parameters: { docs: { source: { code: `toast({ type: 'info', message: 'This toast will stay for 10 seconds', config: { autoClose: 10000, position: 'bottom-right', }, })`, }, }, }, } // Multiple Toasts Example export const MultipleToasts: Story = { render: () => ( ), parameters: { docs: { source: { code: `// Showing multiple toasts in sequence toast({ type: 'info', message: 'Processing your request...', }) setTimeout(() => { toast({ type: 'success', message: 'First task completed', }) }, 1000) setTimeout(() => { toast({ type: 'success', message: 'Second task completed', }) }, 2000) setTimeout(() => { toast({ type: 'success', message: 'All tasks completed successfully!', }) }, 3000)`, }, }, }, }