toast-builder-vue3 1.0.13 â 1.0.15
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 +325 -250
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +255 -238
- package/dist/index.es.js.map +1 -1
- package/package.json +30 -4
- package/src/lib/README.md +98 -25
- package/src/lib/components/Toast.vue +4 -4
- package/src/lib/components/ToastContainer.vue +29 -4
- package/src/lib/composables/useToast.ts +50 -7
- package/src/lib/constants/toast-defaults.ts +28 -0
- package/src/lib/types/toast.ts +27 -7
- package/dist/index.d.ts +0 -104
package/README.md
CHANGED
|
@@ -1,348 +1,423 @@
|
|
|
1
|
-
# Toast
|
|
1
|
+
# đ Toast Builder Vue3
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/toast-builder-vue3)
|
|
6
|
+
[](https://www.npmjs.com/package/toast-builder-vue3)
|
|
7
|
+
[](https://bundlephobia.com/package/toast-builder-vue3)
|
|
8
|
+
[](https://github.com/highpriv/toast-builder/blob/master/LICENSE)
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
**Modern, lightweight toast notification system for Vue 3 with TypeScript**
|
|
11
|
+
|
|
12
|
+
[Live Demo](https://toast-builder.vercel.app/) âĸ [NPM Package](https://www.npmjs.com/package/toast-builder-vue3) âĸ [GitHub](https://github.com/highpriv/toast-builder)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
11
15
|
|
|
12
16
|
---
|
|
13
17
|
|
|
14
|
-
## Features
|
|
18
|
+
## ⨠Features
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
- đ¨ **Fully Customizable** - Configure colors, icons, animations, and positions
|
|
21
|
+
- đ **3 Animation Styles** - Fade, slide, and bounce animations
|
|
22
|
+
- đ **6 Position Options** - Place toasts anywhere on the screen
|
|
23
|
+
- đŧī¸ **Custom Icons** - Use URLs, Base64, or built-in icons
|
|
24
|
+
- âąī¸ **Auto-dismiss** - Optional countdown with progress bar
|
|
25
|
+
- đą **Responsive** - Works on all screen sizes
|
|
26
|
+
- đ **Type-Safe** - Full TypeScript support
|
|
27
|
+
- đĒļ **Lightweight** - Minimal bundle size
|
|
28
|
+
- ⥠**Vite-powered** - Built with modern tooling
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
- 4 notification types (success, error, warning, info)
|
|
20
|
-
- Title and message inputs with validation
|
|
21
|
-
- Duration slider (1-10 seconds) or persistent mode
|
|
22
|
-
- 6 position options (top/bottom à left/center/right)
|
|
30
|
+
---
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
- Background and text color pickers with hex input
|
|
26
|
-
- Icon visibility toggle
|
|
27
|
-
- Close button toggle
|
|
28
|
-
- Progress bar toggle
|
|
32
|
+
## đĻ Installation
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
```bash
|
|
35
|
+
npm install toast-builder-vue3
|
|
36
|
+
```
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
- Save current configuration as named presets
|
|
34
|
-
- Load previously saved presets
|
|
35
|
-
- Delete unwanted presets
|
|
36
|
-
- Persistent storage using localStorage
|
|
38
|
+
Or with yarn:
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
```bash
|
|
41
|
+
yarn add toast-builder-vue3
|
|
42
|
+
```
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
Or with pnpm:
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- **Custom Icon Upload**: Upload custom icons with automatic compression (max 128Ã128, 100KB)
|
|
46
|
-
- **Custom Icon URLs**: Use external icon URLs with validation
|
|
47
|
-
- **Dark/Light Theme**: Toggle between themes with system preference detection
|
|
48
|
-
- **Built-in Icon Library**: 15 pre-configured icons for immediate use
|
|
46
|
+
```bash
|
|
47
|
+
pnpm add toast-builder-vue3
|
|
48
|
+
```
|
|
49
49
|
|
|
50
50
|
---
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## đ Quick Start
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
| ------------------ | ------- | ------------------------------------ |
|
|
56
|
-
| **Vue 3** | 3.5.25 | Frontend framework (Composition API) |
|
|
57
|
-
| **TypeScript** | 5.9 | Type safety and better DX |
|
|
58
|
-
| **Vite** | 7.3 | Build tool and dev server |
|
|
59
|
-
| **Jest** | 29.7 | Testing framework |
|
|
60
|
-
| **Vue Test Utils** | 2.4.6 | Vue component testing |
|
|
61
|
-
| **Nanoid** | 5.0.7 | Unique ID generation |
|
|
62
|
-
| **SCSS Modules** | - | Scoped styling |
|
|
54
|
+
### 1. Import CSS
|
|
63
55
|
|
|
64
|
-
|
|
56
|
+
In your `main.ts`:
|
|
65
57
|
|
|
66
|
-
|
|
58
|
+
```typescript
|
|
59
|
+
import { createApp } from "vue";
|
|
60
|
+
import App from "./App.vue";
|
|
61
|
+
import "toast-builder-vue3/dist/toast-builder-vue3.css";
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
createApp(App).mount("#app");
|
|
64
|
+
```
|
|
70
65
|
|
|
71
|
-
|
|
66
|
+
### 2. Add ToastContainer
|
|
72
67
|
|
|
73
|
-
|
|
68
|
+
In your `App.vue`:
|
|
74
69
|
|
|
75
|
-
|
|
70
|
+
```vue
|
|
71
|
+
<template>
|
|
72
|
+
<div id="app">
|
|
73
|
+
<router-view />
|
|
74
|
+
<ToastContainer />
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
<script setup lang="ts">
|
|
79
|
+
import { ToastContainer } from "toast-builder-vue3";
|
|
80
|
+
</script>
|
|
80
81
|
```
|
|
81
82
|
|
|
82
|
-
###
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
### 3. Show Toasts
|
|
84
|
+
|
|
85
|
+
In any component:
|
|
86
|
+
|
|
87
|
+
```vue
|
|
88
|
+
<script setup lang="ts">
|
|
89
|
+
import { useToast } from "toast-builder-vue3";
|
|
90
|
+
|
|
91
|
+
const { showToast } = useToast();
|
|
92
|
+
|
|
93
|
+
const notify = () => {
|
|
94
|
+
// Minimal usage - smart defaults applied automatically
|
|
95
|
+
showToast({
|
|
96
|
+
type: "success",
|
|
97
|
+
message: "Operation completed successfully!",
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const notifyWithCustomization = () => {
|
|
102
|
+
// Full customization - override any default
|
|
103
|
+
showToast({
|
|
104
|
+
type: "success",
|
|
105
|
+
message: "Operation completed successfully!",
|
|
106
|
+
title: "Success",
|
|
107
|
+
duration: 5000,
|
|
108
|
+
position: "bottom-right",
|
|
109
|
+
backgroundColor: "#10b981",
|
|
110
|
+
textColor: "#ffffff",
|
|
111
|
+
showIcon: true,
|
|
112
|
+
showCloseButton: true,
|
|
113
|
+
showProgress: true,
|
|
114
|
+
animation: "slide",
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
</script>
|
|
86
118
|
```
|
|
87
119
|
|
|
88
|
-
|
|
120
|
+
> **Smart Defaults:** Only `type` and `message` are required. All other options have sensible defaults based on the toast type.
|
|
89
121
|
|
|
90
|
-
|
|
91
|
-
npm run dev
|
|
92
|
-
```
|
|
122
|
+
---
|
|
93
123
|
|
|
94
|
-
|
|
124
|
+
## đ¨ Smart Defaults System
|
|
95
125
|
|
|
96
|
-
|
|
126
|
+
The package uses an intelligent defaults system that requires minimal configuration while allowing full customization.
|
|
97
127
|
|
|
98
|
-
|
|
99
|
-
|
|
128
|
+
### Type-Based Defaults
|
|
129
|
+
|
|
130
|
+
Each toast type automatically gets appropriate colors and icons:
|
|
131
|
+
|
|
132
|
+
| Type | Colors | Icon |
|
|
133
|
+
| --------- | -------------------------- | ------------ |
|
|
134
|
+
| `success` | Green (#10b981 / #ffffff) | Check circle |
|
|
135
|
+
| `error` | Red (#ef4444 / #ffffff) | X circle |
|
|
136
|
+
| `warning` | Orange (#f59e0b / #111827) | Alert |
|
|
137
|
+
| `info` | Blue (#3b82f6 / #ffffff) | Info circle |
|
|
138
|
+
|
|
139
|
+
### Base Defaults
|
|
140
|
+
|
|
141
|
+
All toasts use these defaults unless overridden:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
{
|
|
145
|
+
duration: 3000, // 3 seconds
|
|
146
|
+
position: 'top-right',
|
|
147
|
+
showIcon: true,
|
|
148
|
+
showCloseButton: true,
|
|
149
|
+
animation: 'fade',
|
|
150
|
+
showProgress: false,
|
|
151
|
+
}
|
|
100
152
|
```
|
|
101
153
|
|
|
102
|
-
|
|
154
|
+
### Customization Priority
|
|
103
155
|
|
|
104
|
-
|
|
156
|
+
Defaults are applied in this order (highest priority first):
|
|
105
157
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| `npm run preview` | Preview production build locally |
|
|
111
|
-
| `npm run test` | Run all tests |
|
|
112
|
-
| `npm run test:watch` | Run tests in watch mode |
|
|
113
|
-
| `npm run test:coverage` | Generate test coverage report |
|
|
114
|
-
| `npm run type-check` | Run TypeScript type checking |
|
|
158
|
+
1. **Per-toast config** (showToast options)
|
|
159
|
+
2. **Global defaults** (ToastContainer props)
|
|
160
|
+
3. **Type defaults** (type-based colors/icons)
|
|
161
|
+
4. **Base defaults** (package defaults)
|
|
115
162
|
|
|
116
|
-
|
|
163
|
+
### Global Defaults (Optional)
|
|
117
164
|
|
|
118
|
-
|
|
165
|
+
Set default options for all toasts in your app:
|
|
119
166
|
|
|
167
|
+
```vue
|
|
168
|
+
<template>
|
|
169
|
+
<ToastContainer
|
|
170
|
+
position="top-right"
|
|
171
|
+
:defaultDuration="5000"
|
|
172
|
+
defaultAnimation="slide"
|
|
173
|
+
:defaultShowProgress="true"
|
|
174
|
+
/>
|
|
175
|
+
</template>
|
|
176
|
+
|
|
177
|
+
<script setup lang="ts">
|
|
178
|
+
import { ToastContainer } from "toast-builder-vue3";
|
|
179
|
+
</script>
|
|
120
180
|
```
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
â â â âââ AnimationSelector.vue
|
|
133
|
-
â â â âââ PresetManager.vue
|
|
134
|
-
â â â âââ CodeExport.vue
|
|
135
|
-
â â âââ common/ # Reusable UI components
|
|
136
|
-
â â â âââ BaseButton.vue
|
|
137
|
-
â â â âââ BaseInput.vue
|
|
138
|
-
â â â âââ BaseSelect.vue
|
|
139
|
-
â â â âââ BaseRadio.vue
|
|
140
|
-
â â â âââ ColorPicker.vue
|
|
141
|
-
â â â âââ Icon.vue
|
|
142
|
-
â â â âââ ThemeToggle.vue
|
|
143
|
-
â â âââ toast/ # Toast display components
|
|
144
|
-
â â âââ Toast.vue
|
|
145
|
-
â â âââ ToastContainer.vue
|
|
146
|
-
â âââ composables/ # Vue composition functions
|
|
147
|
-
â â âââ useToast.ts # Toast state management
|
|
148
|
-
â â âââ useToastBuilder.ts # Builder config management
|
|
149
|
-
â â âââ usePresets.ts # Preset CRUD operations
|
|
150
|
-
â â âââ useTheme.ts # Theme management
|
|
151
|
-
â â âââ useAnimation.ts # Animation utilities
|
|
152
|
-
â â âââ useClipboard.ts # Copy-to-clipboard functionality
|
|
153
|
-
â âââ utils/ # Helper functions
|
|
154
|
-
â â âââ validators.ts # Input validation
|
|
155
|
-
â â âââ storage.ts # localStorage abstraction
|
|
156
|
-
â â âââ code-generator.ts # Code export logic
|
|
157
|
-
â â âââ color-utils.ts # Color manipulation
|
|
158
|
-
â â âââ image-utils.ts # Image compression & validation
|
|
159
|
-
â â âââ nanoid.ts # ID generation
|
|
160
|
-
â âââ types/ # TypeScript type definitions
|
|
161
|
-
â â âââ toast.ts
|
|
162
|
-
â â âââ builder.ts
|
|
163
|
-
â â âââ animation.ts
|
|
164
|
-
â â âââ theme.ts
|
|
165
|
-
â âââ constants/ # App constants
|
|
166
|
-
â â âââ toast-defaults.ts
|
|
167
|
-
â â âââ animation-presets.ts
|
|
168
|
-
â â âââ color-palettes.ts
|
|
169
|
-
â â âââ icon-library.ts
|
|
170
|
-
â âââ styles/ # Global styles
|
|
171
|
-
â â âââ main.scss
|
|
172
|
-
â â âââ _variables.scss
|
|
173
|
-
â â âââ _reset.scss
|
|
174
|
-
â â âââ _animations.scss
|
|
175
|
-
â âââ App.vue
|
|
176
|
-
â âââ main.ts
|
|
177
|
-
âââ tests/
|
|
178
|
-
â âââ unit/
|
|
179
|
-
â â âââ utils/
|
|
180
|
-
â â âââ validators.spec.ts
|
|
181
|
-
â âââ setup.ts
|
|
182
|
-
â âââ __mocks__/
|
|
183
|
-
âââ package.json
|
|
184
|
-
âââ vite.config.ts
|
|
185
|
-
âââ tsconfig.json
|
|
186
|
-
âââ jest.config.cjs
|
|
187
|
-
```
|
|
181
|
+
|
|
182
|
+
**ToastContainer Props:**
|
|
183
|
+
|
|
184
|
+
| Prop | Type | Default | Description |
|
|
185
|
+
| ------------------------ | --------------- | ------------- | ----------------------------- |
|
|
186
|
+
| `position` | `Position` | `'top-right'` | Container position |
|
|
187
|
+
| `defaultDuration` | `number` | `3000` | Default toast duration (ms) |
|
|
188
|
+
| `defaultAnimation` | `AnimationType` | `'fade'` | Default animation type |
|
|
189
|
+
| `defaultShowIcon` | `boolean` | `true` | Show icons by default |
|
|
190
|
+
| `defaultShowCloseButton` | `boolean` | `true` | Show close buttons by default |
|
|
191
|
+
| `defaultShowProgress` | `boolean` | `false` | Show progress bars by default |
|
|
188
192
|
|
|
189
193
|
---
|
|
190
194
|
|
|
191
|
-
##
|
|
195
|
+
## đ API Reference
|
|
196
|
+
|
|
197
|
+
### `useToast()`
|
|
198
|
+
|
|
199
|
+
Returns an object with the following methods and properties:
|
|
200
|
+
|
|
201
|
+
#### Methods
|
|
192
202
|
|
|
193
|
-
|
|
203
|
+
##### `showToast(config: ToastInput): string`
|
|
194
204
|
|
|
195
|
-
|
|
205
|
+
Display a new toast notification. Returns the toast ID.
|
|
196
206
|
|
|
197
|
-
|
|
198
|
-
2. **Business Logic** (`composables/`): Shared state management and functionality using Vue composables
|
|
199
|
-
3. **Utilities** (`utils/`): Pure functions for validation, storage, code generation
|
|
200
|
-
4. **Type Safety**: Strict TypeScript configuration with comprehensive type definitions
|
|
207
|
+
**Required Parameters:**
|
|
201
208
|
|
|
202
|
-
|
|
209
|
+
| Parameter | Type | Description |
|
|
210
|
+
| --------- | --------------------------------------------- | ------------- |
|
|
211
|
+
| `type` | `'success' \| 'error' \| 'warning' \| 'info'` | Toast type |
|
|
212
|
+
| `message` | `string` | Toast message |
|
|
203
213
|
|
|
204
|
-
**
|
|
214
|
+
**Optional Parameters:**
|
|
205
215
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
216
|
+
| Parameter | Type | Default | Description |
|
|
217
|
+
| ------------------------- | ------------------------------- | ------------- | ------------------------------- |
|
|
218
|
+
| `title` | `string` | `''` | Toast title |
|
|
219
|
+
| `duration` | `number` | `3000` | Duration in ms (0 = persistent) |
|
|
220
|
+
| `position` | `Position` | `'top-right'` | Position on screen |
|
|
221
|
+
| `backgroundColor` | `string` | Type-based | Background color (hex) |
|
|
222
|
+
| `textColor` | `string` | Type-based | Text color (hex) |
|
|
223
|
+
| `showIcon` | `boolean` | `true` | Show/hide icon |
|
|
224
|
+
| `showCloseButton` | `boolean` | `true` | Show/hide close button |
|
|
225
|
+
| `showProgress` | `boolean` | `false` | Show progress bar |
|
|
226
|
+
| `animation` | `'fade' \| 'slide' \| 'bounce'` | `'fade'` | Animation type |
|
|
227
|
+
| `customIcon` | `IconName` | Type-based | Built-in icon name |
|
|
228
|
+
| `customIconUrl` | `string` | - | Custom icon URL |
|
|
229
|
+
| `customIconBase64` | `string` | - | Custom icon Base64 |
|
|
230
|
+
| `customCloseButtonUrl` | `string` | - | Custom close button URL |
|
|
231
|
+
| `customCloseButtonBase64` | `string` | - | Custom close button Base64 |
|
|
209
232
|
|
|
210
|
-
|
|
233
|
+
##### `dismissToast(id: string): void`
|
|
211
234
|
|
|
212
|
-
|
|
213
|
-
- CSS variable system for theming
|
|
214
|
-
- Consistent design tokens
|
|
235
|
+
Dismiss a specific toast by ID.
|
|
215
236
|
|
|
216
|
-
|
|
237
|
+
##### `clearAllToasts(): void`
|
|
217
238
|
|
|
218
|
-
|
|
219
|
-
- `useToast()` manages active notifications
|
|
220
|
-
- All components react to state changes
|
|
239
|
+
Dismiss all active toasts.
|
|
221
240
|
|
|
222
|
-
|
|
241
|
+
##### `undoLastDismissed(): void`
|
|
223
242
|
|
|
224
|
-
|
|
225
|
-
- User-friendly error messages
|
|
226
|
-
- Prevents invalid configurations
|
|
243
|
+
Restore the last dismissed toast.
|
|
227
244
|
|
|
228
|
-
|
|
245
|
+
##### `getToastsByPosition(position: Position): ComputedRef<ActiveNotification[]>`
|
|
229
246
|
|
|
230
|
-
|
|
231
|
-
- Maximum dimensions (128Ã128px)
|
|
232
|
-
- File size limit (100KB)
|
|
233
|
-
- Supported formats: PNG, JPEG, GIF, WebP, SVG
|
|
247
|
+
Get all toasts at a specific position.
|
|
234
248
|
|
|
235
|
-
|
|
249
|
+
#### Properties
|
|
236
250
|
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
- Copy-to-clipboard with user feedback
|
|
251
|
+
- `activeToasts`: `ComputedRef<ActiveNotification[]>` - All active toasts
|
|
252
|
+
- `dismissedToasts`: `ComputedRef<ActiveNotification[]>` - Recently dismissed toasts
|
|
240
253
|
|
|
241
|
-
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## đĄ Examples
|
|
257
|
+
|
|
258
|
+
### Success Toast
|
|
242
259
|
|
|
243
260
|
```typescript
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
261
|
+
showToast({
|
|
262
|
+
type: "success",
|
|
263
|
+
message: "Changes saved successfully!",
|
|
264
|
+
duration: 3000,
|
|
265
|
+
position: "top-right",
|
|
266
|
+
backgroundColor: "#10b981",
|
|
267
|
+
textColor: "#ffffff",
|
|
268
|
+
showIcon: true,
|
|
269
|
+
showCloseButton: true,
|
|
270
|
+
});
|
|
249
271
|
```
|
|
250
272
|
|
|
251
|
-
###
|
|
273
|
+
### Error Toast with Progress Bar
|
|
252
274
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
```typescript
|
|
276
|
+
showToast({
|
|
277
|
+
type: "error",
|
|
278
|
+
title: "Error",
|
|
279
|
+
message: "Failed to save changes",
|
|
280
|
+
duration: 5000,
|
|
281
|
+
position: "top-right",
|
|
282
|
+
backgroundColor: "#ef4444",
|
|
283
|
+
textColor: "#ffffff",
|
|
284
|
+
showIcon: true,
|
|
285
|
+
showCloseButton: true,
|
|
286
|
+
showProgress: true,
|
|
287
|
+
animation: "bounce",
|
|
288
|
+
});
|
|
289
|
+
```
|
|
256
290
|
|
|
257
|
-
|
|
291
|
+
### Persistent Toast
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
showToast({
|
|
295
|
+
type: "warning",
|
|
296
|
+
message: "This toast stays until closed",
|
|
297
|
+
duration: 0, // Persistent
|
|
298
|
+
position: "top-center",
|
|
299
|
+
backgroundColor: "#f59e0b",
|
|
300
|
+
textColor: "#000000",
|
|
301
|
+
showIcon: true,
|
|
302
|
+
showCloseButton: true,
|
|
303
|
+
});
|
|
304
|
+
```
|
|
258
305
|
|
|
259
|
-
|
|
306
|
+
### Custom Icon
|
|
260
307
|
|
|
261
|
-
|
|
308
|
+
```typescript
|
|
309
|
+
showToast({
|
|
310
|
+
type: "info",
|
|
311
|
+
message: "You have a new message",
|
|
312
|
+
duration: 4000,
|
|
313
|
+
position: "bottom-right",
|
|
314
|
+
backgroundColor: "#3b82f6",
|
|
315
|
+
textColor: "#ffffff",
|
|
316
|
+
showIcon: true,
|
|
317
|
+
showCloseButton: true,
|
|
318
|
+
customIcon: "bell", // Built-in icon
|
|
319
|
+
});
|
|
320
|
+
```
|
|
262
321
|
|
|
263
|
-
|
|
264
|
-
2. **Modern browser support**: Assumes ES2020+ features (async/await, optional chaining, etc.)
|
|
265
|
-
3. **JavaScript enabled**: Application requires JavaScript to function
|
|
266
|
-
4. **localStorage available**: Presets require localStorage (graceful degradation if unavailable)
|
|
322
|
+
### Using Built-in Icons
|
|
267
323
|
|
|
268
|
-
|
|
324
|
+
Available icons: `check-circle`, `check`, `badge-check`, `x-circle`, `alert-circle`, `exclamation-circle`, `alert-triangle`, `exclamation-triangle`, `information-circle`, `question-mark-circle`, `bell`, `megaphone`, `sparkles`, `heart`, `moon`, `sun`
|
|
269
325
|
|
|
270
|
-
|
|
271
|
-
2. **ID generation**: Using `nanoid` for unique IDs instead of UUID (smaller, URL-safe)
|
|
272
|
-
3. **Animation timing**: Standard durations (fade: 300ms, slide: 400ms, bounce: 500ms)
|
|
273
|
-
4. **Color format**: Only hex colors supported (no RGB/HSL input)
|
|
274
|
-
5. **Image upload**: Client-side compression using Canvas API (no server-side processing)
|
|
275
|
-
6. **Theme detection**: Uses `prefers-color-scheme` media query for initial theme
|
|
326
|
+
---
|
|
276
327
|
|
|
277
|
-
|
|
328
|
+
## đ¨ Position Options
|
|
278
329
|
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
-
|
|
284
|
-
-
|
|
330
|
+
- `top-left`
|
|
331
|
+
- `top-center`
|
|
332
|
+
- `top-right`
|
|
333
|
+
- `bottom-left`
|
|
334
|
+
- `bottom-center`
|
|
335
|
+
- `bottom-right`
|
|
336
|
+
|
|
337
|
+
---
|
|
285
338
|
|
|
286
|
-
|
|
339
|
+
## đŦ Animation Types
|
|
287
340
|
|
|
288
|
-
-
|
|
289
|
-
-
|
|
290
|
-
-
|
|
291
|
-
- **Edge**: âĨ90
|
|
341
|
+
- `fade` - Simple fade in/out (300ms)
|
|
342
|
+
- `slide` - Slide from right (400ms)
|
|
343
|
+
- `bounce` - Bouncy entrance (500ms)
|
|
292
344
|
|
|
293
345
|
---
|
|
294
346
|
|
|
295
|
-
##
|
|
347
|
+
## đ¨ Recommended Colors
|
|
296
348
|
|
|
297
|
-
|
|
349
|
+
| Type | Background | Text |
|
|
350
|
+
| ------- | ---------- | --------- |
|
|
351
|
+
| Success | `#10b981` | `#ffffff` |
|
|
352
|
+
| Error | `#ef4444` | `#ffffff` |
|
|
353
|
+
| Warning | `#f59e0b` | `#000000` |
|
|
354
|
+
| Info | `#3b82f6` | `#ffffff` |
|
|
298
355
|
|
|
299
|
-
|
|
300
|
-
# Run all tests
|
|
301
|
-
npm run test
|
|
356
|
+
---
|
|
302
357
|
|
|
303
|
-
|
|
304
|
-
npm run test:coverage
|
|
358
|
+
## đ TypeScript Support
|
|
305
359
|
|
|
306
|
-
|
|
307
|
-
|
|
360
|
+
Full TypeScript support with comprehensive type definitions:
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
import type {
|
|
364
|
+
NotificationConfig,
|
|
365
|
+
ActiveNotification,
|
|
366
|
+
NotificationType,
|
|
367
|
+
Position,
|
|
368
|
+
AnimationType,
|
|
369
|
+
IconName,
|
|
370
|
+
} from "toast-builder-vue3";
|
|
308
371
|
```
|
|
309
372
|
|
|
310
|
-
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## đ ī¸ Browser Support
|
|
311
376
|
|
|
312
|
-
-
|
|
313
|
-
-
|
|
314
|
-
-
|
|
315
|
-
-
|
|
316
|
-
- Integration tests (planned)
|
|
377
|
+
- Chrome âĨ 90
|
|
378
|
+
- Firefox âĨ 88
|
|
379
|
+
- Safari âĨ 14
|
|
380
|
+
- Edge âĨ 90
|
|
317
381
|
|
|
318
382
|
---
|
|
319
383
|
|
|
320
|
-
##
|
|
384
|
+
## đ License
|
|
321
385
|
|
|
322
|
-
|
|
323
|
-
2. **Configure content** (title, message, duration)
|
|
324
|
-
3. **Choose position** (where toast appears on screen)
|
|
325
|
-
4. **Customize appearance** (colors, icons, progress bar)
|
|
326
|
-
5. **Select animation** (fade, slide, bounce)
|
|
327
|
-
6. **Preview in real-time** - See changes instantly
|
|
328
|
-
7. **Test behavior** - Click "Show Notification" to trigger actual toast
|
|
329
|
-
8. **Save as preset** (optional) - Save for reuse
|
|
330
|
-
9. **Export code** - Get Vue 3 or JavaScript code
|
|
386
|
+
[GPL-3.0](LICENSE)
|
|
331
387
|
|
|
332
388
|
---
|
|
333
389
|
|
|
334
|
-
##
|
|
390
|
+
## đ Links
|
|
335
391
|
|
|
336
|
-
|
|
392
|
+
- [NPM Package](https://www.npmjs.com/package/toast-builder-vue3)
|
|
393
|
+
- [Live Demo](https://toast-builder.vercel.app/)
|
|
394
|
+
- [GitHub Repository](https://github.com/highpriv/toast-builder)
|
|
395
|
+
- [Report Issues](https://github.com/highpriv/toast-builder/issues)
|
|
337
396
|
|
|
338
|
-
|
|
339
|
-
npm run build
|
|
340
|
-
```
|
|
397
|
+
---
|
|
341
398
|
|
|
342
|
-
|
|
399
|
+
## đ¨âđģ Author
|
|
400
|
+
|
|
401
|
+
**Canberk Beren**
|
|
402
|
+
|
|
403
|
+
- GitHub: [@highpriv](https://github.com/highpriv)
|
|
404
|
+
|
|
405
|
+
---
|
|
343
406
|
|
|
344
|
-
|
|
407
|
+
## â Support This Project
|
|
408
|
+
|
|
409
|
+
If you find this package useful, consider buying me a coffee! Your support helps me maintain and improve this project.
|
|
410
|
+
|
|
411
|
+
<div align="center">
|
|
412
|
+
|
|
413
|
+
[](https://buymeacoffee.com/highpriv)
|
|
414
|
+
|
|
415
|
+
### Or scan the QR code:
|
|
416
|
+
|
|
417
|
+
<img src="buymeacoffee-qr.png" alt="Buy Me a Coffee QR Code" width="200" />
|
|
418
|
+
|
|
419
|
+
</div>
|
|
420
|
+
|
|
421
|
+
---
|
|
345
422
|
|
|
346
|
-
|
|
347
|
-
- Build command: `npm run build`
|
|
348
|
-
- Install command: `npm install`
|
|
423
|
+
Made with â¤ī¸ using Vue 3 and TypeScript
|