react-toast-master 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -4,51 +4,69 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```
8
- $ npm install react-toast-master
9
- $ yarn add react-toast-master
7
+ ```bash
8
+ npm install react-toast-master
9
+ pnpm install react-toast-master
10
+ yarn add react-toast-master
10
11
  ```
11
12
 
12
- ## 💡 Simple Example
13
+ ## 🚀 Setup
14
+
15
+ Wrap your app with `ToastProvider` and import the styles once at your root:
13
16
 
14
17
  ```jsx
15
- import React from "react";
16
- import { ToastProvider, useToast } from "react-toast-master";
18
+ import { ToastProvider } from "react-toast-master";
19
+ import "react-toast-master/dist/style.css";
17
20
 
18
21
  function App() {
19
- const { toastMaster } = useToast();
20
-
21
- const showToast = () => {
22
- toastMaster({
23
- type: "success",
24
- message: "Hello World!",
25
- });
26
- };
27
-
28
22
  return (
29
23
  <ToastProvider>
30
- <button onClick={showToast}>Toast</button>
24
+ <YourApp />
31
25
  </ToastProvider>
32
26
  );
33
27
  }
34
28
  ```
35
29
 
36
- ## 💡 With More Customization ( with Tailwind CSS )
30
+ ## 💡 Simple Example
31
+
32
+ `useToast` must be used inside a component that is a child of `ToastProvider`:
37
33
 
38
34
  ```jsx
39
- import React from "react";
40
- import { ToastProvider, useToast } from "react-toast-master";
35
+ import { useToast } from "react-toast-master";
41
36
 
42
- function App() {
37
+ function ToastButton() {
43
38
  const { toastMaster } = useToast();
44
39
 
40
+ return (
41
+ <button
42
+ onClick={() =>
43
+ toastMaster({
44
+ type: "success",
45
+ message: "Hello World!",
46
+ })
47
+ }
48
+ >
49
+ Show Toast
50
+ </button>
51
+ );
52
+ }
53
+ ```
54
+
55
+ ## 💡 With More Customization (with Tailwind CSS)
56
+
57
+ ```jsx
58
+ import { useToast } from "react-toast-master";
59
+
60
+ function ToastButton() {
61
+ const { toastMaster, hideToast } = useToast();
62
+
45
63
  const showToast = () => {
46
64
  toastMaster({
47
65
  type: "errorWhite",
48
66
  message: "Uh oh! Something went wrong.",
49
67
  footer: (
50
68
  <div className="flex justify-between w-full">
51
- <p>There was a problem with your request.</p>{" "}
69
+ <p>There was a problem with your request.</p>
52
70
  <span className="border border-white cursor-pointer duration-100 hover:bg-white hover:text-[#dc2626] h-min px-2 rounded-sm text-white whitespace-nowrap">
53
71
  Try again
54
72
  </span>
@@ -64,16 +82,62 @@ function App() {
64
82
  };
65
83
 
66
84
  return (
67
- <ToastProvider>
68
- <button onClick={showToast}>Toast</button>
69
- </ToastProvider>
85
+ <div>
86
+ <button onClick={showToast}>Show Toast</button>
87
+ <button onClick={() => hideToast()}>Hide Toast</button>
88
+ </div>
70
89
  );
71
90
  }
72
91
  ```
73
92
 
93
+ ## ⚙️ Options
94
+
95
+ | Prop | Type | Default | Description |
96
+ | -------------- | --------- | ----------- | ------------------------------- |
97
+ | `type` | string | `"success"` | Toast variant (see types below) |
98
+ | `message` | ReactNode | `""` | Toast content |
99
+ | `position` | string | `"top"` | Where the toast appears |
100
+ | `transition` | string | `"zoom"` | Entry animation |
101
+ | `bg` | string | `"white"` | Background style |
102
+ | `align` | string | `"center"` | Text alignment |
103
+ | `shadow` | string | `"gray"` | Shadow style |
104
+ | `radius` | string | `"lg"` | Border radius |
105
+ | `cancelButton` | boolean | `true` | Show close button |
106
+ | `skew` | string | `""` | Skew transform |
107
+ | `footer` | ReactNode | `null` | Footer content |
108
+ | `loadFooter` | ReactNode | `null` | Loading state footer |
109
+ | `timeout` | number | `3000` | Auto-hide delay in ms |
110
+ | `custom` | ReactNode | `null` | Custom toast content |
111
+
112
+ ## 🎨 Types
113
+
114
+ | Category | Values |
115
+ | -------- | ----------------------------------------------------------------------------------------- |
116
+ | Success | `success` `successWhite` `successDark` |
117
+ | Error | `error` `errorWhite` `errorDark` |
118
+ | Info | `info` `infoWhite` `infoStay` `infoStayWhite` `infoDark` `infoStayDark` |
119
+ | Warning | `warning` `warningWhite` `warningStay` `warningStayWhite` `warningDark` `warningStayDark` |
120
+ | Loading | `loading` `loadingWhite` `loadingDark` |
121
+ | Basic | `basic` `basicDark` |
122
+ | Confirm | `confirm` `confirmDark` |
123
+ | Custom | `custom` `customStay` |
124
+
125
+ ## 🪝 Hook
126
+
127
+ ```jsx
128
+ const { toastMaster, hideToast } = useToast();
129
+
130
+ // Show a toast — returns a Promise (resolves true/false for confirm toasts)
131
+ toastMaster({ type: "success", message: "Done!" });
132
+
133
+ // Hide the last toast, or pass an id to hide a specific one
134
+ hideToast();
135
+ hideToast(id);
136
+ ```
137
+
74
138
  ## 📔 Documentation and Demo
75
139
 
76
- Check [website](https://react-toast-master.netlify.app/) to get a better understanding!
140
+ Check the [website](https://react-toast-master.netlify.app/) for a full demo and examples!
77
141
 
78
142
  ## 📜 License
79
143