Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(toast): improved toast docs #181

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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