Skip to content

Commit 213236a

Browse files
committed
update to v1.3.2
1 parent 97eb840 commit 213236a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+9106
-1675
lines changed

README.md

Lines changed: 23 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,21 @@
1-
# ReadMe
2-
3-
![https://user-images.githubusercontent.com/56094829/190699464-8394b80b-6259-4eee-8cb3-5ccf24e9aef8.png](https://user-images.githubusercontent.com/56094829/190699464-8394b80b-6259-4eee-8cb3-5ccf24e9aef8.png)
4-
5-
# Rc-Toastr
6-
7-
> a fully customizable ReactJs toasting library that helps you build complex notification in your app.
8-
>
9-
10-
![https://user-images.githubusercontent.com/56094829/190833292-dfaf26be-c88e-482b-9d4e-0919a5810286.gif](https://user-images.githubusercontent.com/56094829/190833292-dfaf26be-c88e-482b-9d4e-0919a5810286.gif)
11-
12-
## Config Options
13-
14-
| Propriety | description | value | default value |
15-
| --- | --- | --- | --- |
16-
| autoClose | If the toast should be closed automatically after duration ends | true OR false | true |
17-
| showProgressBar | Whether to show the progress bar - autoClose should be true | true OR false | true |
18-
| pauseOnHover | Whether to pause the closing the toast on hover - autoClose should be true | true OR false | true |
19-
| maxToasts | The maximum toasts to show in the screen | number | 30 |
20-
| duration | The duration in ms before closing the toast | number | 5000 |
21-
| zIndex | The order of the toasts on the screen | number | 30 |
22-
| toastBackgroundColor | Function to override the default toast color | (variant) ⇒ string | (variant) ⇒ theme.colors[type] |
23-
| renderToastIcon | Function to override the default toast icon | (variant) ⇒ JSX.Element | (variant) ⇒ theme.icons[type] |
24-
| postion | The position of the toasts on the screen | top | bottom | top-right | top-left | bottom-right | bottom-left | top |
25-
26-
## Installation:
27-
28-
```visual-basic
29-
npm install rc-toastr
30-
```
31-
32-
```visual-basic
33-
yarn add rc-toastr
34-
```
1+
<div align="center">
2+
3+
![https://user-images.githubusercontent.com/56094829/197514874-b521164e-045e-4390-8db7-eaf13fc35150.png](https://user-images.githubusercontent.com/56094829/197514874-b521164e-045e-4390-8db7-eaf13fc35150.png)
4+
5+
6+
<img src="https://img.shields.io/npm/dm/rc-toastr" alt="downloads"/>
7+
<img src="https://img.shields.io/npm/l/rc-toastr" alt="license"/>
8+
<img src="https://img.shields.io/npm/v/rc-toastr?color=green" alt="version" />
9+
10+
</div>
11+
<br />
12+
<div align="center">
13+
<a href="https://dub.sh/rc-toastr">Website</a>
14+
<span> · </span>
15+
<a href="https://dub.sh/rc-docs">Documentation</a>
16+
<span> · </span>
17+
<a href="https://dub.sh/walid">Twitter</a>
18+
</div>
3519

3620
## Usage
3721

@@ -40,13 +24,7 @@ import { ToastProvider } from 'rc-toastr'
4024
import "rc-toastr/dist/index.css" // import the css file
4125

4226
ReactDOM.render((
43-
<ToastProvider
44-
config={{ // <- Optional
45-
position: "top-right"
46-
duration: 3000
47-
// other config here...
48-
}}
49-
>
27+
<ToastProvider>
5028
<App />
5129
</ToastProvider>
5230
), document.getElementById('root'))
@@ -57,21 +35,13 @@ import { useToast } from 'rc-toastr'
5735

5836
const App = () => {
5937
const { toast } = useToast()
60-
const sayHello = () => {
61-
toast("Hello World!")
62-
// toast.success("Hello World!")
63-
}
64-
return <button onClick={sayHello}> Say Hello </button>
38+
const hello = () => toast.success("Hello World!")
39+
return <button onClick={toast}> Say Hello </button>
6540
}
6641

6742
export default App
6843
```
6944

70-
## Contributions :
71-
72-
Contributions are always welcome!
73-
feel free to open a PR or raise an issue if you face any :D
74-
75-
## Live Example
45+
## Documentation:
7646

77-
**[dub.sh/rc-toaster](https://dub.sh/rc-toaster)**
47+
For more information and examples feel free to check the official website at: **[dub.sh/rc-toastr](https://dub.sh/rc-toastr)**

example/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
"typescript": "link:../node_modules/typescript"
2525
},
2626
"devDependencies": {
27-
"@babel/plugin-syntax-object-rest-spread": "^7.8.3"
27+
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
28+
"autoprefixer": "^10.4.12",
29+
"postcss": "^8.4.18",
30+
"tailwindcss": "^3.2.0"
2831
},
2932
"eslintConfig": {
3033
"extends": "react-app"
File renamed without changes.

example/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
content="width=device-width, initial-scale=1, shrink-to-fit=no"
99
/>
1010
<meta name="theme-color" content="#000000" />
11+
<script src="https://cdn.tailwindcss.com"></script>
1112

1213
<!--
1314
manifest.json provides metadata used when your web app is added to the

example/src/App.tsx

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { Variant } from 'rc-toastr/dist/types'
44
const App = () => {
55
const { updateConfig, config } = useToast()
66
return <div>
7-
<div className="container">
7+
<div className="container mx-auto">
88
<img src="/logo.png" alt="" width={100} />
99
<h1 className="title">
1010
rc-toastr
1111
</h1>
1212
<p className="description">
1313
<span role="img" aria-label='light'>💡</span> Tip: Click the toast to show the others!
1414
</p>
15-
<div className="flex gap-md">
16-
<label className="flex gap-xs">
15+
<div className="flex gap-4">
16+
<label className="flex gap-2">
1717
<label className="checkbox">
1818
<input checked={config.autoClose} type="checkbox" onChange={(e) => {
1919
updateConfig({
@@ -25,7 +25,7 @@ const App = () => {
2525
</label>
2626
<span>Auto Close</span>
2727
</label>
28-
<label className="flex gap-xs">
28+
<label className="flex gap-2">
2929
<label className="checkbox">
3030
<input type="checkbox" checked={config.showProgressBar} disabled={!config.autoClose} onChange={(e) => {
3131
updateConfig({
@@ -37,7 +37,7 @@ const App = () => {
3737
</label>
3838
<span>Show Porgress Bar</span>
3939
</label>
40-
<label className="flex gap-xs">
40+
<label className="flex gap-2">
4141
<label className="checkbox">
4242
<input type="checkbox" checked={config.pauseOnHover} disabled={!config.autoClose} onChange={(e) => {
4343
updateConfig({
@@ -50,8 +50,8 @@ const App = () => {
5050
<span>Pause On Hover</span>
5151
</label>
5252
</div>
53-
<div className="flex gap-md">
54-
<label className="flex gap-xs">
53+
<div className="flex gap-4">
54+
<label className="flex gap-2">
5555
<label className="checkbox">
5656
<input type="radio" checked={config.position === "top"} name='postion' onChange={() => {
5757
updateConfig({
@@ -63,7 +63,7 @@ const App = () => {
6363
</label>
6464
<span>Top</span>
6565
</label>
66-
<label className="flex gap-xs">
66+
<label className="flex gap-2">
6767
<label className="checkbox">
6868
<input type="radio" checked={config.position === "top-left"} name='postion' onChange={() => {
6969
updateConfig({
@@ -75,7 +75,7 @@ const App = () => {
7575
</label>
7676
<span>Top Left</span>
7777
</label>
78-
<label className="flex gap-xs">
78+
<label className="flex gap-2">
7979
<label className="checkbox">
8080
<input type="radio" checked={config.position === "top-right"} name='postion' onChange={() => {
8181
updateConfig({
@@ -87,7 +87,7 @@ const App = () => {
8787
</label>
8888
<span>Top Right</span>
8989
</label>
90-
<label className="flex gap-xs">
90+
<label className="flex gap-2">
9191
<label className="checkbox">
9292
<input type="radio" checked={config.position === "bottom"} name='postion' onChange={() => {
9393
updateConfig({
@@ -99,7 +99,7 @@ const App = () => {
9999
</label>
100100
<span>Bottom</span>
101101
</label>
102-
<label className="flex gap-xs">
102+
<label className="flex gap-2">
103103
<label className="checkbox">
104104
<input type="radio" checked={config.position === "bottom-left"} name='postion' onChange={() => {
105105
updateConfig({
@@ -111,7 +111,7 @@ const App = () => {
111111
</label>
112112
<span>Bottom Left</span>
113113
</label>
114-
<label className="flex gap-xs">
114+
<label className="flex gap-2">
115115
<label className="checkbox">
116116
<input type="radio" checked={config.position === "bottom-right"} name='postion' onChange={() => {
117117
updateConfig({
@@ -165,7 +165,20 @@ const Button: React.FC<{
165165
const { toast } = useToast()
166166

167167
const handleToast = () => {
168-
toast[variant]?.(`Here is your ${variant} toast`)
168+
toast.loading(
169+
new Promise((_, reject) => {
170+
setTimeout(() => {
171+
reject("Done")
172+
}, 3000)
173+
}),
174+
{
175+
success: "Success, it's done!",
176+
error: (e)=>{
177+
toast.error(e as string)
178+
},
179+
loading: `Loading data...`,
180+
}
181+
)
169182
}
170183
return (
171184
<button className="button" onClick={handleToast}>

example/src/index.css

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
15
body {
26
margin: 0;
37
padding: 0;
@@ -6,6 +10,8 @@ body {
610
sans-serif;
711
-webkit-font-smoothing: antialiased;
812
-moz-osx-font-smoothing: grayscale;
13+
background: linear-gradient(to right, #c9d6ff, #e2e2e2);
14+
915
}
1016

1117

@@ -14,31 +20,6 @@ code {
1420
monospace;
1521
}
1622

17-
.flex {
18-
display: flex;
19-
justify-content: center;
20-
align-items: center;
21-
}
22-
23-
.flex-column {
24-
flex-direction: column;
25-
}
26-
.gap-xs {
27-
gap: 0.5rem;
28-
}
29-
.gap-sm {
30-
gap: 1rem;
31-
}
32-
.gap-md {
33-
gap: 1.5rem;
34-
}
35-
.gap-lg {
36-
gap: 2rem;
37-
}
38-
.gap-xl {
39-
gap: 2.5rem;
40-
}
41-
4223
.container {
4324
overflow-x: auto;
4425
min-height: 100vh;
@@ -50,7 +31,6 @@ code {
5031
gap: 1rem;
5132
flex-wrap: wrap;
5233
padding: 1rem 0;
53-
background: linear-gradient(to right, #c9d6ff, #e2e2e2);
5434
}
5535

5636
.title {

example/src/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
import React from 'react'
33
import ReactDOM from 'react-dom'
44
import App from './App'
5-
import { ToastProvider } from 'rc-toastr'
5+
import {ToastProvider } from 'rc-toastr'
66
import "rc-toastr/dist/index.css"
77
import './index.css'
88

99
ReactDOM.render((
10-
<ToastProvider>
11-
<App />
12-
</ToastProvider>
10+
<ToastProvider
11+
config={{
12+
autoClose: false
13+
}}
14+
>
15+
<App />
16+
</ToastProvider>
1317

1418
), document.getElementById('root'))

example/tailwind.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
"content": [
3+
"./src/**/*.{js,jsx,ts,tsx}"
4+
],
5+
"theme": {
6+
"extend": {}
7+
},
8+
"plugins": []
9+
}

0 commit comments

Comments
 (0)