goey-toast 0.2.2 → 0.4.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 +99 -72
- package/dist/index.cjs +170 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +146 -81
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +34 -31
- package/dist/index.d.ts +34 -31
- package/dist/index.js +167 -123
- 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,11 +19,12 @@
|
|
|
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 `
|
|
23
|
-
- Dismiss by type filter: `
|
|
22
|
+
- In-place toast updates via `gooeyToast.update()`
|
|
23
|
+
- Dismiss by type filter: `gooeyToast.dismiss({ type: 'error' })`
|
|
24
24
|
- Dark mode and RTL layout support
|
|
25
25
|
- Animation presets: smooth, bouncy, subtle, snappy
|
|
26
|
-
- Timestamp display on expanded toasts
|
|
26
|
+
- Timestamp display on expanded toasts with optional `showTimestamp` toggle
|
|
27
|
+
- Close button with configurable position (`top-left` / `top-right`)
|
|
27
28
|
- Countdown progress bar with hover-pause and re-expand
|
|
28
29
|
- Keyboard dismiss (Escape) and swipe-to-dismiss on mobile
|
|
29
30
|
- Toast queue with configurable overflow strategy
|
|
@@ -70,14 +71,14 @@ Add this import once in your app's entry point (e.g., `main.tsx` or `App.tsx`).
|
|
|
70
71
|
## Quick Start
|
|
71
72
|
|
|
72
73
|
```tsx
|
|
73
|
-
import {
|
|
74
|
+
import { GooeyToaster, gooeyToast } from 'goey-toast'
|
|
74
75
|
import 'goey-toast/styles.css'
|
|
75
76
|
|
|
76
77
|
function App() {
|
|
77
78
|
return (
|
|
78
79
|
<>
|
|
79
|
-
<
|
|
80
|
-
<button onClick={() =>
|
|
80
|
+
<GooeyToaster position="bottom-right" />
|
|
81
|
+
<button onClick={() => gooeyToast.success('Saved!')}>
|
|
81
82
|
Save
|
|
82
83
|
</button>
|
|
83
84
|
</>
|
|
@@ -87,30 +88,30 @@ function App() {
|
|
|
87
88
|
|
|
88
89
|
## API Reference
|
|
89
90
|
|
|
90
|
-
### `
|
|
91
|
+
### `gooeyToast` Methods
|
|
91
92
|
|
|
92
93
|
```ts
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
gooeyToast(title, options?) // default (neutral)
|
|
95
|
+
gooeyToast.success(title, options?) // green
|
|
96
|
+
gooeyToast.error(title, options?) // red
|
|
97
|
+
gooeyToast.warning(title, options?) // yellow
|
|
98
|
+
gooeyToast.info(title, options?) // blue
|
|
99
|
+
gooeyToast.promise(promise, data) // loading -> success/error
|
|
100
|
+
gooeyToast.update(id, options) // update an existing toast in-place
|
|
101
|
+
gooeyToast.dismiss(idOrFilter?) // dismiss one, by type, or all toasts
|
|
101
102
|
```
|
|
102
103
|
|
|
103
|
-
#### `
|
|
104
|
+
#### `gooeyToast.update(id, options)`
|
|
104
105
|
|
|
105
106
|
Updates an existing toast in-place without removing and re-creating it.
|
|
106
107
|
|
|
107
108
|
```tsx
|
|
108
|
-
const id =
|
|
109
|
+
const id = gooeyToast('Uploading...', {
|
|
109
110
|
icon: <SpinnerIcon />,
|
|
110
111
|
})
|
|
111
112
|
|
|
112
113
|
// Later, update the toast
|
|
113
|
-
|
|
114
|
+
gooeyToast.update(id, {
|
|
114
115
|
title: 'Upload complete',
|
|
115
116
|
type: 'success',
|
|
116
117
|
description: '3 files uploaded.',
|
|
@@ -118,58 +119,59 @@ goeyToast.update(id, {
|
|
|
118
119
|
})
|
|
119
120
|
```
|
|
120
121
|
|
|
121
|
-
**`
|
|
122
|
+
**`GooeyToastUpdateOptions`:**
|
|
122
123
|
|
|
123
124
|
| Option | Type | Description |
|
|
124
125
|
| ------------- | ----------------- | ----------------------------- |
|
|
125
126
|
| `title` | `string` | New title text |
|
|
126
127
|
| `description` | `ReactNode` | New body content |
|
|
127
|
-
| `type` | `
|
|
128
|
-
| `action` | `
|
|
128
|
+
| `type` | `GooeyToastType` | Change the toast type/color |
|
|
129
|
+
| `action` | `GooeyToastAction` | New action button |
|
|
129
130
|
| `icon` | `ReactNode \| null` | Custom icon (pass `null` to clear) |
|
|
130
131
|
|
|
131
|
-
#### `
|
|
132
|
+
#### `gooeyToast.dismiss(idOrFilter?)`
|
|
132
133
|
|
|
133
134
|
Dismiss a single toast by ID, all toasts of a given type, or all toasts at once.
|
|
134
135
|
|
|
135
136
|
```ts
|
|
136
137
|
// Dismiss a specific toast
|
|
137
|
-
|
|
138
|
+
gooeyToast.dismiss(toastId)
|
|
138
139
|
|
|
139
140
|
// Dismiss all error toasts
|
|
140
|
-
|
|
141
|
+
gooeyToast.dismiss({ type: 'error' })
|
|
141
142
|
|
|
142
143
|
// Dismiss multiple types
|
|
143
|
-
|
|
144
|
+
gooeyToast.dismiss({ type: ['error', 'warning'] })
|
|
144
145
|
|
|
145
146
|
// Dismiss all toasts
|
|
146
|
-
|
|
147
|
+
gooeyToast.dismiss()
|
|
147
148
|
```
|
|
148
149
|
|
|
149
|
-
### `
|
|
150
|
+
### `GooeyToastOptions`
|
|
150
151
|
|
|
151
|
-
Options passed as the second argument to `
|
|
152
|
+
Options passed as the second argument to `gooeyToast()` and type-specific methods.
|
|
152
153
|
|
|
153
154
|
| Option | Type | Description |
|
|
154
155
|
| ------------- | -------------------- | ---------------------------------- |
|
|
155
156
|
| `description` | `ReactNode` | Body content (string or component) |
|
|
156
|
-
| `action` | `
|
|
157
|
+
| `action` | `GooeyToastAction` | Action button configuration |
|
|
157
158
|
| `icon` | `ReactNode` | Custom icon override |
|
|
158
159
|
| `duration` | `number` | Display duration in ms |
|
|
159
160
|
| `id` | `string \| number` | Unique toast identifier |
|
|
160
|
-
| `classNames` | `
|
|
161
|
+
| `classNames` | `GooeyToastClassNames`| CSS class overrides |
|
|
161
162
|
| `fillColor` | `string` | Background color of the blob |
|
|
162
163
|
| `borderColor` | `string` | Border color of the blob |
|
|
163
164
|
| `borderWidth` | `number` | Border width in px (default 1.5) |
|
|
164
|
-
| `timing` | `
|
|
165
|
+
| `timing` | `GooeyToastTimings` | Animation timing overrides |
|
|
165
166
|
| `spring` | `boolean` | Enable spring/bounce animations (default `true`) |
|
|
166
167
|
| `bounce` | `number` | Spring intensity from `0.05` (subtle) to `0.8` (dramatic), default `0.4` |
|
|
168
|
+
| `showTimestamp` | `boolean` | Show/hide timestamp in toast header/body (default `true`) |
|
|
167
169
|
| `showProgress`| `boolean` | Show countdown progress bar |
|
|
168
170
|
| `onDismiss` | `(id) => void` | Called when toast is dismissed (any reason) |
|
|
169
171
|
| `onAutoClose` | `(id) => void` | Called only on timer-based auto-dismiss |
|
|
170
172
|
| `preset` | `AnimationPresetName`| Animation preset (`'smooth'`, `'bouncy'`, `'subtle'`, `'snappy'`) |
|
|
171
173
|
|
|
172
|
-
### `
|
|
174
|
+
### `GooeyToastAction`
|
|
173
175
|
|
|
174
176
|
| Property | Type | Required | Description |
|
|
175
177
|
| -------------- | ---------- | -------- | -------------------------------------------- |
|
|
@@ -177,7 +179,7 @@ Options passed as the second argument to `goeyToast()` and type-specific methods
|
|
|
177
179
|
| `onClick` | `() => void` | Yes | Click handler |
|
|
178
180
|
| `successLabel` | `string` | No | Label shown after click (morphs back to pill)|
|
|
179
181
|
|
|
180
|
-
### `
|
|
182
|
+
### `GooeyToastTimings`
|
|
181
183
|
|
|
182
184
|
Fine-tune animation speeds per toast.
|
|
183
185
|
|
|
@@ -185,7 +187,7 @@ Fine-tune animation speeds per toast.
|
|
|
185
187
|
| ------------------ | -------- | ------- | ------------------------------------ |
|
|
186
188
|
| `displayDuration` | `number` | 4000 | Milliseconds toast stays expanded |
|
|
187
189
|
|
|
188
|
-
### `
|
|
190
|
+
### `GooeyToastClassNames`
|
|
189
191
|
|
|
190
192
|
Override styles for any part of the toast.
|
|
191
193
|
|
|
@@ -200,9 +202,9 @@ Override styles for any part of the toast.
|
|
|
200
202
|
| `actionWrapper` | Button container |
|
|
201
203
|
| `actionButton` | Action button |
|
|
202
204
|
|
|
203
|
-
### `
|
|
205
|
+
### `GooeyToasterProps`
|
|
204
206
|
|
|
205
|
-
Props for the `<
|
|
207
|
+
Props for the `<GooeyToaster />` component.
|
|
206
208
|
|
|
207
209
|
| Prop | Type | Default | Description |
|
|
208
210
|
| ------------ | ------------------------------------- | ---------------- | --------------------------------------------- |
|
|
@@ -216,15 +218,16 @@ Props for the `<GoeyToaster />` component.
|
|
|
216
218
|
| `bounce` | `number` | `0.4` | Spring intensity: `0.05` (subtle) to `0.8` (dramatic) |
|
|
217
219
|
| `preset` | `AnimationPresetName` | -- | Animation preset for all toasts |
|
|
218
220
|
| `closeOnEscape` | `boolean` | `true` | Dismiss most recent toast on Escape key |
|
|
221
|
+
| `closeButton` | `boolean \| 'top-left' \| 'top-right'` | `false` | Show close button on hover |
|
|
219
222
|
| `showProgress` | `boolean` | `false` | Show countdown progress bar on all toasts |
|
|
220
223
|
| `maxQueue` | `number` | `Infinity` | Maximum queued toasts |
|
|
221
224
|
| `queueOverflow` | `'drop-oldest' \| 'drop-newest'` | `'drop-oldest'` | Queue overflow strategy |
|
|
222
225
|
| `dir` | `'ltr' \| 'rtl'` | `'ltr'` | Layout direction |
|
|
223
226
|
| `swipeToDismiss` | `boolean` | `true` | Enable swipe-to-dismiss on mobile |
|
|
224
227
|
|
|
225
|
-
### `
|
|
228
|
+
### `GooeyPromiseData<T>`
|
|
226
229
|
|
|
227
|
-
Configuration for `
|
|
230
|
+
Configuration for `gooeyToast.promise()`.
|
|
228
231
|
|
|
229
232
|
| Property | Type | Required | Description |
|
|
230
233
|
| ------------- | --------------------------------------------- | -------- | ---------------------------------------------- |
|
|
@@ -233,11 +236,11 @@ Configuration for `goeyToast.promise()`.
|
|
|
233
236
|
| `error` | `string \| ((error: unknown) => string)` | Yes | Title on error (static or derived from error) |
|
|
234
237
|
| `description` | `object` | No | Per-phase descriptions (see below) |
|
|
235
238
|
| `action` | `object` | No | Per-phase action buttons (see below) |
|
|
236
|
-
| `classNames` | `
|
|
239
|
+
| `classNames` | `GooeyToastClassNames` | No | CSS class overrides |
|
|
237
240
|
| `fillColor` | `string` | No | Background color of the blob |
|
|
238
241
|
| `borderColor` | `string` | No | Border color of the blob |
|
|
239
242
|
| `borderWidth` | `number` | No | Border width in px |
|
|
240
|
-
| `timing` | `
|
|
243
|
+
| `timing` | `GooeyToastTimings` | No | Animation timing overrides |
|
|
241
244
|
| `spring` | `boolean` | No | Enable spring/bounce animations (default `true`) |
|
|
242
245
|
| `bounce` | `number` | No | Spring intensity: `0.05` (subtle) to `0.8` (dramatic), default `0.4` |
|
|
243
246
|
| `onDismiss` | `(id: string \| number) => void` | No | Called when toast is dismissed (any reason) |
|
|
@@ -255,15 +258,15 @@ Configuration for `goeyToast.promise()`.
|
|
|
255
258
|
|
|
256
259
|
| Key | Type |
|
|
257
260
|
| --------- | ----------------- |
|
|
258
|
-
| `success` | `
|
|
259
|
-
| `error` | `
|
|
261
|
+
| `success` | `GooeyToastAction` |
|
|
262
|
+
| `error` | `GooeyToastAction` |
|
|
260
263
|
|
|
261
264
|
## Usage Examples
|
|
262
265
|
|
|
263
266
|
### Description
|
|
264
267
|
|
|
265
268
|
```tsx
|
|
266
|
-
|
|
269
|
+
gooeyToast.error('Payment failed', {
|
|
267
270
|
description: 'Your card was declined. Please try again.',
|
|
268
271
|
})
|
|
269
272
|
```
|
|
@@ -271,7 +274,7 @@ goeyToast.error('Payment failed', {
|
|
|
271
274
|
### Custom React Component as Description
|
|
272
275
|
|
|
273
276
|
```tsx
|
|
274
|
-
|
|
277
|
+
gooeyToast.success('Deployment complete', {
|
|
275
278
|
description: (
|
|
276
279
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
|
277
280
|
<div>
|
|
@@ -288,7 +291,7 @@ goeyToast.success('Deployment complete', {
|
|
|
288
291
|
### Action Button with Success Label
|
|
289
292
|
|
|
290
293
|
```tsx
|
|
291
|
-
|
|
294
|
+
gooeyToast.info('Share link ready', {
|
|
292
295
|
description: 'Your link has been generated.',
|
|
293
296
|
action: {
|
|
294
297
|
label: 'Copy to Clipboard',
|
|
@@ -301,7 +304,7 @@ goeyToast.info('Share link ready', {
|
|
|
301
304
|
### Promise Toast
|
|
302
305
|
|
|
303
306
|
```tsx
|
|
304
|
-
|
|
307
|
+
gooeyToast.promise(saveData(), {
|
|
305
308
|
loading: 'Saving...',
|
|
306
309
|
success: 'Changes saved',
|
|
307
310
|
error: 'Something went wrong',
|
|
@@ -321,7 +324,7 @@ goeyToast.promise(saveData(), {
|
|
|
321
324
|
### Custom Styling
|
|
322
325
|
|
|
323
326
|
```tsx
|
|
324
|
-
|
|
327
|
+
gooeyToast.success('Styled!', {
|
|
325
328
|
fillColor: '#1a1a2e',
|
|
326
329
|
borderColor: '#333',
|
|
327
330
|
borderWidth: 2,
|
|
@@ -337,7 +340,7 @@ goeyToast.success('Styled!', {
|
|
|
337
340
|
### Display Duration
|
|
338
341
|
|
|
339
342
|
```tsx
|
|
340
|
-
|
|
343
|
+
gooeyToast.success('Saved', {
|
|
341
344
|
description: 'Your changes have been synced.',
|
|
342
345
|
timing: { displayDuration: 5000 },
|
|
343
346
|
})
|
|
@@ -349,13 +352,13 @@ Disable bounce/spring animations for a cleaner, more subtle look:
|
|
|
349
352
|
|
|
350
353
|
```tsx
|
|
351
354
|
// Per-toast: disable spring for this toast only
|
|
352
|
-
|
|
355
|
+
gooeyToast.success('Saved', {
|
|
353
356
|
description: 'Your changes have been synced.',
|
|
354
357
|
spring: false,
|
|
355
358
|
})
|
|
356
359
|
|
|
357
360
|
// Globally: disable spring for all toasts
|
|
358
|
-
<
|
|
361
|
+
<GooeyToaster spring={false} />
|
|
359
362
|
```
|
|
360
363
|
|
|
361
364
|
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.
|
|
@@ -366,16 +369,16 @@ Control how dramatic the spring effect feels with a single `bounce` value:
|
|
|
366
369
|
|
|
367
370
|
```tsx
|
|
368
371
|
// Subtle, barely-there spring
|
|
369
|
-
|
|
372
|
+
gooeyToast.success('Saved', { bounce: 0.1 })
|
|
370
373
|
|
|
371
374
|
// Default feel
|
|
372
|
-
|
|
375
|
+
gooeyToast.success('Saved', { bounce: 0.4 })
|
|
373
376
|
|
|
374
377
|
// Jelly mode
|
|
375
|
-
|
|
378
|
+
gooeyToast.success('Saved', { bounce: 0.8 })
|
|
376
379
|
|
|
377
|
-
// Set globally via
|
|
378
|
-
<
|
|
380
|
+
// Set globally via GooeyToaster
|
|
381
|
+
<GooeyToaster bounce={0.6} />
|
|
379
382
|
```
|
|
380
383
|
|
|
381
384
|
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.
|
|
@@ -383,13 +386,13 @@ The `bounce` value (0.05 to 0.8) controls spring stiffness, damping, and squish
|
|
|
383
386
|
### Dark Mode
|
|
384
387
|
|
|
385
388
|
```tsx
|
|
386
|
-
<
|
|
389
|
+
<GooeyToaster theme="dark" />
|
|
387
390
|
```
|
|
388
391
|
|
|
389
392
|
### RTL Support
|
|
390
393
|
|
|
391
394
|
```tsx
|
|
392
|
-
<
|
|
395
|
+
<GooeyToaster dir="rtl" />
|
|
393
396
|
```
|
|
394
397
|
|
|
395
398
|
### Animation Presets
|
|
@@ -397,10 +400,10 @@ The `bounce` value (0.05 to 0.8) controls spring stiffness, damping, and squish
|
|
|
397
400
|
Four built-in presets: `smooth`, `bouncy`, `subtle`, `snappy`. Apply per-toast or globally:
|
|
398
401
|
|
|
399
402
|
```tsx
|
|
400
|
-
|
|
403
|
+
gooeyToast.success('Saved', { preset: 'bouncy' })
|
|
401
404
|
|
|
402
405
|
// Or globally
|
|
403
|
-
<
|
|
406
|
+
<GooeyToaster preset="smooth" />
|
|
404
407
|
```
|
|
405
408
|
|
|
406
409
|
### Progress Bar
|
|
@@ -408,10 +411,10 @@ goeyToast.success('Saved', { preset: 'bouncy' })
|
|
|
408
411
|
Show a countdown progress bar on toasts:
|
|
409
412
|
|
|
410
413
|
```tsx
|
|
411
|
-
|
|
414
|
+
gooeyToast.success('Saved', { showProgress: true })
|
|
412
415
|
|
|
413
416
|
// Or enable globally
|
|
414
|
-
<
|
|
417
|
+
<GooeyToaster showProgress />
|
|
415
418
|
```
|
|
416
419
|
|
|
417
420
|
### Keyboard Shortcuts
|
|
@@ -422,27 +425,47 @@ Press **Escape** to dismiss the most recent toast. Enabled by default; disable w
|
|
|
422
425
|
|
|
423
426
|
On mobile, swipe toasts to dismiss them. Enabled by default; disable with `swipeToDismiss={false}`.
|
|
424
427
|
|
|
428
|
+
### Close Button
|
|
429
|
+
|
|
430
|
+
Show a close button on hover. Position it `top-left` (default) or `top-right`:
|
|
431
|
+
|
|
432
|
+
```tsx
|
|
433
|
+
<GooeyToaster closeButton />
|
|
434
|
+
<GooeyToaster closeButton="top-left" />
|
|
435
|
+
<GooeyToaster closeButton="top-right" />
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
The close button inherits the toast's border and fill color styling. Hidden during the loading phase of promise toasts.
|
|
439
|
+
|
|
440
|
+
### Hiding Timestamps
|
|
441
|
+
|
|
442
|
+
Hide the timestamp from toasts:
|
|
443
|
+
|
|
444
|
+
```tsx
|
|
445
|
+
gooeyToast.success('Saved', { showTimestamp: false })
|
|
446
|
+
```
|
|
447
|
+
|
|
425
448
|
## Exports
|
|
426
449
|
|
|
427
450
|
```ts
|
|
428
451
|
// Components
|
|
429
|
-
export {
|
|
452
|
+
export { GooeyToaster } from 'goey-toast'
|
|
430
453
|
|
|
431
454
|
// Toast function
|
|
432
|
-
export {
|
|
455
|
+
export { gooeyToast } from 'goey-toast'
|
|
433
456
|
|
|
434
457
|
// Animation presets
|
|
435
458
|
export { animationPresets } from 'goey-toast'
|
|
436
459
|
|
|
437
460
|
// Types
|
|
438
461
|
export type {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
462
|
+
GooeyToastOptions,
|
|
463
|
+
GooeyPromiseData,
|
|
464
|
+
GooeyToasterProps,
|
|
465
|
+
GooeyToastAction,
|
|
466
|
+
GooeyToastClassNames,
|
|
467
|
+
GooeyToastTimings,
|
|
468
|
+
GooeyToastUpdateOptions,
|
|
446
469
|
DismissFilter,
|
|
447
470
|
AnimationPreset,
|
|
448
471
|
AnimationPresetName,
|
|
@@ -458,6 +481,10 @@ goey-toast works in all modern browsers that support:
|
|
|
458
481
|
- ResizeObserver
|
|
459
482
|
- `framer-motion` (Chrome, Firefox, Safari, Edge)
|
|
460
483
|
|
|
484
|
+
## See Also
|
|
485
|
+
|
|
486
|
+
- **[gooey-search-tabs](https://github.com/anl331/gooey-search-tabs)** — A morphing search bar with animated tab navigation for React. [Live Demo](https://gooey-search-tabs.vercel.app)
|
|
487
|
+
|
|
461
488
|
## License
|
|
462
489
|
|
|
463
490
|
[MIT](./LICENSE)
|