goey-toast 0.1.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 +21 -0
- package/README.md +297 -0
- package/dist/index.cjs +983 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +248 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +82 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +980 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# goey-toast
|
|
2
|
+
|
|
3
|
+
Morphing toast notifications for React. Organic blob animations powered by [Sonner](https://sonner.emilkowal.dev/) and [Framer Motion](https://www.framer.com/motion/).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Organic blob morph animation (pill → blob → pill)
|
|
8
|
+
- Five toast types: default, success, error, warning, info
|
|
9
|
+
- Promise toasts with loading → success/error transitions
|
|
10
|
+
- Action buttons with optional success label morph-back
|
|
11
|
+
- Description body supporting strings and React components
|
|
12
|
+
- Configurable timing for expand delay, morph duration, collapse, and display
|
|
13
|
+
- Custom fill color, border color, and border width
|
|
14
|
+
- CSS class overrides via `classNames` prop
|
|
15
|
+
- Position support with automatic horizontal mirroring for right-side positions
|
|
16
|
+
- Pre-dismiss collapse animation
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install goey-toast
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
goey-toast requires the following peer dependencies:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install react react-dom framer-motion
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Package | Version |
|
|
33
|
+
| -------------- | ---------- |
|
|
34
|
+
| react | >= 18.0.0 |
|
|
35
|
+
| react-dom | >= 18.0.0 |
|
|
36
|
+
| framer-motion | >= 10.0.0 |
|
|
37
|
+
|
|
38
|
+
### CSS Import (Required)
|
|
39
|
+
|
|
40
|
+
You **must** import the goey-toast stylesheet for the component to render correctly:
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import 'goey-toast/styles.css'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Add this import once in your app's entry point (e.g., `main.tsx` or `App.tsx`). Without it, toasts will appear unstyled.
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import { GoeyToaster, goeyToast } from 'goey-toast'
|
|
52
|
+
import 'goey-toast/styles.css'
|
|
53
|
+
|
|
54
|
+
function App() {
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<GoeyToaster position="bottom-right" />
|
|
58
|
+
<button onClick={() => goeyToast.success('Saved!')}>
|
|
59
|
+
Save
|
|
60
|
+
</button>
|
|
61
|
+
</>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API Reference
|
|
67
|
+
|
|
68
|
+
### `goeyToast` Methods
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
goeyToast(title, options?) // default (neutral)
|
|
72
|
+
goeyToast.success(title, options?) // green
|
|
73
|
+
goeyToast.error(title, options?) // red
|
|
74
|
+
goeyToast.warning(title, options?) // yellow
|
|
75
|
+
goeyToast.info(title, options?) // blue
|
|
76
|
+
goeyToast.promise(promise, data) // loading -> success/error
|
|
77
|
+
goeyToast.dismiss(toastId?) // dismiss one or all toasts
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `GoeyToastOptions`
|
|
81
|
+
|
|
82
|
+
Options passed as the second argument to `goeyToast()` and type-specific methods.
|
|
83
|
+
|
|
84
|
+
| Option | Type | Description |
|
|
85
|
+
| ------------- | -------------------- | ---------------------------------- |
|
|
86
|
+
| `description` | `ReactNode` | Body content (string or component) |
|
|
87
|
+
| `action` | `GoeyToastAction` | Action button configuration |
|
|
88
|
+
| `icon` | `ReactNode` | Custom icon override |
|
|
89
|
+
| `duration` | `number` | Display duration in ms |
|
|
90
|
+
| `id` | `string \| number` | Unique toast identifier |
|
|
91
|
+
| `classNames` | `GoeyToastClassNames`| CSS class overrides |
|
|
92
|
+
| `fillColor` | `string` | Background color of the blob |
|
|
93
|
+
| `borderColor` | `string` | Border color of the blob |
|
|
94
|
+
| `borderWidth` | `number` | Border width in px (default 1.5) |
|
|
95
|
+
| `timing` | `GoeyToastTimings` | Animation timing overrides |
|
|
96
|
+
|
|
97
|
+
### `GoeyToastAction`
|
|
98
|
+
|
|
99
|
+
| Property | Type | Required | Description |
|
|
100
|
+
| -------------- | ---------- | -------- | -------------------------------------------- |
|
|
101
|
+
| `label` | `string` | Yes | Button text |
|
|
102
|
+
| `onClick` | `() => void` | Yes | Click handler |
|
|
103
|
+
| `successLabel` | `string` | No | Label shown after click (morphs back to pill)|
|
|
104
|
+
|
|
105
|
+
### `GoeyToastTimings`
|
|
106
|
+
|
|
107
|
+
Fine-tune animation speeds per toast.
|
|
108
|
+
|
|
109
|
+
| Property | Type | Default | Description |
|
|
110
|
+
| ------------------ | -------- | ------- | ------------------------------------ |
|
|
111
|
+
| `expandDelay` | `number` | 330 | Milliseconds before expand starts |
|
|
112
|
+
| `expandDuration` | `number` | 0.9 | Seconds for pill-to-blob morph |
|
|
113
|
+
| `collapseDuration` | `number` | 0.9 | Seconds for blob-to-pill morph |
|
|
114
|
+
| `displayDuration` | `number` | 4000 | Milliseconds toast stays expanded |
|
|
115
|
+
|
|
116
|
+
### `GoeyToastClassNames`
|
|
117
|
+
|
|
118
|
+
Override styles for any part of the toast.
|
|
119
|
+
|
|
120
|
+
| Key | Target |
|
|
121
|
+
| --------------- | ---------------- |
|
|
122
|
+
| `wrapper` | Outer container |
|
|
123
|
+
| `content` | Content area |
|
|
124
|
+
| `header` | Icon + title row |
|
|
125
|
+
| `title` | Title text |
|
|
126
|
+
| `icon` | Icon wrapper |
|
|
127
|
+
| `description` | Body text |
|
|
128
|
+
| `actionWrapper` | Button container |
|
|
129
|
+
| `actionButton` | Action button |
|
|
130
|
+
|
|
131
|
+
### `GoeyToasterProps`
|
|
132
|
+
|
|
133
|
+
Props for the `<GoeyToaster />` component.
|
|
134
|
+
|
|
135
|
+
| Prop | Type | Default | Description |
|
|
136
|
+
| ------------ | ------------------------------------- | ---------------- | --------------------------------------------- |
|
|
137
|
+
| `position` | `'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `'bottom-right'` | Toast position (right-side positions auto-mirror the blob) |
|
|
138
|
+
| `duration` | `number` | -- | Default display duration in ms |
|
|
139
|
+
| `gap` | `number` | `14` | Gap between stacked toasts (px) |
|
|
140
|
+
| `offset` | `number \| string` | `'24px'` | Distance from screen edge |
|
|
141
|
+
| `theme` | `'light' \| 'dark'` | `'light'` | Color theme |
|
|
142
|
+
| `toastOptions` | `Partial<ExternalToast>` | -- | Default options passed to Sonner |
|
|
143
|
+
|
|
144
|
+
### `GoeyPromiseData<T>`
|
|
145
|
+
|
|
146
|
+
Configuration for `goeyToast.promise()`.
|
|
147
|
+
|
|
148
|
+
| Property | Type | Required | Description |
|
|
149
|
+
| ------------- | --------------------------------------------- | -------- | ---------------------------------------------- |
|
|
150
|
+
| `loading` | `string` | Yes | Title shown during loading |
|
|
151
|
+
| `success` | `string \| ((data: T) => string)` | Yes | Title on success (static or derived from result)|
|
|
152
|
+
| `error` | `string \| ((error: unknown) => string)` | Yes | Title on error (static or derived from error) |
|
|
153
|
+
| `description` | `object` | No | Per-phase descriptions (see below) |
|
|
154
|
+
| `action` | `object` | No | Per-phase action buttons (see below) |
|
|
155
|
+
| `classNames` | `GoeyToastClassNames` | No | CSS class overrides |
|
|
156
|
+
| `fillColor` | `string` | No | Background color of the blob |
|
|
157
|
+
| `borderColor` | `string` | No | Border color of the blob |
|
|
158
|
+
| `borderWidth` | `number` | No | Border width in px |
|
|
159
|
+
| `timing` | `GoeyToastTimings` | No | Animation timing overrides |
|
|
160
|
+
|
|
161
|
+
**`description` sub-fields:**
|
|
162
|
+
|
|
163
|
+
| Key | Type |
|
|
164
|
+
| --------- | ------------------------------------------------ |
|
|
165
|
+
| `loading` | `ReactNode` |
|
|
166
|
+
| `success` | `ReactNode \| ((data: T) => ReactNode)` |
|
|
167
|
+
| `error` | `ReactNode \| ((error: unknown) => ReactNode)` |
|
|
168
|
+
|
|
169
|
+
**`action` sub-fields:**
|
|
170
|
+
|
|
171
|
+
| Key | Type |
|
|
172
|
+
| --------- | ----------------- |
|
|
173
|
+
| `success` | `GoeyToastAction` |
|
|
174
|
+
| `error` | `GoeyToastAction` |
|
|
175
|
+
|
|
176
|
+
## Usage Examples
|
|
177
|
+
|
|
178
|
+
### Description
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
goeyToast.error('Payment failed', {
|
|
182
|
+
description: 'Your card was declined. Please try again.',
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Custom React Component as Description
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
goeyToast.success('Deployment complete', {
|
|
190
|
+
description: (
|
|
191
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
|
192
|
+
<div>
|
|
193
|
+
<span>Environment:</span> <strong>Production</strong>
|
|
194
|
+
</div>
|
|
195
|
+
<div>
|
|
196
|
+
<span>Branch:</span> <strong>main @ 3f8a2c1</strong>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
),
|
|
200
|
+
})
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Action Button with Success Label
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
goeyToast.info('Share link ready', {
|
|
207
|
+
description: 'Your link has been generated.',
|
|
208
|
+
action: {
|
|
209
|
+
label: 'Copy to Clipboard',
|
|
210
|
+
onClick: () => navigator.clipboard.writeText(url),
|
|
211
|
+
successLabel: 'Copied!',
|
|
212
|
+
},
|
|
213
|
+
})
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Promise Toast
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
goeyToast.promise(saveData(), {
|
|
220
|
+
loading: 'Saving...',
|
|
221
|
+
success: 'Changes saved',
|
|
222
|
+
error: 'Something went wrong',
|
|
223
|
+
description: {
|
|
224
|
+
success: 'All changes have been synced.',
|
|
225
|
+
error: 'Please try again later.',
|
|
226
|
+
},
|
|
227
|
+
action: {
|
|
228
|
+
error: {
|
|
229
|
+
label: 'Retry',
|
|
230
|
+
onClick: () => retry(),
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Custom Styling
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
goeyToast.success('Styled!', {
|
|
240
|
+
fillColor: '#1a1a2e',
|
|
241
|
+
borderColor: '#333',
|
|
242
|
+
borderWidth: 2,
|
|
243
|
+
classNames: {
|
|
244
|
+
wrapper: 'my-wrapper',
|
|
245
|
+
title: 'my-title',
|
|
246
|
+
description: 'my-desc',
|
|
247
|
+
actionButton: 'my-btn',
|
|
248
|
+
},
|
|
249
|
+
})
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Custom Timing
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
goeyToast.success('Saved', {
|
|
256
|
+
description: 'Your changes have been synced.',
|
|
257
|
+
timing: {
|
|
258
|
+
expandDelay: 200,
|
|
259
|
+
expandDuration: 0.6,
|
|
260
|
+
collapseDuration: 0.6,
|
|
261
|
+
displayDuration: 5000,
|
|
262
|
+
},
|
|
263
|
+
})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Exports
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
// Components
|
|
270
|
+
export { GoeyToaster } from 'goey-toast'
|
|
271
|
+
|
|
272
|
+
// Toast function
|
|
273
|
+
export { goeyToast } from 'goey-toast'
|
|
274
|
+
|
|
275
|
+
// Types
|
|
276
|
+
export type {
|
|
277
|
+
GoeyToastOptions,
|
|
278
|
+
GoeyPromiseData,
|
|
279
|
+
GoeyToasterProps,
|
|
280
|
+
GoeyToastAction,
|
|
281
|
+
GoeyToastClassNames,
|
|
282
|
+
GoeyToastTimings,
|
|
283
|
+
} from 'goey-toast'
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Browser Support
|
|
287
|
+
|
|
288
|
+
goey-toast works in all modern browsers that support:
|
|
289
|
+
|
|
290
|
+
- CSS Modules
|
|
291
|
+
- SVG path animations
|
|
292
|
+
- ResizeObserver
|
|
293
|
+
- `framer-motion` (Chrome, Firefox, Safari, Edge)
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
[MIT](./LICENSE)
|