toast-builder-vue3 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.
- package/.vscode/extensions.json +10 -0
- package/.vscode/settings.json +53 -0
- package/README.md +348 -0
- package/babel.config.cjs +12 -0
- package/demo/README.md +1 -0
- package/demo/ToastBuilder.vue +0 -0
- package/demo/main.ts +0 -0
- package/index.html +54 -0
- package/jest.config.cjs +57 -0
- package/package.json +57 -0
- package/src/App.vue +31 -0
- package/src/components/builder/AnimationSelector.vue +40 -0
- package/src/components/builder/CodeExport.vue +123 -0
- package/src/components/builder/ConfigPanel.vue +28 -0
- package/src/components/builder/ContentControls.vue +261 -0
- package/src/components/builder/PositionSelector.vue +103 -0
- package/src/components/builder/PresetManager.vue +231 -0
- package/src/components/builder/PreviewPane.vue +126 -0
- package/src/components/builder/StyleControls.vue +412 -0
- package/src/components/builder/ToastBuilder.vue +74 -0
- package/src/components/builder/TypeSelector.vue +84 -0
- package/src/components/builder/index.ts +10 -0
- package/src/components/common/BaseButton.vue +131 -0
- package/src/components/common/BaseInput.vue +67 -0
- package/src/components/common/BaseRadio.vue +53 -0
- package/src/components/common/BaseSelect.vue +68 -0
- package/src/components/common/ColorPicker.vue +80 -0
- package/src/components/common/Icon.vue +98 -0
- package/src/components/common/ThemeToggle.vue +46 -0
- package/src/components/common/index.ts +8 -0
- package/src/components/toast/Toast.vue +202 -0
- package/src/components/toast/ToastContainer.vue +92 -0
- package/src/components/toast/index.ts +2 -0
- package/src/composables/index.ts +6 -0
- package/src/composables/useAnimation.ts +21 -0
- package/src/composables/useClipboard.ts +36 -0
- package/src/composables/usePresets.ts +57 -0
- package/src/composables/useTheme.ts +58 -0
- package/src/composables/useToast.ts +78 -0
- package/src/composables/useToastBuilder.ts +59 -0
- package/src/constants/animation-presets.ts +20 -0
- package/src/constants/color-palettes.ts +20 -0
- package/src/constants/icon-library.ts +54 -0
- package/src/constants/index.ts +10 -0
- package/src/constants/toast-defaults.ts +62 -0
- package/src/lib/README.md +125 -0
- package/src/lib/components/Icon.vue +0 -0
- package/src/lib/components/Toast.vue +96 -0
- package/src/lib/components/ToastContainer.vue +32 -0
- package/src/lib/constants/icon-library.ts +1 -0
- package/src/lib/constants/toast-defaults.ts +65 -0
- package/src/lib/index.ts +5 -0
- package/src/lib/package.json +15 -0
- package/src/lib/styles/toast.module.scss +1 -0
- package/src/lib/tsconfig.json +12 -0
- package/src/lib/types/toast.ts +49 -0
- package/src/lib/utils/nanoid.ts +2 -0
- package/src/lib/utils/validateImageUrl.ts +4 -0
- package/src/main.ts +5 -0
- package/src/styles/_animations.scss +95 -0
- package/src/styles/_reset.scss +56 -0
- package/src/styles/_variables.scss +73 -0
- package/src/styles/builder.module.scss +236 -0
- package/src/styles/main.scss +117 -0
- package/src/styles/toast.module.scss +105 -0
- package/src/types/animation.ts +5 -0
- package/src/types/builder.ts +13 -0
- package/src/types/index.ts +10 -0
- package/src/types/theme.ts +1 -0
- package/src/types/toast.ts +54 -0
- package/src/utils/code-generator.ts +84 -0
- package/src/utils/color-utils.ts +84 -0
- package/src/utils/image-utils.ts +107 -0
- package/src/utils/index.ts +25 -0
- package/src/utils/nanoid.ts +9 -0
- package/src/utils/storage.ts +61 -0
- package/src/utils/validators.ts +27 -0
- package/tests/__mocks__/styleMock.js +1 -0
- package/tests/setup.ts +21 -0
- package/tests/unit/utils/validators.spec.ts +41 -0
- package/tsconfig.app.json +28 -0
- package/tsconfig.json +8 -0
- package/tsconfig.node.json +22 -0
- package/tsconfig.test.json +9 -0
- package/vercel.json +8 -0
- package/vite.config.ts +47 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": true,
|
|
3
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
4
|
+
"editor.codeActionsOnSave": {
|
|
5
|
+
"source.fixAll": "explicit"
|
|
6
|
+
},
|
|
7
|
+
"editor.tabSize": 2,
|
|
8
|
+
"editor.insertSpaces": true,
|
|
9
|
+
"editor.detectIndentation": false,
|
|
10
|
+
|
|
11
|
+
// Vue specific
|
|
12
|
+
"[vue]": {
|
|
13
|
+
"editor.defaultFormatter": "Vue.volar"
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
// TypeScript specific
|
|
17
|
+
"[typescript]": {
|
|
18
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
// SCSS specific
|
|
22
|
+
"[scss]": {
|
|
23
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
// TypeScript settings
|
|
27
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
28
|
+
"typescript.enablePromptUseWorkspaceTsdk": true,
|
|
29
|
+
"typescript.preferences.importModuleSpecifier": "non-relative",
|
|
30
|
+
|
|
31
|
+
// Vue Volar settings
|
|
32
|
+
"volar.autoCompleteRefs": true,
|
|
33
|
+
"volar.completion.autoImportComponent": true,
|
|
34
|
+
|
|
35
|
+
// CSS settings
|
|
36
|
+
"css.lint.unknownAtRules": "ignore",
|
|
37
|
+
|
|
38
|
+
// File associations
|
|
39
|
+
"files.associations": {
|
|
40
|
+
"*.css": "scss"
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// Exclude from file watcher
|
|
44
|
+
"files.watcherExclude": {
|
|
45
|
+
"**/node_modules/**": true,
|
|
46
|
+
"**/dist/**": true,
|
|
47
|
+
"**/.git/**": true,
|
|
48
|
+
"**/coverage/**": true
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// Testing
|
|
52
|
+
"jest.runMode": "on-demand"
|
|
53
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# Toast Notification Builder
|
|
2
|
+
|
|
3
|
+
A type-safe toast notification configuration tool built with Vue 3 and TypeScript. Configure, preview, and export production-ready notification code with live updates and comprehensive customization options.
|
|
4
|
+
|
|
5
|
+
Live Demo: https://toast-builder.vercel.app/
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
### Core Features
|
|
17
|
+
|
|
18
|
+
- **Configuration Panel**: Fully customizable notification properties
|
|
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)
|
|
23
|
+
|
|
24
|
+
- **Style Customization**
|
|
25
|
+
- Background and text color pickers with hex input
|
|
26
|
+
- Icon visibility toggle
|
|
27
|
+
- Close button toggle
|
|
28
|
+
- Progress bar toggle
|
|
29
|
+
|
|
30
|
+
- **Live Preview**: Real-time preview that updates instantly as you configure
|
|
31
|
+
|
|
32
|
+
- **Preset Management**
|
|
33
|
+
- Save current configuration as named presets
|
|
34
|
+
- Load previously saved presets
|
|
35
|
+
- Delete unwanted presets
|
|
36
|
+
- Persistent storage using localStorage
|
|
37
|
+
|
|
38
|
+
- **Multiple Notification Stacking**: Display multiple notifications simultaneously with proper vertical arrangement
|
|
39
|
+
|
|
40
|
+
### Bonus Features (All Implemented)
|
|
41
|
+
|
|
42
|
+
- **Animation System**: 3 animation styles (fade, slide, bounce)
|
|
43
|
+
- **Code Export**: Generate production-ready Vue 3 or JavaScript code with copy-to-clipboard
|
|
44
|
+
- **Progress Bar**: Visual countdown for auto-dismiss notifications
|
|
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
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Tech Stack
|
|
53
|
+
|
|
54
|
+
| Technology | Version | Purpose |
|
|
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 |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Prerequisites
|
|
67
|
+
|
|
68
|
+
- **Node.js**: ≥ 18.0.0
|
|
69
|
+
- **npm**: ≥ 9.0.0
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Setup Instructions
|
|
74
|
+
|
|
75
|
+
### 1. Clone the repository
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/highpriv/toast-builder.git
|
|
79
|
+
cd toast-builder
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2. Install dependencies
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 3. Start the development server
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm run dev
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The application will open automatically at `http://localhost:5173`
|
|
95
|
+
|
|
96
|
+
### 4. Run tests
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm run test
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Available Scripts
|
|
105
|
+
|
|
106
|
+
| Command | Description |
|
|
107
|
+
| ----------------------- | ---------------------------------------- |
|
|
108
|
+
| `npm run dev` | Start development server with hot reload |
|
|
109
|
+
| `npm run build` | Build for production (`dist/` folder) |
|
|
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 |
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Project Structure
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
toast-builder/
|
|
122
|
+
├── src/
|
|
123
|
+
│ ├── components/
|
|
124
|
+
│ │ ├── builder/ # Configuration panel components
|
|
125
|
+
│ │ │ ├── ToastBuilder.vue
|
|
126
|
+
│ │ │ ├── ConfigPanel.vue
|
|
127
|
+
│ │ │ ├── PreviewPane.vue
|
|
128
|
+
│ │ │ ├── TypeSelector.vue
|
|
129
|
+
│ │ │ ├── PositionSelector.vue
|
|
130
|
+
│ │ │ ├── ContentControls.vue
|
|
131
|
+
│ │ │ ├── StyleControls.vue
|
|
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
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Development Approach
|
|
192
|
+
|
|
193
|
+
### Architecture
|
|
194
|
+
|
|
195
|
+
The project follows a **component-based architecture** with clear separation of concerns:
|
|
196
|
+
|
|
197
|
+
1. **Presentation Layer** (`components/`): Reusable UI components using Vue 3 Composition API
|
|
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
|
|
201
|
+
|
|
202
|
+
### Key Design Decisions
|
|
203
|
+
|
|
204
|
+
**1. Composition API over Options API**
|
|
205
|
+
|
|
206
|
+
- Better TypeScript inference
|
|
207
|
+
- Improved code reusability through composables
|
|
208
|
+
- More maintainable for complex logic
|
|
209
|
+
|
|
210
|
+
**2. SCSS Modules for Styling**
|
|
211
|
+
|
|
212
|
+
- Scoped styles prevent conflicts
|
|
213
|
+
- CSS variable system for theming
|
|
214
|
+
- Consistent design tokens
|
|
215
|
+
|
|
216
|
+
**3. Single Source of Truth**
|
|
217
|
+
|
|
218
|
+
- `useToastBuilder()` manages configuration state
|
|
219
|
+
- `useToast()` manages active notifications
|
|
220
|
+
- All components react to state changes
|
|
221
|
+
|
|
222
|
+
**4. Validation & Error Handling**
|
|
223
|
+
|
|
224
|
+
- Input validation on every change
|
|
225
|
+
- User-friendly error messages
|
|
226
|
+
- Prevents invalid configurations
|
|
227
|
+
|
|
228
|
+
**5. Image Optimization**
|
|
229
|
+
|
|
230
|
+
- Canvas API for client-side compression
|
|
231
|
+
- Maximum dimensions (128×128px)
|
|
232
|
+
- File size limit (100KB)
|
|
233
|
+
- Supported formats: PNG, JPEG, GIF, WebP, SVG
|
|
234
|
+
|
|
235
|
+
**6. Code Export**
|
|
236
|
+
|
|
237
|
+
- Templates for Vue 3 SFC and plain JavaScript
|
|
238
|
+
- Proper escaping for special characters
|
|
239
|
+
- Copy-to-clipboard with user feedback
|
|
240
|
+
|
|
241
|
+
### State Management Pattern
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
// Global reactive state using composables
|
|
245
|
+
const config = useToastBuilder(); // Configuration state
|
|
246
|
+
const toasts = useToast(); // Active toasts
|
|
247
|
+
const presets = usePresets(); // Saved presets
|
|
248
|
+
const theme = useTheme(); // Theme preference
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Testing Strategy
|
|
252
|
+
|
|
253
|
+
- **Unit Tests**: Core utilities (validators, color manipulation)
|
|
254
|
+
- **Component Tests**: (Ready for expansion)
|
|
255
|
+
- **Integration Tests**: (Future improvement)
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Assumptions
|
|
260
|
+
|
|
261
|
+
### User Experience
|
|
262
|
+
|
|
263
|
+
1. **Responsive design**: Optimized for all devices
|
|
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)
|
|
267
|
+
|
|
268
|
+
### Technical
|
|
269
|
+
|
|
270
|
+
1. **No backend required**: All state managed client-side
|
|
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
|
|
276
|
+
|
|
277
|
+
### Validation Rules
|
|
278
|
+
|
|
279
|
+
- **Title**: Optional, max 50 characters
|
|
280
|
+
- **Message**: Required, 1-200 characters
|
|
281
|
+
- **Duration**: 1000ms - 10000ms or 0 (persistent)
|
|
282
|
+
- **Preset name**: 1-50 characters
|
|
283
|
+
- **Image files**: ≤5MB, PNG/JPEG/GIF/WebP/SVG only
|
|
284
|
+
- **Image URLs**: Must end with valid image extension
|
|
285
|
+
|
|
286
|
+
### Browser Compatibility
|
|
287
|
+
|
|
288
|
+
- **Chrome**: ≥90
|
|
289
|
+
- **Firefox**: ≥88
|
|
290
|
+
- **Safari**: ≥14
|
|
291
|
+
- **Edge**: ≥90
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Testing
|
|
296
|
+
|
|
297
|
+
The project includes comprehensive unit tests for core functionality:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Run all tests
|
|
301
|
+
npm run test
|
|
302
|
+
|
|
303
|
+
# Run with coverage
|
|
304
|
+
npm run test:coverage
|
|
305
|
+
|
|
306
|
+
# Watch mode for development
|
|
307
|
+
npm run test:watch
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Current Test Coverage:**
|
|
311
|
+
|
|
312
|
+
- Input validation (title, message, duration, preset names)
|
|
313
|
+
- Color utilities
|
|
314
|
+
- Image validation (file type, size, URL format)
|
|
315
|
+
- Component tests (planned)
|
|
316
|
+
- Integration tests (planned)
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Usage Example
|
|
321
|
+
|
|
322
|
+
1. **Select notification type** (success, error, warning, info)
|
|
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
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Build & Deployment
|
|
335
|
+
|
|
336
|
+
### Production Build
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
npm run build
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Generates optimized production build in `dist/` folder.
|
|
343
|
+
|
|
344
|
+
**Build configuration:**
|
|
345
|
+
|
|
346
|
+
- Output directory: `dist`
|
|
347
|
+
- Build command: `npm run build`
|
|
348
|
+
- Install command: `npm install`
|
package/babel.config.cjs
ADDED
package/demo/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Toast Notification Demo
|
|
File without changes
|
package/demo/main.ts
ADDED
|
File without changes
|
package/index.html
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
|
|
7
|
+
<meta
|
|
8
|
+
name="description"
|
|
9
|
+
content="Build and preview custom toast notifications"
|
|
10
|
+
/>
|
|
11
|
+
<meta name="keywords" content="toast, notification, builder" />
|
|
12
|
+
<meta name="author" content="Canberk Beren" />
|
|
13
|
+
|
|
14
|
+
<meta property="og:type" content="website" />
|
|
15
|
+
<meta property="og:title" content="Toast Notification Builder" />
|
|
16
|
+
<meta
|
|
17
|
+
property="og:description"
|
|
18
|
+
content="Build and preview custom toast notifications"
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<meta
|
|
22
|
+
name="theme-color"
|
|
23
|
+
content="#3b82f6"
|
|
24
|
+
media="(prefers-color-scheme: light)"
|
|
25
|
+
/>
|
|
26
|
+
<meta
|
|
27
|
+
name="theme-color"
|
|
28
|
+
content="#1e40af"
|
|
29
|
+
media="(prefers-color-scheme: dark)"
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin />
|
|
33
|
+
|
|
34
|
+
<title>Toast Notification Builder</title>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<div id="app"></div>
|
|
38
|
+
<script type="module" src="/src/main.ts"></script>
|
|
39
|
+
|
|
40
|
+
<div
|
|
41
|
+
id="toast-announcer"
|
|
42
|
+
role="status"
|
|
43
|
+
aria-live="polite"
|
|
44
|
+
aria-atomic="true"
|
|
45
|
+
style="
|
|
46
|
+
position: absolute;
|
|
47
|
+
left: -10000px;
|
|
48
|
+
width: 1px;
|
|
49
|
+
height: 1px;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
"
|
|
52
|
+
></div>
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
package/jest.config.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
testEnvironment: "jsdom",
|
|
3
|
+
|
|
4
|
+
transform: {
|
|
5
|
+
"^.+\\.vue$": "@vue/vue3-jest",
|
|
6
|
+
"^.+\\.(ts|tsx)$": [
|
|
7
|
+
"ts-jest",
|
|
8
|
+
{
|
|
9
|
+
tsconfig: {
|
|
10
|
+
jsx: "preserve",
|
|
11
|
+
esModuleInterop: true,
|
|
12
|
+
allowSyntheticDefaultImports: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
"^.+\\.js$": "babel-jest",
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
moduleFileExtensions: ["js", "ts", "json", "vue"],
|
|
20
|
+
|
|
21
|
+
moduleNameMapper: {
|
|
22
|
+
"^@/(.*)$": "<rootDir>/src/$1",
|
|
23
|
+
"^@components/(.*)$": "<rootDir>/src/components/$1",
|
|
24
|
+
"^@composables/(.*)$": "<rootDir>/src/composables/$1",
|
|
25
|
+
"^@types/(.*)$": "<rootDir>/src/types/$1",
|
|
26
|
+
"^@utils/(.*)$": "<rootDir>/src/utils/$1",
|
|
27
|
+
"^@constants/(.*)$": "<rootDir>/src/constants/$1",
|
|
28
|
+
"^@styles/(.*)$": "<rootDir>/src/styles/$1",
|
|
29
|
+
"\\.(css|scss|sass)$": "<rootDir>/tests/__mocks__/styleMock.js",
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
testMatch: ["**/tests/**/*.spec.ts", "**/tests/**/*.test.ts"],
|
|
33
|
+
|
|
34
|
+
collectCoverageFrom: [
|
|
35
|
+
"src/**/*.{ts,vue}",
|
|
36
|
+
"!src/main.ts",
|
|
37
|
+
"!src/**/*.d.ts",
|
|
38
|
+
"!src/types/**/*",
|
|
39
|
+
"!src/assets/**/*",
|
|
40
|
+
],
|
|
41
|
+
|
|
42
|
+
coverageThreshold: {
|
|
43
|
+
global: {
|
|
44
|
+
branches: 70,
|
|
45
|
+
functions: 70,
|
|
46
|
+
lines: 70,
|
|
47
|
+
statements: 70,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
setupFilesAfterEnv: ["<rootDir>/tests/setup.ts"],
|
|
52
|
+
|
|
53
|
+
clearMocks: true,
|
|
54
|
+
restoreMocks: true,
|
|
55
|
+
|
|
56
|
+
verbose: true,
|
|
57
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "toast-builder-vue3",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "A modern, type-safe toast notification builder for Vue 3, built with TypeScript and Vite.",
|
|
7
|
+
"author": "Canberk Beren",
|
|
8
|
+
"license": "GPL-3.0",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"vue3",
|
|
11
|
+
"typescript",
|
|
12
|
+
"toast",
|
|
13
|
+
"notification",
|
|
14
|
+
"builder",
|
|
15
|
+
"vite"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/highpriv/toast-builder"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "vite",
|
|
23
|
+
"build": "vue-tsc -b && vite build",
|
|
24
|
+
"preview": "vite preview",
|
|
25
|
+
"test": "jest --verbose",
|
|
26
|
+
"test:watch": "jest --watch",
|
|
27
|
+
"test:coverage": "jest --coverage",
|
|
28
|
+
"type-check": "vue-tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"vue": "^3.5.25",
|
|
32
|
+
"nanoid": "^5.0.7"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@babel/core": "^7.24.0",
|
|
36
|
+
"@babel/preset-env": "^7.24.0",
|
|
37
|
+
"@babel/preset-typescript": "^7.24.0",
|
|
38
|
+
"@types/jest": "^29.5.12",
|
|
39
|
+
"@types/node": "^24.10.1",
|
|
40
|
+
"@vitejs/plugin-vue": "^6.0.2",
|
|
41
|
+
"@vue/test-utils": "^2.4.6",
|
|
42
|
+
"@vue/tsconfig": "^0.8.1",
|
|
43
|
+
"@vue/vue3-jest": "^29.2.6",
|
|
44
|
+
"babel-jest": "^29.7.0",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
47
|
+
"sass": "^1.77.0",
|
|
48
|
+
"ts-jest": "^29.2.0",
|
|
49
|
+
"typescript": "~5.9.3",
|
|
50
|
+
"vite": "^7.3.1",
|
|
51
|
+
"vue-tsc": "^3.1.5"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18.0.0",
|
|
55
|
+
"npm": ">=9.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/App.vue
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<ToastBuilder>
|
|
4
|
+
<template #config>
|
|
5
|
+
<ConfigPanel />
|
|
6
|
+
</template>
|
|
7
|
+
<template #preview>
|
|
8
|
+
<PreviewPane />
|
|
9
|
+
</template>
|
|
10
|
+
</ToastBuilder>
|
|
11
|
+
|
|
12
|
+
<ToastContainer position="top-left" />
|
|
13
|
+
<ToastContainer position="top-center" />
|
|
14
|
+
<ToastContainer position="top-right" />
|
|
15
|
+
<ToastContainer position="bottom-left" />
|
|
16
|
+
<ToastContainer position="bottom-center" />
|
|
17
|
+
<ToastContainer position="bottom-right" />
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { ToastBuilder, ConfigPanel, PreviewPane } from '@/components/builder';
|
|
23
|
+
import { ToastContainer } from '@/components/toast';
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<style>
|
|
27
|
+
#app {
|
|
28
|
+
width: 100%;
|
|
29
|
+
min-height: 100vh;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style.section">
|
|
3
|
+
<h3 :class="$style.title">Animation</h3>
|
|
4
|
+
<BaseSelect :modelValue="currentConfig.animation || 'fade'" :options="animationOptions"
|
|
5
|
+
@update:modelValue="handleAnimationChange" />
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import type { AnimationType } from '@/types';
|
|
11
|
+
import { BaseSelect, type SelectOption } from '@/components/common';
|
|
12
|
+
import { useToastBuilder } from '@/composables';
|
|
13
|
+
|
|
14
|
+
const { currentConfig, updateConfig } = useToastBuilder();
|
|
15
|
+
|
|
16
|
+
const animationOptions: SelectOption[] = [
|
|
17
|
+
{ value: 'fade', label: 'Fade' },
|
|
18
|
+
{ value: 'slide', label: 'Slide' },
|
|
19
|
+
{ value: 'bounce', label: 'Bounce' },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const handleAnimationChange = (value: string | number) => {
|
|
23
|
+
updateConfig({ animation: value as AnimationType });
|
|
24
|
+
};
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<style module lang="scss">
|
|
28
|
+
.section {
|
|
29
|
+
margin-bottom: var(--spacing-lg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.title {
|
|
33
|
+
font-size: var(--font-size-sm);
|
|
34
|
+
font-weight: var(--font-weight-semibold);
|
|
35
|
+
color: var(--text-secondary);
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
letter-spacing: 0.05em;
|
|
38
|
+
margin-bottom: var(--spacing-md);
|
|
39
|
+
}
|
|
40
|
+
</style>
|