import {
  Title,
  Meta,
  Subtitle,
  Description,
  Canvas,
  Controls,
  Source,
  Story,
} from '@storybook/addon-docs/blocks'
import { LifecycleTag, SourceLinks } from '../../docs/components'
import * as ToastStories from './Toast.stories'

<Meta of={ToastStories} />

<Title>Toast</Title>
<Subtitle>A temporary message to inform users about system events.</Subtitle>
<SourceLinks
  links={[
    {
      label: 'Sonner',
      href: 'https://sonner.emilkowal.ski/toast',
    },
  ]}
/>
<LifecycleTag variant="Stable" />

<Description>
  The <strong>Toast</strong> component is an ephemeral notification that appears
  briefly at the top of the screen. It can inform users about success messages,
  warnings, errors, or other important events. It also supports actions,
  countdown timers, and a close button.
</Description>

<Story of={ToastStories.AllVariants} />

<div className="h-8" />

## Usage

### Import and Place the Toaster

The `Toaster` component is required to display toast notifications.
It is powered by [Sonner](https://sonner.dev/), a modern toast notification library.

#### **Add the Toaster to Your Layout**

```tsx
import { Toaster } from '@chainlink/blocks'

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head />
      <body>
        <main>{children}</main>

        {/* Ensure Toaster is rendered at the top level */}
        <Toaster />
      </body>
    </html>
  )
}
```

### Triggering a Toast

To display a toast, use the `toast` function. The example below shows how to trigger a `success` toast when a user clicks a button.

<Source of={ToastStories.AllElements} />

## Customization

The `toast` function accepts several props to customize its content and behavior.

### All Elements

<Story of={ToastStories.AllElements} />
<Source of={ToastStories.AllElements} />

### Without Action

<Story of={ToastStories.WithoutAction} />
<Source of={ToastStories.WithoutAction} />

### Without Close Button

<Story of={ToastStories.WithoutClose} />
<Source of={ToastStories.WithoutClose} />
### Without Countdown
<Story of={ToastStories.WithoutCountdown} />
<Source of={ToastStories.WithoutCountdown} />
