Skip to content

Commit

Permalink
docs(toast): improved toast docs (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra authored Dec 4, 2020
1 parent fccc3de commit 4b34d8f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs-templates/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ the

<!-- IMPORT_EXAMPLE src/toast/stories/__js/ToastBasic.component.jsx -->

We can utilize the `toastWrapper` prop to add animations and other wrappers
around the toast.

Example:

```jsx
<ToastProvider
animationTimeout={500}
toastWrapper={({ id, isVisible, children }) => (
<CSSTransition className="fadeIn" in={isVisible} timeout={500}>
{children}
</CSSTransition>
)}
toastTypes={{
primary: ({ content }) => <span>{content}</span>,
}}
>
<ToastTriggers />
</ToastProvider>
```

We also have to add the `animationTimeout` inorder to specify a delay before
removing the toast from the state, this would ensure the CSS or any other
animations has the chance to finish without being interrupted.

<!-- CODESANDBOX
link_title: Toast Basic - Open On Sandbox
js: src/toast/stories/__js/ToastBasic.component.jsx
Expand Down
25 changes: 25 additions & 0 deletions docs/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@ const ToastTriggers = () => {
};
```

We can utilize the `toastWrapper` prop to add animations and other wrappers
around the toast.

Example:

```jsx
<ToastProvider
animationTimeout={500}
toastWrapper={({ id, isVisible, children }) => (
<CSSTransition className="fadeIn" in={isVisible} timeout={500}>
{children}
</CSSTransition>
)}
toastTypes={{
primary: ({ content }) => <span>{content}</span>,
}}
>
<ToastTriggers />
</ToastProvider>
```

We also have to add the `animationTimeout` inorder to specify a delay before
removing the toast from the state, this would ensure the CSS or any other
animations has the chance to finish without being interrupted.

[Toast Basic - Open On Sandbox](https://codesandbox.io/s/2z7hj)

[Toast Styled - Open On Sandbox](https://codesandbox.io/s/k9rki)
Expand Down

1 comment on commit 4b34d8f

@vercel
Copy link

@vercel vercel bot commented on 4b34d8f Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.