diff --git a/README.md b/README.md index e082f7df..0ffe95fa 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ ![NPM](https://img.shields.io/npm/l/react-toastify.svg?label=%F0%9F%93%9Clicense&style=for-the-badge) ![Coveralls github](https://img.shields.io/coveralls/github/fkhadra/react-toastify.svg?label=%E2%9B%B1coverage&style=for-the-badge) - -![React toastify](https://user-images.githubusercontent.com/5574267/130804494-a9d2d69c-f170-4576-b2e1-0bb7f13dd92d.gif "React toastify") +![React toastify](https://user-images.githubusercontent.com/5574267/130804494-a9d2d69c-f170-4576-b2e1-0bb7f13dd92d.gif 'React toastify') ![stacked](https://github.com/fkhadra/react-toastify/assets/5574267/975c7c01-b95e-43cf-9100-256fa8ef2760) @@ -23,20 +22,51 @@ $ yarn add react-toastify ``` ```jsx - import React from 'react'; - - import { ToastContainer, toast } from 'react-toastify'; - - function App(){ - const notify = () => toast("Wow so easy!"); - - return ( -
- - -
- ); - } +import React from 'react'; + +import { ToastContainer, toast } from 'react-toastify'; + +function App() { + const notify = () => toast('Wow so easy!'); + + return ( +
+ + +
+ ); +} +``` + +### With custom transition + +```jsx +import React from 'react'; + +import { ToastContainer, toast, Bounce } from 'react-toastify'; + +function App() { + const notify = () => toast('Wow so easy!'); + + return ( +
+ + +
+ ); +} ``` ## Documentation @@ -52,7 +82,7 @@ Check the [documentation](https://fkhadra.github.io/react-toastify/introduction) - Can choose swipe direction - Super easy to use an animation of your choice. Works well with animate.css for example - Can display a react component inside the toast! -- Has ```onOpen``` and ```onClose``` hooks. Both can access the props passed to the react component rendered inside the toast +- Has `onOpen` and `onClose` hooks. Both can access the props passed to the react component rendered inside the toast - Can remove a toast programmatically - Define behavior per toast - Pause toast when the window loses focus 👁 @@ -61,7 +91,7 @@ Check the [documentation](https://fkhadra.github.io/react-toastify/introduction) - You can control the progress bar a la `nprogress` 😲 - You can limit the number of toast displayed at the same time - Dark mode 🌒 -- Pause timer programmaticaly +- Pause timer programmaticaly - Stacked notifications! - And much more ! @@ -69,7 +99,6 @@ Check the [documentation](https://fkhadra.github.io/react-toastify/introduction) [A demo is worth a thousand words](https://fkhadra.github.io/react-toastify/introduction) - ## Contribute Show your ❤️ and support by giving a ⭐. Any suggestions are welcome! Take a look at the contributing guide. diff --git a/playground/src/components/App.tsx b/playground/src/components/App.tsx index acde3d51..8aad61f7 100644 --- a/playground/src/components/App.tsx +++ b/playground/src/components/App.tsx @@ -88,7 +88,8 @@ class App extends React.Component { this.state.pauseOnHover && this.state.closeOnClick && this.state.draggable && - this.state.theme === 'light' + this.state.theme === 'light' && + this.state.transition === 'bounce' ); } diff --git a/playground/src/components/ContainerCode.tsx b/playground/src/components/ContainerCode.tsx index e5fd01d7..7b694927 100644 --- a/playground/src/components/ContainerCode.tsx +++ b/playground/src/components/ContainerCode.tsx @@ -17,6 +17,7 @@ function getProp(prop: L, value: R) { export interface ContainerCodeProps extends Partial { isDefaultProps: boolean; disableAutoClose: boolean; + transition?: string; } export const ContainerCode: React.FC = ({ @@ -31,10 +32,19 @@ export const ContainerCode: React.FC = ({ pauseOnFocusLoss, isDefaultProps, draggable, - theme + theme, + transition }) => (

Toast Container

+ {transition && transition !== 'bounce' && ( +
+
+ import + {` { ${transition.charAt(0).toUpperCase() + transition.slice(1)} } from 'react-toastify';`} +
+
+ )}
{`<`} @@ -48,6 +58,12 @@ export const ContainerCode: React.FC = ({ theme {`="${theme}"`}
+ {transition && transition !== 'bounce' && ( +
+ transition + {`={${transition.charAt(0).toUpperCase() + transition.slice(1)}}`} +
+ )}
autoClose {`={${disableAutoClose ? false : autoClose}}`} diff --git a/src/addons/use-notification-center/NotificationCenter.cy.tsx b/src/addons/use-notification-center/NotificationCenter.cy.tsx index 2ffe1962..34b77122 100644 --- a/src/addons/use-notification-center/NotificationCenter.cy.tsx +++ b/src/addons/use-notification-center/NotificationCenter.cy.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { toast, ToastContainer } from 'react-toastify'; +import { toast, ToastContainer } from '../../../src'; import { NotificationCenterItem, useNotificationCenter, UseNotificationCenterParams } from './useNotificationCenter'; function TestComponent(props: UseNotificationCenterParams) { diff --git a/src/addons/use-notification-center/useNotificationCenter.ts b/src/addons/use-notification-center/useNotificationCenter.ts index 7e69ec38..264579ea 100644 --- a/src/addons/use-notification-center/useNotificationCenter.ts +++ b/src/addons/use-notification-center/useNotificationCenter.ts @@ -1,5 +1,5 @@ import { useState, useEffect, useRef } from 'react'; -import { toast, ToastItem, Id } from 'react-toastify'; +import { toast, ToastItem, Id } from '../../index'; type Optional = Pick, K> & Omit;