goey-toast 0.2.1 → 0.3.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/README.md +168 -50
- package/dist/index.cjs +649 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +135 -65
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +73 -23
- package/dist/index.d.ts +73 -23
- package/dist/index.js +648 -195
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gooey-toast
|
|
2
2
|
|
|
3
|
-
[](https://goey-toast.vercel.app)
|
|
4
4
|
|
|
5
5
|
**[Live Demo & Docs](https://goey-toast.vercel.app)**
|
|
6
6
|
|
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
- Hover pause: hovering an expanded toast pauses the dismiss timer
|
|
20
20
|
- Hover re-expand: hovering a collapsed pill re-expands the toast
|
|
21
21
|
- Pre-dismiss collapse animation
|
|
22
|
+
- In-place toast updates via `gooeyToast.update()`
|
|
23
|
+
- Dismiss by type filter: `gooeyToast.dismiss({ type: 'error' })`
|
|
24
|
+
- Dark mode and RTL layout support
|
|
25
|
+
- Animation presets: smooth, bouncy, subtle, snappy
|
|
26
|
+
- Timestamp display on expanded toasts
|
|
27
|
+
- Countdown progress bar with hover-pause and re-expand
|
|
28
|
+
- Keyboard dismiss (Escape) and swipe-to-dismiss on mobile
|
|
29
|
+
- Toast queue with configurable overflow strategy
|
|
30
|
+
- Dismiss callbacks: `onDismiss` and `onAutoClose`
|
|
22
31
|
|
|
23
32
|
## Installation
|
|
24
33
|
|
|
@@ -61,14 +70,14 @@ Add this import once in your app's entry point (e.g., `main.tsx` or `App.tsx`).
|
|
|
61
70
|
## Quick Start
|
|
62
71
|
|
|
63
72
|
```tsx
|
|
64
|
-
import {
|
|
73
|
+
import { GooeyToaster, gooeyToast } from 'goey-toast'
|
|
65
74
|
import 'goey-toast/styles.css'
|
|
66
75
|
|
|
67
76
|
function App() {
|
|
68
77
|
return (
|
|
69
78
|
<>
|
|
70
|
-
<
|
|
71
|
-
<button onClick={() =>
|
|
79
|
+
<GooeyToaster position="bottom-right" />
|
|
80
|
+
<button onClick={() => gooeyToast.success('Saved!')}>
|
|
72
81
|
Save
|
|
73
82
|
</button>
|
|
74
83
|
</>
|
|
@@ -78,38 +87,89 @@ function App() {
|
|
|
78
87
|
|
|
79
88
|
## API Reference
|
|
80
89
|
|
|
81
|
-
### `
|
|
90
|
+
### `gooeyToast` Methods
|
|
82
91
|
|
|
83
92
|
```ts
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
gooeyToast(title, options?) // default (neutral)
|
|
94
|
+
gooeyToast.success(title, options?) // green
|
|
95
|
+
gooeyToast.error(title, options?) // red
|
|
96
|
+
gooeyToast.warning(title, options?) // yellow
|
|
97
|
+
gooeyToast.info(title, options?) // blue
|
|
98
|
+
gooeyToast.promise(promise, data) // loading -> success/error
|
|
99
|
+
gooeyToast.update(id, options) // update an existing toast in-place
|
|
100
|
+
gooeyToast.dismiss(idOrFilter?) // dismiss one, by type, or all toasts
|
|
91
101
|
```
|
|
92
102
|
|
|
93
|
-
|
|
103
|
+
#### `gooeyToast.update(id, options)`
|
|
94
104
|
|
|
95
|
-
|
|
105
|
+
Updates an existing toast in-place without removing and re-creating it.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
const id = gooeyToast('Uploading...', {
|
|
109
|
+
icon: <SpinnerIcon />,
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// Later, update the toast
|
|
113
|
+
gooeyToast.update(id, {
|
|
114
|
+
title: 'Upload complete',
|
|
115
|
+
type: 'success',
|
|
116
|
+
description: '3 files uploaded.',
|
|
117
|
+
icon: null, // clears the custom icon
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**`GooeyToastUpdateOptions`:**
|
|
122
|
+
|
|
123
|
+
| Option | Type | Description |
|
|
124
|
+
| ------------- | ----------------- | ----------------------------- |
|
|
125
|
+
| `title` | `string` | New title text |
|
|
126
|
+
| `description` | `ReactNode` | New body content |
|
|
127
|
+
| `type` | `GooeyToastType` | Change the toast type/color |
|
|
128
|
+
| `action` | `GooeyToastAction` | New action button |
|
|
129
|
+
| `icon` | `ReactNode \| null` | Custom icon (pass `null` to clear) |
|
|
130
|
+
|
|
131
|
+
#### `gooeyToast.dismiss(idOrFilter?)`
|
|
132
|
+
|
|
133
|
+
Dismiss a single toast by ID, all toasts of a given type, or all toasts at once.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
// Dismiss a specific toast
|
|
137
|
+
gooeyToast.dismiss(toastId)
|
|
138
|
+
|
|
139
|
+
// Dismiss all error toasts
|
|
140
|
+
gooeyToast.dismiss({ type: 'error' })
|
|
141
|
+
|
|
142
|
+
// Dismiss multiple types
|
|
143
|
+
gooeyToast.dismiss({ type: ['error', 'warning'] })
|
|
144
|
+
|
|
145
|
+
// Dismiss all toasts
|
|
146
|
+
gooeyToast.dismiss()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `GooeyToastOptions`
|
|
150
|
+
|
|
151
|
+
Options passed as the second argument to `gooeyToast()` and type-specific methods.
|
|
96
152
|
|
|
97
153
|
| Option | Type | Description |
|
|
98
154
|
| ------------- | -------------------- | ---------------------------------- |
|
|
99
155
|
| `description` | `ReactNode` | Body content (string or component) |
|
|
100
|
-
| `action` | `
|
|
156
|
+
| `action` | `GooeyToastAction` | Action button configuration |
|
|
101
157
|
| `icon` | `ReactNode` | Custom icon override |
|
|
102
158
|
| `duration` | `number` | Display duration in ms |
|
|
103
159
|
| `id` | `string \| number` | Unique toast identifier |
|
|
104
|
-
| `classNames` | `
|
|
160
|
+
| `classNames` | `GooeyToastClassNames`| CSS class overrides |
|
|
105
161
|
| `fillColor` | `string` | Background color of the blob |
|
|
106
162
|
| `borderColor` | `string` | Border color of the blob |
|
|
107
163
|
| `borderWidth` | `number` | Border width in px (default 1.5) |
|
|
108
|
-
| `timing` | `
|
|
164
|
+
| `timing` | `GooeyToastTimings` | Animation timing overrides |
|
|
109
165
|
| `spring` | `boolean` | Enable spring/bounce animations (default `true`) |
|
|
110
166
|
| `bounce` | `number` | Spring intensity from `0.05` (subtle) to `0.8` (dramatic), default `0.4` |
|
|
167
|
+
| `showProgress`| `boolean` | Show countdown progress bar |
|
|
168
|
+
| `onDismiss` | `(id) => void` | Called when toast is dismissed (any reason) |
|
|
169
|
+
| `onAutoClose` | `(id) => void` | Called only on timer-based auto-dismiss |
|
|
170
|
+
| `preset` | `AnimationPresetName`| Animation preset (`'smooth'`, `'bouncy'`, `'subtle'`, `'snappy'`) |
|
|
111
171
|
|
|
112
|
-
### `
|
|
172
|
+
### `GooeyToastAction`
|
|
113
173
|
|
|
114
174
|
| Property | Type | Required | Description |
|
|
115
175
|
| -------------- | ---------- | -------- | -------------------------------------------- |
|
|
@@ -117,7 +177,7 @@ Options passed as the second argument to `goeyToast()` and type-specific methods
|
|
|
117
177
|
| `onClick` | `() => void` | Yes | Click handler |
|
|
118
178
|
| `successLabel` | `string` | No | Label shown after click (morphs back to pill)|
|
|
119
179
|
|
|
120
|
-
### `
|
|
180
|
+
### `GooeyToastTimings`
|
|
121
181
|
|
|
122
182
|
Fine-tune animation speeds per toast.
|
|
123
183
|
|
|
@@ -125,7 +185,7 @@ Fine-tune animation speeds per toast.
|
|
|
125
185
|
| ------------------ | -------- | ------- | ------------------------------------ |
|
|
126
186
|
| `displayDuration` | `number` | 4000 | Milliseconds toast stays expanded |
|
|
127
187
|
|
|
128
|
-
### `
|
|
188
|
+
### `GooeyToastClassNames`
|
|
129
189
|
|
|
130
190
|
Override styles for any part of the toast.
|
|
131
191
|
|
|
@@ -140,9 +200,9 @@ Override styles for any part of the toast.
|
|
|
140
200
|
| `actionWrapper` | Button container |
|
|
141
201
|
| `actionButton` | Action button |
|
|
142
202
|
|
|
143
|
-
### `
|
|
203
|
+
### `GooeyToasterProps`
|
|
144
204
|
|
|
145
|
-
Props for the `<
|
|
205
|
+
Props for the `<GooeyToaster />` component.
|
|
146
206
|
|
|
147
207
|
| Prop | Type | Default | Description |
|
|
148
208
|
| ------------ | ------------------------------------- | ---------------- | --------------------------------------------- |
|
|
@@ -154,10 +214,17 @@ Props for the `<GoeyToaster />` component.
|
|
|
154
214
|
| `toastOptions` | `Partial<ExternalToast>` | -- | Default options passed to Sonner |
|
|
155
215
|
| `spring` | `boolean` | `true` | Enable spring/bounce animations globally |
|
|
156
216
|
| `bounce` | `number` | `0.4` | Spring intensity: `0.05` (subtle) to `0.8` (dramatic) |
|
|
217
|
+
| `preset` | `AnimationPresetName` | -- | Animation preset for all toasts |
|
|
218
|
+
| `closeOnEscape` | `boolean` | `true` | Dismiss most recent toast on Escape key |
|
|
219
|
+
| `showProgress` | `boolean` | `false` | Show countdown progress bar on all toasts |
|
|
220
|
+
| `maxQueue` | `number` | `Infinity` | Maximum queued toasts |
|
|
221
|
+
| `queueOverflow` | `'drop-oldest' \| 'drop-newest'` | `'drop-oldest'` | Queue overflow strategy |
|
|
222
|
+
| `dir` | `'ltr' \| 'rtl'` | `'ltr'` | Layout direction |
|
|
223
|
+
| `swipeToDismiss` | `boolean` | `true` | Enable swipe-to-dismiss on mobile |
|
|
157
224
|
|
|
158
|
-
### `
|
|
225
|
+
### `GooeyPromiseData<T>`
|
|
159
226
|
|
|
160
|
-
Configuration for `
|
|
227
|
+
Configuration for `gooeyToast.promise()`.
|
|
161
228
|
|
|
162
229
|
| Property | Type | Required | Description |
|
|
163
230
|
| ------------- | --------------------------------------------- | -------- | ---------------------------------------------- |
|
|
@@ -166,13 +233,15 @@ Configuration for `goeyToast.promise()`.
|
|
|
166
233
|
| `error` | `string \| ((error: unknown) => string)` | Yes | Title on error (static or derived from error) |
|
|
167
234
|
| `description` | `object` | No | Per-phase descriptions (see below) |
|
|
168
235
|
| `action` | `object` | No | Per-phase action buttons (see below) |
|
|
169
|
-
| `classNames` | `
|
|
236
|
+
| `classNames` | `GooeyToastClassNames` | No | CSS class overrides |
|
|
170
237
|
| `fillColor` | `string` | No | Background color of the blob |
|
|
171
238
|
| `borderColor` | `string` | No | Border color of the blob |
|
|
172
239
|
| `borderWidth` | `number` | No | Border width in px |
|
|
173
|
-
| `timing` | `
|
|
240
|
+
| `timing` | `GooeyToastTimings` | No | Animation timing overrides |
|
|
174
241
|
| `spring` | `boolean` | No | Enable spring/bounce animations (default `true`) |
|
|
175
242
|
| `bounce` | `number` | No | Spring intensity: `0.05` (subtle) to `0.8` (dramatic), default `0.4` |
|
|
243
|
+
| `onDismiss` | `(id: string \| number) => void` | No | Called when toast is dismissed (any reason) |
|
|
244
|
+
| `onAutoClose` | `(id: string \| number) => void` | No | Called only on timer-based auto-dismiss |
|
|
176
245
|
|
|
177
246
|
**`description` sub-fields:**
|
|
178
247
|
|
|
@@ -186,15 +255,15 @@ Configuration for `goeyToast.promise()`.
|
|
|
186
255
|
|
|
187
256
|
| Key | Type |
|
|
188
257
|
| --------- | ----------------- |
|
|
189
|
-
| `success` | `
|
|
190
|
-
| `error` | `
|
|
258
|
+
| `success` | `GooeyToastAction` |
|
|
259
|
+
| `error` | `GooeyToastAction` |
|
|
191
260
|
|
|
192
261
|
## Usage Examples
|
|
193
262
|
|
|
194
263
|
### Description
|
|
195
264
|
|
|
196
265
|
```tsx
|
|
197
|
-
|
|
266
|
+
gooeyToast.error('Payment failed', {
|
|
198
267
|
description: 'Your card was declined. Please try again.',
|
|
199
268
|
})
|
|
200
269
|
```
|
|
@@ -202,7 +271,7 @@ goeyToast.error('Payment failed', {
|
|
|
202
271
|
### Custom React Component as Description
|
|
203
272
|
|
|
204
273
|
```tsx
|
|
205
|
-
|
|
274
|
+
gooeyToast.success('Deployment complete', {
|
|
206
275
|
description: (
|
|
207
276
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
|
208
277
|
<div>
|
|
@@ -219,7 +288,7 @@ goeyToast.success('Deployment complete', {
|
|
|
219
288
|
### Action Button with Success Label
|
|
220
289
|
|
|
221
290
|
```tsx
|
|
222
|
-
|
|
291
|
+
gooeyToast.info('Share link ready', {
|
|
223
292
|
description: 'Your link has been generated.',
|
|
224
293
|
action: {
|
|
225
294
|
label: 'Copy to Clipboard',
|
|
@@ -232,7 +301,7 @@ goeyToast.info('Share link ready', {
|
|
|
232
301
|
### Promise Toast
|
|
233
302
|
|
|
234
303
|
```tsx
|
|
235
|
-
|
|
304
|
+
gooeyToast.promise(saveData(), {
|
|
236
305
|
loading: 'Saving...',
|
|
237
306
|
success: 'Changes saved',
|
|
238
307
|
error: 'Something went wrong',
|
|
@@ -252,7 +321,7 @@ goeyToast.promise(saveData(), {
|
|
|
252
321
|
### Custom Styling
|
|
253
322
|
|
|
254
323
|
```tsx
|
|
255
|
-
|
|
324
|
+
gooeyToast.success('Styled!', {
|
|
256
325
|
fillColor: '#1a1a2e',
|
|
257
326
|
borderColor: '#333',
|
|
258
327
|
borderWidth: 2,
|
|
@@ -268,7 +337,7 @@ goeyToast.success('Styled!', {
|
|
|
268
337
|
### Display Duration
|
|
269
338
|
|
|
270
339
|
```tsx
|
|
271
|
-
|
|
340
|
+
gooeyToast.success('Saved', {
|
|
272
341
|
description: 'Your changes have been synced.',
|
|
273
342
|
timing: { displayDuration: 5000 },
|
|
274
343
|
})
|
|
@@ -280,13 +349,13 @@ Disable bounce/spring animations for a cleaner, more subtle look:
|
|
|
280
349
|
|
|
281
350
|
```tsx
|
|
282
351
|
// Per-toast: disable spring for this toast only
|
|
283
|
-
|
|
352
|
+
gooeyToast.success('Saved', {
|
|
284
353
|
description: 'Your changes have been synced.',
|
|
285
354
|
spring: false,
|
|
286
355
|
})
|
|
287
356
|
|
|
288
357
|
// Globally: disable spring for all toasts
|
|
289
|
-
<
|
|
358
|
+
<GooeyToaster spring={false} />
|
|
290
359
|
```
|
|
291
360
|
|
|
292
361
|
When `spring` is `false`, all spring-based animations (landing squish, blob squish, morph transitions, pill resize, header squish) use smooth ease-in-out curves instead. Error shake animations still work regardless of this setting.
|
|
@@ -297,37 +366,86 @@ Control how dramatic the spring effect feels with a single `bounce` value:
|
|
|
297
366
|
|
|
298
367
|
```tsx
|
|
299
368
|
// Subtle, barely-there spring
|
|
300
|
-
|
|
369
|
+
gooeyToast.success('Saved', { bounce: 0.1 })
|
|
301
370
|
|
|
302
371
|
// Default feel
|
|
303
|
-
|
|
372
|
+
gooeyToast.success('Saved', { bounce: 0.4 })
|
|
304
373
|
|
|
305
374
|
// Jelly mode
|
|
306
|
-
|
|
375
|
+
gooeyToast.success('Saved', { bounce: 0.8 })
|
|
307
376
|
|
|
308
|
-
// Set globally via
|
|
309
|
-
<
|
|
377
|
+
// Set globally via GooeyToaster
|
|
378
|
+
<GooeyToaster bounce={0.6} />
|
|
310
379
|
```
|
|
311
380
|
|
|
312
381
|
The `bounce` value (0.05 to 0.8) controls spring stiffness, damping, and squish magnitude together so you get a consistent feel from one number.
|
|
313
382
|
|
|
383
|
+
### Dark Mode
|
|
384
|
+
|
|
385
|
+
```tsx
|
|
386
|
+
<GooeyToaster theme="dark" />
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### RTL Support
|
|
390
|
+
|
|
391
|
+
```tsx
|
|
392
|
+
<GooeyToaster dir="rtl" />
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Animation Presets
|
|
396
|
+
|
|
397
|
+
Four built-in presets: `smooth`, `bouncy`, `subtle`, `snappy`. Apply per-toast or globally:
|
|
398
|
+
|
|
399
|
+
```tsx
|
|
400
|
+
gooeyToast.success('Saved', { preset: 'bouncy' })
|
|
401
|
+
|
|
402
|
+
// Or globally
|
|
403
|
+
<GooeyToaster preset="smooth" />
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Progress Bar
|
|
407
|
+
|
|
408
|
+
Show a countdown progress bar on toasts:
|
|
409
|
+
|
|
410
|
+
```tsx
|
|
411
|
+
gooeyToast.success('Saved', { showProgress: true })
|
|
412
|
+
|
|
413
|
+
// Or enable globally
|
|
414
|
+
<GooeyToaster showProgress />
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Keyboard Shortcuts
|
|
418
|
+
|
|
419
|
+
Press **Escape** to dismiss the most recent toast. Enabled by default; disable with `closeOnEscape={false}`.
|
|
420
|
+
|
|
421
|
+
### Swipe to Dismiss
|
|
422
|
+
|
|
423
|
+
On mobile, swipe toasts to dismiss them. Enabled by default; disable with `swipeToDismiss={false}`.
|
|
424
|
+
|
|
314
425
|
## Exports
|
|
315
426
|
|
|
316
427
|
```ts
|
|
317
428
|
// Components
|
|
318
|
-
export {
|
|
429
|
+
export { GooeyToaster } from 'goey-toast'
|
|
319
430
|
|
|
320
431
|
// Toast function
|
|
321
|
-
export {
|
|
432
|
+
export { gooeyToast } from 'goey-toast'
|
|
433
|
+
|
|
434
|
+
// Animation presets
|
|
435
|
+
export { animationPresets } from 'goey-toast'
|
|
322
436
|
|
|
323
437
|
// Types
|
|
324
438
|
export type {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
439
|
+
GooeyToastOptions,
|
|
440
|
+
GooeyPromiseData,
|
|
441
|
+
GooeyToasterProps,
|
|
442
|
+
GooeyToastAction,
|
|
443
|
+
GooeyToastClassNames,
|
|
444
|
+
GooeyToastTimings,
|
|
445
|
+
GooeyToastUpdateOptions,
|
|
446
|
+
DismissFilter,
|
|
447
|
+
AnimationPreset,
|
|
448
|
+
AnimationPresetName,
|
|
331
449
|
} from 'goey-toast'
|
|
332
450
|
```
|
|
333
451
|
|