@synerise/ds-toast 1.4.26 → 1.4.27
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/CHANGELOG.md +4 -0
- package/CLAUDE.md +137 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.4.27](https://github.com/Synerise/synerise-design/compare/@synerise/ds-toast@1.4.26...@synerise/ds-toast@1.4.27) (2026-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-toast
|
|
9
|
+
|
|
6
10
|
## [1.4.26](https://github.com/Synerise/synerise-design/compare/@synerise/ds-toast@1.4.25...@synerise/ds-toast@1.4.26) (2026-06-17)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @synerise/ds-toast
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Toast (`@synerise/ds-toast`)
|
|
2
|
+
> A notification toast component built on `react-hot-toast` that displays status messages with optional description, close button, expandable content, and action buttons.
|
|
3
|
+
|
|
4
|
+
## Package structure
|
|
5
|
+
```
|
|
6
|
+
src/
|
|
7
|
+
Toast.tsx — Toast component and showToast imperative function; attaches static methods
|
|
8
|
+
Toast.types.ts — ToastType, ToastProps, ShowToastProps, ToastCustomisationOptions
|
|
9
|
+
Toast.styles.ts — All styled-components (Container, AnimationContainer, AlertMessage, etc.)
|
|
10
|
+
constants.tsx — ICONS map: ToastType → ds-icon ReactNode
|
|
11
|
+
index.ts — Public re-exports
|
|
12
|
+
utils/
|
|
13
|
+
dismissToast.ts — Re-exports toast.dismiss from react-hot-toast (animated exit)
|
|
14
|
+
removeToast.ts — Re-exports toast.remove from react-hot-toast (instant removal)
|
|
15
|
+
index.ts — Re-exports both utils
|
|
16
|
+
__specs__/
|
|
17
|
+
Toast.spec.tsx — Vitest tests (renderWithProvider + TOASTER_DEFAULTS from ds-core)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Public exports
|
|
21
|
+
All of the following are exported from the package root (`index.ts`):
|
|
22
|
+
|
|
23
|
+
- `Toast` (default export + named) — the React component
|
|
24
|
+
- `showToast` — imperative function to show a toast via react-hot-toast's Toaster
|
|
25
|
+
- `dismissToast` — alias for `toast.dismiss` (animated exit, optional toastId)
|
|
26
|
+
- `removeToast` — alias for `toast.remove` (instant removal, optional toastId)
|
|
27
|
+
- `ICONS` — `Record<ToastType, ReactNode>` mapping types to ds-icon components
|
|
28
|
+
- `ToastProps` (type)
|
|
29
|
+
|
|
30
|
+
### `Toast` component
|
|
31
|
+
| Prop | Type | Default | Description |
|
|
32
|
+
|------|------|---------|-------------|
|
|
33
|
+
| `type` | `'success' \| 'warning' \| 'negative' \| 'informative'` | — | Controls the icon and top-border accent color |
|
|
34
|
+
| `message` | `ReactNode` | — | Primary message text (bold, 14px) |
|
|
35
|
+
| `description` | `ReactNode` | — | Secondary text below message (13px) |
|
|
36
|
+
| `customIcon` | `ReactElement` | — | Overrides the default type icon |
|
|
37
|
+
| `expander` | `boolean` | — | Shows an `AngleDownS` chevron that toggles `expandedContent` |
|
|
38
|
+
| `expandedContent` | `ReactNode` | — | Content revealed when `expanded` is true; visibility is CSS-toggled |
|
|
39
|
+
| `expanded` | `boolean` | — | Controls whether `expandedContent` is visible |
|
|
40
|
+
| `onExpand` | `(isExpanded: boolean) => void` | — | Called when the expander chevron is clicked |
|
|
41
|
+
| `withClose` | `boolean` | — | Renders a `CloseM` icon that dismisses the toast |
|
|
42
|
+
| `onCloseClick` | `() => void` | — | Called when close icon is clicked (fires before `toast.dismiss`) |
|
|
43
|
+
| `onDismiss` | `() => void` | — | Called on component unmount (covers both manual and timeout dismissal) |
|
|
44
|
+
| `button` | `ReactNode` | — | Action element rendered below description/expandedContent |
|
|
45
|
+
| `toastId` | `string` | — | ID used when calling `toast.dismiss` from the close button |
|
|
46
|
+
| `show` | `boolean` | `true` | Drives enter/exit animation (`AnimationContainer`); set by react-hot-toast internally |
|
|
47
|
+
|
|
48
|
+
Extends `WithHTMLAttributes<HTMLDivElement, ..>` — all standard div props are passed to the inner `Container`.
|
|
49
|
+
|
|
50
|
+
### `showToast(type, props, options?)`
|
|
51
|
+
| Param | Type | Description |
|
|
52
|
+
|-------|------|-------------|
|
|
53
|
+
| `type` | `ToastType` | Toast variant |
|
|
54
|
+
| `props` | `ShowToastProps` | All `ToastProps` except `type` and `show` |
|
|
55
|
+
| `options` | `ToastCustomisationOptions` | Subset of react-hot-toast `ToastOptions`: `duration`, `position`, `id`, `removeDelay`, `className`, `style` |
|
|
56
|
+
|
|
57
|
+
Returns the `toastId` string. If `props.toastId` is not provided a `uuid` is generated.
|
|
58
|
+
|
|
59
|
+
### Static shortcut methods on `Toast`
|
|
60
|
+
| Method | Maps to type |
|
|
61
|
+
|--------|-------------|
|
|
62
|
+
| `Toast.success(props, options?)` | `'success'` |
|
|
63
|
+
| `Toast.error(props, options?)` | `'negative'` |
|
|
64
|
+
| `Toast.info(props, options?)` | `'informative'` |
|
|
65
|
+
| `Toast.warning(props, options?)` | `'warning'` |
|
|
66
|
+
|
|
67
|
+
## Usage patterns
|
|
68
|
+
|
|
69
|
+
### Imperative (Toaster-based, recommended)
|
|
70
|
+
```tsx
|
|
71
|
+
import Toast from '@synerise/ds-toast';
|
|
72
|
+
|
|
73
|
+
// Static shortcut
|
|
74
|
+
Toast.success({ message: 'Campaign saved!' });
|
|
75
|
+
Toast.error({ message: 'Failed', description: 'No response from server' });
|
|
76
|
+
|
|
77
|
+
// With custom duration and explicit id
|
|
78
|
+
Toast.warning({ message: 'Slow connection' }, { duration: 5000, id: 'my-toast' });
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Programmatic with full control
|
|
82
|
+
```tsx
|
|
83
|
+
import { showToast, dismissToast, removeToast } from '@synerise/ds-toast';
|
|
84
|
+
|
|
85
|
+
const id = showToast('informative', { message: 'Loading..', withClose: true });
|
|
86
|
+
|
|
87
|
+
// Later — animated dismiss or instant remove
|
|
88
|
+
dismissToast(id); // fade-out animation
|
|
89
|
+
removeToast(id); // instant removal
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Controlled expandable toast
|
|
93
|
+
```tsx
|
|
94
|
+
import Toast from '@synerise/ds-toast';
|
|
95
|
+
|
|
96
|
+
<Toast
|
|
97
|
+
type="warning"
|
|
98
|
+
message="3 records failed"
|
|
99
|
+
expander
|
|
100
|
+
expanded={isExpanded}
|
|
101
|
+
onExpand={setIsExpanded}
|
|
102
|
+
expandedContent={<ul>..</ul>}
|
|
103
|
+
/>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Inline (no Toaster required)
|
|
107
|
+
The `Toast` component can be rendered directly in JSX without react-hot-toast's `Toaster`. The `show` prop is only needed when driving the animation externally.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import Toast from '@synerise/ds-toast';
|
|
111
|
+
|
|
112
|
+
<Toast type="success" message="Saved!" withClose onCloseClick={handleClose} />
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Styling
|
|
116
|
+
- `Container` renders a white card (`border-radius: 4px`, `box-shadow: 0 16px 32px 0 rgba(35,41,54,0.12)`, `max-width: 500px`) with a 2px top border in the accent color for the type.
|
|
117
|
+
- Accent colors (icon fill + top border): success → `green-600`, warning → `yellow-600`, negative → `red-500`, informative → `grey-600`.
|
|
118
|
+
- `AnimationContainer` plays `openingAnimation` (slide up + fade in from `translateY(60px)`) when `$show=true` and `closingAnimation` (fade out + slight scale-down + `translateY(-8px)`) when `$show=false`. Duration is `0.6s cubic-bezier(0.4,0,0.2,1)`.
|
|
119
|
+
- `AlertMessage` right-padding is computed dynamically: 24px (no icons), 48px (close or expander), 72px (both).
|
|
120
|
+
- `expandedContent` is shown/hidden via `visibility + height: auto/0` (not `display: none`), preserving layout flow.
|
|
121
|
+
- Depends on `@synerise/ds-unordered-list` styles (`UnorderedList` selector used inside `AlertContent`).
|
|
122
|
+
|
|
123
|
+
## Key dependencies
|
|
124
|
+
- `react-hot-toast ^2.5.2` — Toaster and imperative toast API
|
|
125
|
+
- `uuid ^8.3.2` — Auto-generates `toastId` when not provided
|
|
126
|
+
- `@synerise/ds-icon` — `Check3M`, `WarningFillM`, `InfoFillM`, `AngleDownS`, `CloseM`
|
|
127
|
+
- `@synerise/ds-unordered-list` — style import for list layout inside expanded content
|
|
128
|
+
- `@synerise/ds-core` (peer) — theme tokens; `DSProvider` embeds the Toaster via `TOASTER_DEFAULTS`
|
|
129
|
+
- `@synerise/ds-utils` — `WithHTMLAttributes` utility type
|
|
130
|
+
|
|
131
|
+
## Implementation notes
|
|
132
|
+
- `onDismiss` is fired from a `useEffect` cleanup (component unmount), not from the close click handler. It therefore fires for both manual dismissal and timeout expiry.
|
|
133
|
+
- `onCloseClick` fires first, then `toast.dismiss(toastId)` is called — both only if `toastId` is present.
|
|
134
|
+
- `Toast.error` maps to type `'negative'` (not `'error'`). There is no `'error'` type in `ToastType`.
|
|
135
|
+
- The Toaster must be mounted for imperative toasts to render. In tests this is done via `renderWithProvider(.., { toasterProps: TOASTER_DEFAULTS })` from `@synerise/ds-core`.
|
|
136
|
+
- Tests use **Jest** (not Vitest) — see `jest.config.js`.
|
|
137
|
+
- `FirstButtonWrapper` and `Wrapper` styled-components are exported from `dist/Toast.styles` (not from the package root) and used in Storybook stories for layout.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-toast",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.27",
|
|
4
4
|
"description": "Toast UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"/dist",
|
|
19
19
|
"CHANGELOG.md",
|
|
20
|
+
"CLAUDE.md",
|
|
20
21
|
"README.md",
|
|
21
22
|
"package.json",
|
|
22
23
|
"LICENSE.md"
|
|
@@ -41,9 +42,9 @@
|
|
|
41
42
|
],
|
|
42
43
|
"types": "dist/index.d.ts",
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@synerise/ds-icon": "^1.18.
|
|
45
|
-
"@synerise/ds-unordered-list": "^1.1.
|
|
46
|
-
"@synerise/ds-utils": "^1.10.
|
|
45
|
+
"@synerise/ds-icon": "^1.18.5",
|
|
46
|
+
"@synerise/ds-unordered-list": "^1.1.54",
|
|
47
|
+
"@synerise/ds-utils": "^1.10.2",
|
|
47
48
|
"react-hot-toast": "^2.6.0",
|
|
48
49
|
"uuid": "^8.3.2"
|
|
49
50
|
},
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"styled-components": "^5.3.3",
|
|
54
55
|
"vitest": "4"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
|
|
57
58
|
}
|