toast-23 1.0.1 → 1.0.2
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/README.md +187 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<div style= "position: relative; display:inline-block; max-width:100%;">
|
|
3
|
+
<img src="./toast-23-lib/assets/toast-23-image.png" alt="toast-23 preview " style= " width:100%; max-width:1900px; height:auto; border-radius:12px;" />
|
|
4
|
+
|
|
5
|
+
</div>
|
|
6
|
+
<br/>
|
|
7
|
+
<div align="center" >
|
|
8
|
+
<img src="./toast-23-lib/assets/toast-23-logo.png" alt ="toast-23-logo" width="60" style="vertical-align: middle;" />
|
|
9
|
+
<h2
|
|
10
|
+
style="
|
|
11
|
+
font-weight: 900;
|
|
12
|
+
margin-left: 12px;
|
|
13
|
+
vertical-align: middle;
|
|
14
|
+
margin-bottom:10px;
|
|
15
|
+
"
|
|
16
|
+
>
|
|
17
|
+
toast-23
|
|
18
|
+
</h2>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
**A lightweight, accessible, fully-typed React toast notification library.**
|
|
24
|
+
|
|
25
|
+
Zero runtime dependencies · CSS animations · Dark mode · Promise tracking · Queue system
|
|
26
|
+
|
|
27
|
+
[](https://www.npmjs.com/package/toast-23)
|
|
28
|
+
[](https://bundlephobia.com/package/toast-23)
|
|
29
|
+
[](./LICENSE)
|
|
30
|
+
|
|
31
|
+
</div>
|
|
32
|
+
<br/>
|
|
33
|
+
<div align="center">
|
|
34
|
+
<a href="https://toast-23.vercel.app/">Website</a>
|
|
35
|
+
<span> · </span>
|
|
36
|
+
<a href="https://toast-23.vercel.app/docs">Documentation</a>
|
|
37
|
+
<!-- <span> · </span>
|
|
38
|
+
<a href="https://twitter.com/">Twitter</a> -->
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<br />
|
|
42
|
+
<div align="center">
|
|
43
|
+
<sub>Made by <a href="https://github.com/Its-sultan">Thabit S</a> 🧑🏽💻</sub>
|
|
44
|
+
</div>
|
|
45
|
+
<br/>
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- 🎨 **5 variants** — success, error, warning, info, default
|
|
52
|
+
- 📍 **6 positions** — top-right, top-left, top-center, bottom-right, bottom-left, bottom-center
|
|
53
|
+
- ⏳ **Promise API** — track async operations with loading → success / error
|
|
54
|
+
- ⏳ **Loading toast** — `toast.loading()` with manual update
|
|
55
|
+
- 🧩 **Custom JSX** — `toast.custom()` for fully custom content
|
|
56
|
+
- 🔄 **Update & Deduplicate** — update existing toasts via `id`, prevent duplicates
|
|
57
|
+
- 📦 **Queue system** — configurable max visible toasts with +N badge
|
|
58
|
+
- 🧹 **Dismiss & Remove** — dismiss all, remove instantly, configurable `removeDelay`
|
|
59
|
+
- 🌙 **Dark mode** — automatic (`prefers-color-scheme`) + manual (`.dark` class)
|
|
60
|
+
- ♿ **Accessible** — ARIA live regions, keyboard-navigable dismiss
|
|
61
|
+
- 🎭 **CSS animations** — smooth enter/exit transitions, hover-pause with progress reversal
|
|
62
|
+
- 🪶 **Lightweight** — zero runtime dependencies beyond React
|
|
63
|
+
- 🔒 **Fully typed** — complete TypeScript API
|
|
64
|
+
- 🌲 **Tree-shakeable** — ESM + CJS dual output
|
|
65
|
+
- 🌐 **Standalone API** — `createToast23()` for Angular, Vue, Svelte, vanilla JS
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
#### With npm
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install toast-23
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### With yarn
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
yarn add toast-23
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### With pnpm
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pnpm add toast-23
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Quick Start
|
|
92
|
+
|
|
93
|
+
### 1. Import the stylesheet
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
// In your app entry (e.g., main.tsx or layout.tsx)
|
|
97
|
+
import "toast-23/styles.css";
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 2. Wrap your app with the provider
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { Toast23Provider } from "toast-23";
|
|
104
|
+
|
|
105
|
+
function App() {
|
|
106
|
+
return (
|
|
107
|
+
<Toast23Provider position="top-right" maxVisible={5} duration={4000}>
|
|
108
|
+
<YourApp />
|
|
109
|
+
</Toast23Provider>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 3. Use the hook
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { useToast } from "toast-23";
|
|
118
|
+
|
|
119
|
+
function MyComponent() {
|
|
120
|
+
const toast = useToast();
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div>
|
|
124
|
+
<button onClick={() => toast("Hello world!")}>Default</button>
|
|
125
|
+
<button onClick={() => toast.success("Saved successfully!")}>
|
|
126
|
+
Success
|
|
127
|
+
</button>
|
|
128
|
+
<button onClick={() => toast.error("Something went wrong")}>Error</button>
|
|
129
|
+
<button onClick={() => toast.warning("Please check your input")}>
|
|
130
|
+
Warning
|
|
131
|
+
</button>
|
|
132
|
+
<button onClick={() => toast.info("New update available")}>Info</button>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Documentation
|
|
141
|
+
|
|
142
|
+
Find the full API reference on [official documentation ](https://toast-23.vercel.app/docs)
|
|
143
|
+
|
|
144
|
+
## Testing
|
|
145
|
+
|
|
146
|
+
toast-23 uses [Vitest](https://vitest.dev/) with [Testing Library](https://testing-library.com/):
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Run tests
|
|
150
|
+
npm test
|
|
151
|
+
|
|
152
|
+
# Watch mode
|
|
153
|
+
npm run test:watch
|
|
154
|
+
|
|
155
|
+
# Coverage
|
|
156
|
+
npm run test:coverage
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## CI/CD
|
|
162
|
+
|
|
163
|
+
GitHub Actions workflow at `.github/workflows/ci.yml`:
|
|
164
|
+
|
|
165
|
+
- **Lint** — TypeScript type checking
|
|
166
|
+
- **Test** — Vitest test suite (Node 18, 20, 22)
|
|
167
|
+
- **Build** — Vite library build with DTS generation
|
|
168
|
+
- **Publish** — Auto-publish to npm on version bump (requires `NPM_TOKEN` secret)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Suggested Improvements for v2
|
|
173
|
+
|
|
174
|
+
- [ ] Swipe-to-dismiss on mobile
|
|
175
|
+
- [ ] Stacked/collapsed mode for overflow
|
|
176
|
+
- [ ] Undo action support
|
|
177
|
+
- [ ] Theming via CSS custom properties (design tokens)
|
|
178
|
+
- [ ] Headless mode (bring your own UI)
|
|
179
|
+
- [ ] Rich content: icons, avatars, action buttons
|
|
180
|
+
- [ ] Sound notifications
|
|
181
|
+
- [ ] Persistent toasts (survive page navigation)
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
MIT © toast-23 contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toast-23",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A lightweight, accessible, fully-typed React toast notification library with zero dependencies.",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"default": "./dist/index.cjs"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
"./styles.css": "./dist/
|
|
22
|
+
"./styles.css": "./dist/toast-23.css"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|