@samline/notify 0.2.7 → 1.0.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.
Files changed (46) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +121 -150
  3. package/dist/browser-notify.js +69 -0
  4. package/dist/cc-2Yt7NqMX.mjs +21 -0
  5. package/dist/cc-B6peeNak.mjs +33 -0
  6. package/dist/cc-BWuAzFJ6.js +12 -0
  7. package/dist/cc-CaBHsjUt.js +34 -0
  8. package/dist/cc-DGff5sSY.js +21 -0
  9. package/dist/cc-he3fHS3P.mjs +12 -0
  10. package/dist/notify.d.mts +44 -0
  11. package/dist/notify.d.mts.map +1 -0
  12. package/dist/notify.d.ts +44 -0
  13. package/dist/notify.d.ts.map +1 -0
  14. package/dist/notify.js +90 -0
  15. package/dist/notify.mjs +87 -0
  16. package/dist/react-notify-12s-7LOZlSBi.js +1068 -0
  17. package/dist/react-notify-12s-BjWbwTu8.mjs +1066 -0
  18. package/dist/react.d.mts +66 -0
  19. package/dist/react.d.mts.map +1 -0
  20. package/dist/react.d.ts +66 -0
  21. package/dist/react.d.ts.map +1 -0
  22. package/dist/react.js +18 -0
  23. package/dist/react.mjs +10 -0
  24. package/dist/styles.css +477 -89
  25. package/dist/svelte.d.mts +45 -0
  26. package/dist/svelte.d.mts.map +1 -0
  27. package/dist/svelte.d.ts +45 -0
  28. package/dist/svelte.d.ts.map +1 -0
  29. package/dist/svelte.js +168 -0
  30. package/dist/svelte.mjs +165 -0
  31. package/dist/vue.d.mts +103 -0
  32. package/dist/vue.d.mts.map +1 -0
  33. package/dist/vue.d.ts +103 -0
  34. package/dist/vue.d.ts.map +1 -0
  35. package/dist/vue.js +2099 -0
  36. package/dist/vue.mjs +2096 -0
  37. package/package.json +95 -57
  38. package/dist/index.cjs.js +0 -1249
  39. package/dist/index.esm.js +0 -1242
  40. package/dist/notify.umd.js +0 -1255
  41. package/docs/browser.md +0 -92
  42. package/docs/react.md +0 -275
  43. package/docs/svelte.md +0 -267
  44. package/docs/vanilla.md +0 -256
  45. package/docs/vue.md +0 -301
  46. package/rollup.config.mjs +0 -56
package/docs/browser.md DELETED
@@ -1,92 +0,0 @@
1
-
2
- # Browser / CDN usage
3
-
4
- Use this package directly in the browser when you cannot use npm modules or a bundler (e.g. Shopify, WordPress, static HTML).
5
-
6
- ## Quick start
7
-
8
- Add the stylesheet and UMD bundle to your HTML:
9
-
10
- ```html
11
- <link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.7/dist/styles.css">
12
- <script src="https://unpkg.com/@samline/notify@0.2.7/dist/notify.umd.js"></script>
13
- <script>
14
- document.addEventListener('DOMContentLoaded', () => {
15
- const api = window.notify; // or window.notifications for legacy
16
- // Always use an array of strings as the second argument
17
- // Correct usage:
18
- api.initToasters(document.body, ['top-left']);
19
- api.notify({ title: 'Hello', description: 'No-bundler usage', type: 'info' });
20
- });
21
- </script>
22
- ```
23
-
24
-
25
-
26
- ## API
27
-
28
- - The UMD bundle exposes `window.notify` (recommended) and `window.notifications` (legacy/compatibility).
29
- - Always include `dist/styles.css` for correct appearance and animations.
30
- - Use `api.initToasters(container, positions, { offset, options, theme })` to mount containers (usually `document.body`).
31
- - Use `api.notify({...})` to show a notification.
32
-
33
- ### ⚠️ Warnings and Best Practices
34
-
35
- - The second argument to `initToasters` **must be an array of strings** (e.g. `['top-left']`).
36
- - **Do not use** `document.body['top-left']` (this is `undefined` and will not work).
37
- - If you initialize only one position, toasts without an explicit position will go there automatically (dynamic fallback).
38
- - If you initialize multiple positions, toasts without an explicit position will go to `'top-right'` by default.
39
- - If you notify to a position that was not initialized, you will see a warning in the console and the toast will not be shown.
40
-
41
- ### Advanced Options
42
-
43
- <link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.7/dist/styles.css">
44
- <script src="https://unpkg.com/@samline/notify@0.2.7/dist/notify.umd.js"></script>
45
- | Property | Type | Default | Description |
46
- | ------------- | -------------------------------------- | ----------- | ------------------------------------------- |
47
- | `title` | string | — | Toast title |
48
- | `description` | string | — | Optional body text (HTML or string) |
49
- | `type` | `info\|success\|error\|warning\|action`| `info` | Visual intent |
50
- | `position` | string | `top-right` | One of toast positions |
51
- | `duration` | number \| null | `4000` | Auto-dismiss timeout in ms (null = sticky) |
52
- | `button` | { title: string, onClick: () => void } | — | Optional action button |
53
- | `icon` | string | — | Custom icon (SVG or HTML) |
54
- | `fill` | string | — | Custom background color (SVG or badge) |
55
- | `styles` | { title, description, badge, button } | — | Custom class overrides for sub-elements |
56
- | `roundness` | number | 16 | Border radius in pixels |
57
- | `autopilot` | boolean \| object | true | Auto expand/collapse timing |
58
- <script src="https://unpkg.com/@samline/notify@0.2.7/dist/notify.umd.js"></script>
59
- <link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.7/dist/styles.css" />
60
-
61
- ```js
62
- api.success({
63
- title: "Styled!",
64
- fill: "#222",
65
- icon: '<svg>...</svg>',
66
- styles: {
67
- title: "text-white!",
68
- badge: "bg-white/20!",
69
- button: "bg-white/10!"
70
- },
71
- roundness: 24,
72
- autopilot: false
73
- });
74
- ```
75
-
76
- ### Toaster Options
77
-
78
-
79
- You can pass advanced options to `initToasters`:
80
-
81
- ```js
82
- // Correct example with multiple positions
83
- api.initToasters(document.body, ['top-right', 'bottom-left'], {
84
- offset: { top: 32, right: 16 },
85
- options: { fill: '#222', roundness: 20 },
86
- theme: 'dark'
87
- });
88
- ```
89
-
90
- ## Notes
91
-
92
- - If you need more control or want to avoid global variables, use the ESM/CJS builds with a bundler.
package/docs/react.md DELETED
@@ -1,275 +0,0 @@
1
-
2
- # React
3
-
4
- ## Quick start
5
-
6
- Install the package and peer dependencies:
7
-
8
- ```bash
9
- npm install @samline/notify react react-dom
10
- ```
11
-
12
- Import and render the `Toaster` component in your app root:
13
-
14
- ```tsx
15
- import React from 'react';
16
-
17
- import { Toaster, notify } from '@samline/notify/react';
18
-
19
- export function App() {
20
- return (
21
- <>
22
- <Toaster />
23
- <button onClick={() => notify.show({ title: 'Done', type: 'success' })}>Show</button>
24
- </>
25
- );
26
- }
27
- ```
28
-
29
- ## Methods: Full Examples
30
-
31
- ```tsx
32
- // Show a generic toast
33
- notify.show({ title: 'Hello', description: 'Generic toast', type: 'info' });
34
-
35
- // Success toast
36
- notify.success({ title: 'Success!', description: 'Operation completed.' });
37
-
38
- // Error toast
39
- notify.error({ title: 'Error', description: 'Something went wrong.' });
40
-
41
- // Info toast
42
- notify.info({ title: 'Heads up!', description: 'This is an info toast.' });
43
-
44
- // Warning toast
45
- notify.warning({ title: 'Warning!', description: 'Be careful.' });
46
-
47
- // Action toast with button
48
- notify.action({
49
- title: 'Action required',
50
- description: 'Click the button to proceed.',
51
- button: { title: 'Proceed', onClick: () => alert('Action!') }
52
- });
53
-
54
- // Promise toast (loading, success, error, action)
55
- notify.promise(fetch('/api/save'), {
56
- loading: { title: 'Saving...' },
57
- success: { title: 'Saved!', description: 'Your data was saved.' },
58
- error: { title: 'Failed', description: 'Could not save.' },
59
- action: { title: 'Retry?', button: { title: 'Retry', onClick: () => {/* retry logic */} } }
60
- });
61
-
62
- // Dismiss a toast by id
63
- const id = notify.success({ title: 'Dismiss me' });
64
- notify.dismiss(id);
65
-
66
- // Clear all toasts
67
- notify.clear();
68
-
69
- // Clear only a position
70
- notify.clear('top-right');
71
- ```
72
-
73
- > **Note:**
74
- > Import `@samline/notify/dist/styles.css` in your main entrypoint or include it in your HTML for correct appearance.
75
-
76
-
77
-
78
- ## API
79
-
80
- - `<Toaster />` subscribes to the notification controller and renders toasts.
81
- - Use `notify.show({...})` or shortcut methods (`notify.success`, `notify.error`, `notify.info`, `notify.warning`, `notify.action`, `notify.promise`, `notify.dismiss`, `notify.clear`) to trigger notifications. Import from `@samline/notify/react`.
82
-
83
- ### Methods
84
-
85
- ```ts
86
- notify.show(options)
87
- notify.success(options)
88
- notify.error(options)
89
- notify.info(options)
90
- notify.warning(options)
91
- notify.action(options)
92
- notify.promise(promise, { loading, success, error })
93
- notify.dismiss(id)
94
- notify.clear()
95
- ```
96
-
97
- ### Options
98
-
99
- All notification methods accept advanced options:
100
-
101
- | Property | Type | Default | Description |
102
- | ------------- | -------------------------------------- | ----------- | ------------------------------------------- |
103
- | `title` | string | — | Toast title |
104
- | `description` | string \| ReactNode | — | Optional body text (JSX or string) |
105
- | `type` | `info\|success\|error\|warning\|action`| `info` | Visual intent |
106
- | `position` | string | `top-right` | One of the valid positions. If you only initialize one position with `<Toaster position="..." />`, toasts without an explicit position will go there (dynamic fallback). If you initialize multiple, the fallback is `top-right`. |
107
- | `duration` | number \| null | `4000` | Auto-dismiss timeout in ms (null = sticky) |
108
- | `button` | { title: string, onClick: () => void } | — | Optional action button |
109
- | `icon` | string \| ReactNode | — | Custom icon (SVG or JSX) |
110
- | `fill` | string | — | Custom background color (SVG or badge) |
111
- | `styles` | { title, description, badge, button } | — | Custom class overrides for sub-elements |
112
- | `roundness` | number | 16 | Border radius in pixels |
113
- | `autopilot` | boolean \| object | true | Auto expand/collapse timing |
114
-
115
- #### Example: Advanced Toasts
116
-
117
- ```tsx
118
- // Custom icon (SVG string or JSX)
119
- notify.success({
120
- title: 'With Icon',
121
- icon: <svg width="16" height="16" ...>...</svg>
122
- });
123
-
124
- // Custom fill color
125
- notify.info({
126
- title: 'Colored',
127
- fill: '#2563eb'
128
- });
129
-
130
- // Custom styles for sub-elements
131
- notify.success({
132
- title: 'Styled',
133
- styles: {
134
- title: 'my-title-class',
135
- badge: 'my-badge-class',
136
- button: 'my-btn-class'
137
- }
138
- });
139
-
140
- // Custom roundness
141
- notify.success({
142
- title: 'Rounded',
143
- roundness: 32
144
- });
145
-
146
- // Autopilot off (manual expand/collapse)
147
- notify.success({
148
- title: 'Manual',
149
- autopilot: false
150
- });
151
-
152
- // Custom duration (sticky)
153
- notify.info({
154
- title: 'Sticky',
155
- duration: null
156
- });
157
-
158
- // Custom position (make sure you initialized that position with <Toaster position="bottom-left" />)
159
- notify.success({
160
- title: 'Bottom left',
161
- position: 'bottom-left'
162
- });
163
- ---
164
-
165
- ## ⚠️ Warnings and Best Practices
166
-
167
- - If you only use one `<Toaster position="..." />`, toasts without an explicit position will go there automatically (dynamic fallback).
168
- - If you use multiple `<Toaster position="..." />`, the fallback will be `top-right`.
169
- - If you notify to a position that was not initialized, you will see a warning in the console and the toast will not be shown.
170
-
171
- // Description as ReactNode
172
- notify.info({
173
- title: 'JSX Description',
174
- description: <span style={{ color: 'red' }}>Custom JSX content</span>
175
- });
176
- ```
177
-
178
- #### Example: Advanced Toast
179
-
180
- ```tsx
181
- notify.success({
182
- title: "Styled!",
183
- fill: "#222",
184
- icon: '<svg>...</svg>',
185
- styles: {
186
- title: "text-white!",
187
- badge: "bg-white/20!",
188
- button: "bg-white/10!"
189
- },
190
- roundness: 24,
191
- autopilot: false
192
- });
193
- ```
194
-
195
- #### Promise Toasts
196
-
197
- ```tsx
198
- notify.promise(fetchData(), {
199
- loading: { title: "Loading..." },
200
- success: (data) => ({ title: `Loaded ${data.name}` }),
201
- error: (err) => ({ title: "Error", description: err.message }),
202
- action: (data) => ({ title: "Action required", button: { title: "Retry", onClick: () => retry() } })
203
- });
204
- ```
205
-
206
- ### Toaster Component Props
207
-
208
- The `<Toaster />` component accepts the following props:
209
-
210
- | Prop | Type | Default | Description |
211
- | --------- | ----------------------------------------- | ------------ | ------------------------------------------- |
212
- | `position`| string | top-right | Default toast position |
213
- | `offset` | number \| string \| {top,right,bottom,left}| 0 | Distance from viewport edges |
214
- | `options` | Partial<Options> | — | Default options for all toasts |
215
- | `theme` | "light" \| "dark" \| "system" | system | Color scheme (auto, light, dark) |
216
-
217
- #### Example: Custom Toaster
218
-
219
- ```tsx
220
- <Toaster position="bottom-center" offset={24} theme="dark" options={{ fill: '#222', roundness: 20 }} />
221
- ```
222
-
223
- ## Customizing Styles
224
-
225
- - Override CSS variables in your stylesheet or inline:
226
-
227
- ```css
228
- :root {
229
- --sileo-bg: #18181b;
230
- --sileo-success: #22c55e;
231
- --sileo-error: #ef4444;
232
- --sileo-info: #2563eb;
233
- --sileo-warning: #f59e0b;
234
- }
235
- ```
236
-
237
- - Add custom classes via the `styles` option for title, badge, button, description.
238
-
239
- ## Accessibility
240
-
241
- - Toast containers use `role="status"` and `aria-live="polite"`.
242
- - Respects `prefers-reduced-motion` for users with motion sensitivity.
243
-
244
- ## Common Errors & Troubleshooting
245
-
246
- - **No styles?** Make sure to import or link `dist/styles.css`.
247
- - **No animation?** Check that the `motion` dependency is installed for ESM/bundler usage.
248
- - **Button not working?** Ensure your `onClick` is a function and not a string.
249
- - **Nothing appears?** Confirm you rendered `<Toaster />` and are using the correct import.
250
-
251
- ## Migration & Best Practices
252
-
253
- - If migrating from Sileo, all options and methods are compatible.
254
- - Prefer using `notify.success`, `notify.error`, etc. for intent clarity.
255
- - Use `notify.clear()` to remove all toasts, or pass a position to clear only one area.
256
-
257
- ---
258
-
259
- For other frameworks, see the Vue, Svelte, and Vanilla guides.
260
- | `duration` | number | `4000` | Auto-dismiss timeout in ms (0 = persistent) |
261
- | `button` | { title: string, onClick: () => void } | — | Optional action button |
262
-
263
- ## Tips
264
-
265
- - You can customize positions and styles by overriding CSS variables or importing the stylesheet in your preferred way.
266
-
267
- ## API
268
-
269
- - `Toaster` component: mounts a toast container and subscribes to the core controller.
270
- - Primary API: use `notify` (e.g. `notify.show(...)`). A backward-compatible `sileo` alias is also available: `sileo.show(...)`.
271
-
272
- ## Notes
273
-
274
- - The React adapter renders toasts in a React-friendly way and is SSR-safe when used with client-only mounting.
275
- - To customize styles, import `dist/styles.css` or override the CSS variables defined in the stylesheet.
package/docs/svelte.md DELETED
@@ -1,267 +0,0 @@
1
-
2
- # Svelte
3
-
4
- ## Quick start
5
-
6
- Install the package:
7
-
8
- ```bash
9
- npm install @samline/notify svelte
10
- ```
11
-
12
- Import and initialize in your root component:
13
-
14
- ```svelte
15
- <script>
16
- import Toaster, { initSileoStore } from '@samline/notify/svelte';
17
- initSileoStore(); // Call once in your app root
18
-
19
- import { notify } from '@samline/notify/svelte';
20
- function show() {
21
- notify.show({ title: 'From Svelte' });
22
- }
23
- </script>
24
-
25
- <Toaster />
26
- <button on:click={show}>Show</button>
27
- ```
28
-
29
- ## Methods: Full Examples
30
-
31
- ```svelte
32
- // Show a generic toast
33
- notify.show({ title: 'Hello', description: 'Generic toast', type: 'info' });
34
-
35
- // Success toast
36
- notify.success({ title: 'Success!', description: 'Operation completed.' });
37
-
38
- // Error toast
39
- notify.error({ title: 'Error', description: 'Something went wrong.' });
40
-
41
- // Info toast
42
- notify.info({ title: 'Heads up!', description: 'This is an info toast.' });
43
-
44
- // Warning toast
45
- notify.warning({ title: 'Warning!', description: 'Be careful.' });
46
-
47
- // Action toast with button
48
- notify.action({
49
- title: 'Action required',
50
- description: 'Click the button to proceed.',
51
- button: { title: 'Proceed', onClick: () => alert('Action!') }
52
- });
53
-
54
- // Promise toast (loading, success, error, action)
55
- notify.promise(fetch('/api/save'), {
56
- loading: { title: 'Saving...' },
57
- success: { title: 'Saved!', description: 'Your data was saved.' },
58
- error: { title: 'Failed', description: 'Could not save.' },
59
- action: { title: 'Retry?', button: { title: 'Retry', onClick: () => {/* retry logic */} } }
60
- });
61
-
62
- // Dismiss a toast by id
63
- const id = notify.success({ title: 'Dismiss me' });
64
- notify.dismiss(id);
65
-
66
- // Clear all toasts
67
- notify.clear();
68
-
69
- // Clear only a position
70
- notify.clear('top-right');
71
- ```
72
-
73
- > **Note:**
74
- > Import `@samline/notify/dist/styles.css` in your main entrypoint or HTML for correct appearance.
75
-
76
-
77
-
78
- ## API
79
-
80
- - `Toaster.svelte`: Renders notifications and subscribes to the core controller.
81
- - `initSileoStore()`: Wires the notification controller to a Svelte store (call once in your app root).
82
- - Use `notify.show({...})` or shortcut methods to trigger notifications. Import from `@samline/notify/svelte` (now available directly).
83
-
84
- ### Methods
85
-
86
- ```ts
87
- notify.show(options)
88
- notify.success(options)
89
- notify.error(options)
90
- notify.info(options)
91
- notify.warning(options)
92
- notify.action(options)
93
- notify.promise(promise, { loading, success, error })
94
- notify.dismiss(id)
95
- notify.clear()
96
- ```
97
-
98
- ### Options
99
-
100
- All notification methods accept advanced options:
101
-
102
- | Property | Type | Default | Description |
103
- | ------------- | -------------------------------------- | ----------- | ------------------------------------------- |
104
- | `title` | string | — | Toast title |
105
- | `description` | string \| SvelteNode | — | Optional body text (HTML or string) |
106
- | `type` | `info\|success\|error\|warning\|action`| `info` | Visual intent |
107
- | `position` | string | `top-right` | One of the valid positions. If you only initialize one position with `<Toaster position="..." />`, toasts without an explicit position will go there (dynamic fallback). If you initialize multiple, the fallback is `top-right`. |
108
- | `duration` | number \| null | `4000` | Auto-dismiss timeout in ms (null = sticky) |
109
- | `button` | { title: string, onClick: () => void } | — | Optional action button |
110
- | `icon` | string \| SvelteNode | — | Custom icon (SVG or node) |
111
- | `fill` | string | — | Custom background color (SVG or badge) |
112
- | `styles` | { title, description, badge, button } | — | Custom class overrides for sub-elements |
113
- | `roundness` | number | 16 | Border radius in pixels |
114
- | `autopilot` | boolean \| object | true | Auto expand/collapse timing |
115
-
116
- #### Example: Advanced Toasts
117
-
118
- ```svelte
119
- // Custom icon (SVG string or SvelteNode)
120
- notify.success({
121
- title: 'With Icon',
122
- icon: '<svg width="16" height="16" ...>...</svg>'
123
- });
124
-
125
- // Custom fill color
126
- notify.info({
127
- title: 'Colored',
128
- fill: '#2563eb'
129
- });
130
-
131
- // Custom styles for sub-elements
132
- notify.success({
133
- title: 'Styled',
134
- styles: {
135
- title: 'my-title-class',
136
- badge: 'my-badge-class',
137
- button: 'my-btn-class'
138
- }
139
- });
140
-
141
- // Custom roundness
142
- notify.success({
143
- title: 'Rounded',
144
- roundness: 32
145
- });
146
-
147
- // Autopilot off (manual expand/collapse)
148
- notify.success({
149
- title: 'Manual',
150
- autopilot: false
151
- });
152
-
153
- // Custom duration (sticky)
154
- notify.info({
155
- title: 'Sticky',
156
- duration: null
157
- });
158
-
159
- // Custom position (make sure you initialized that position with <Toaster position="bottom-left" />)
160
- notify.success({
161
- title: 'Bottom left',
162
- position: 'bottom-left'
163
- });
164
- ---
165
-
166
- ## ⚠️ Warnings and Best Practices
167
-
168
- - If you only use one `<Toaster position="..." />`, toasts without an explicit position will go there automatically (dynamic fallback).
169
- - If you use multiple `<Toaster position="..." />`, the fallback will be `top-right`.
170
- - If you notify to a position that was not initialized, you will see a warning in the console and the toast will not be shown.
171
-
172
- // Description as SvelteNode
173
- notify.info({
174
- title: 'Node Description',
175
- description: '<span style="color: red">Custom HTML content</span>'
176
- });
177
- ```
178
-
179
- #### Example: Advanced Toast
180
-
181
- ```svelte
182
- notify.success({
183
- title: "Styled!",
184
- fill: "#222",
185
- icon: '<svg>...</svg>',
186
- styles: {
187
- title: "text-white!",
188
- badge: "bg-white/20!",
189
- button: "bg-white/10!"
190
- },
191
- roundness: 24,
192
- autopilot: false
193
- });
194
- ```
195
-
196
- #### Promise Toasts
197
-
198
- ```svelte
199
- notify.promise(fetchData(), {
200
- loading: { title: "Loading..." },
201
- success: (data) => ({ title: `Loaded ${data.name}` }),
202
- error: (err) => ({ title: "Error", description: err.message }),
203
- action: (data) => ({ title: "Action required", button: { title: "Retry", onClick: () => retry() } })
204
- });
205
- ```
206
-
207
- ### Toaster Component Props
208
-
209
- The `<Toaster />` component accepts the following props:
210
-
211
- | Prop | Type | Default | Description |
212
- | --------- | ----------------------------------------- | ------------ | ------------------------------------------- |
213
- | `position`| string | top-right | Default toast position |
214
- | `offset` | number \| string \| {top,right,bottom,left}| 0 | Distance from viewport edges |
215
- | `options` | Partial<Options> | — | Default options for all toasts |
216
- | `theme` | "light" \| "dark" \| "system" | system | Color scheme (auto, light, dark) |
217
-
218
- #### Example: Custom Toaster
219
-
220
- ```svelte
221
- <Toaster position="bottom-center" offset={24} theme="dark" options={{ fill: '#222', roundness: 20 }} />
222
- ```
223
-
224
- ## Customizing Styles
225
-
226
- - Override CSS variables in your stylesheet or inline:
227
-
228
- ```css
229
- :root {
230
- --sileo-bg: #18181b;
231
- --sileo-success: #22c55e;
232
- --sileo-error: #ef4444;
233
- --sileo-info: #2563eb;
234
- --sileo-warning: #f59e0b;
235
- }
236
- ```
237
-
238
- - Add custom classes via the `styles` option for title, badge, button, description.
239
-
240
- ## Accessibility
241
-
242
- - Toast containers use `role="status"` and `aria-live="polite"`.
243
- - Respects `prefers-reduced-motion` for users with motion sensitivity.
244
-
245
- ## Common Errors & Troubleshooting
246
-
247
- - **No styles?** Make sure to import or link `dist/styles.css`.
248
- - **No animation?** Check that the `motion` dependency is installed for ESM/bundler usage.
249
- - **Button not working?** Ensure your `onClick` is a function and not a string.
250
- - **Nothing appears?** Confirm you rendered `<Toaster />` and are using the correct import.
251
-
252
- ## Migration & Best Practices
253
-
254
- - If migrating from Sileo, all options and methods are compatible.
255
- - Prefer using `notify.success`, `notify.error`, etc. for intent clarity.
256
- - Use `notify.clear()` to remove all toasts, o pasar una posición para limpiar solo un área.
257
-
258
- ---
259
-
260
- For other frameworks, see the React, Vue, and Vanilla guides.
261
- | `duration` | number | `4000` | Auto-dismiss timeout in ms (0 = persistent) |
262
- | `button` | { title: string, onClick: () => void } | — | Optional action button |
263
-
264
- ## Tips
265
-
266
- - For TypeScript, use `npx svelte-check` and `npm run typecheck` during development.
267
- - You can customize styles by overriding CSS variables or importing the stylesheet as needed.