@su-labs/notifications 21.0.4 โ†’ 21.0.5

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 (2) hide show
  1. package/README.md +183 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,47 @@
1
1
  # Notifications
2
2
 
3
+ `@su-labs/notifications`
4
+
5
+ ![Angular](https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white)
6
+ ![Angular Version](https://img.shields.io/badge/Angular-v21-DD0031?style=for-the-badge&logo=angular&logoColor=white)
7
+ ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
8
+ ![License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)
9
+ ![NPM](https://img.shields.io/badge/NPM-CB3837?style=for-the-badge&logo=npm&logoColor=white)
10
+ ![Size](https://img.shields.io/badge/Size-Small-green.svg?style=for-the-badge)
11
+ ![Downloads](https://img.shields.io/npm/dt/@su-labs/notifications?style=for-the-badge)
12
+ ![Version](https://img.shields.io/npm/v/@su-labs/notifications?style=for-the-badge)
13
+
3
14
  A highly customizable Angular notification library built with modern practices, including reactive Signals. Easily display different types of notifications with various positions, custom icons, and optional auto-closing behavior.
4
15
 
16
+ ## ๐Ÿ“š Table of Contents
17
+
18
+ - [Why Use This Library?](#-why-use-this-library)
19
+ - [Features](#features)
20
+ - [Installation](#installation)
21
+ - [Quick Start](#-quick-start)
22
+ - [Usage](#usage)
23
+ - [API Reference](#-api-reference)
24
+ - [Configuration Options](#configuration-options)
25
+ - [How It Works](#how-it-works)
26
+ - [Browser Compatibility](#-browser-compatibility)
27
+ - [Related Libraries](#-related-libraries)
28
+ - [Troubleshooting](#-troubleshooting)
29
+ - [Support](#-support)
30
+ - [Contributing](#contributing)
31
+ - [License](#license)
32
+
33
+ ## ๐Ÿ’ก Why Use This Library?
34
+
35
+ - ๐ŸŽฏ **Lightweight** - Minimal bundle size
36
+ - โšก **Reactive** - Built with Angular Signals
37
+ - ๐ŸŽจ **Customizable** - Multiple themes and positions
38
+ - ๐Ÿ–ผ๏ธ **Icon Support** - Default SVG or custom icons
39
+ - โฑ๏ธ **Auto-dismiss** - Configurable duration
40
+ - ๐Ÿ”’ **Type-Safe** - Full TypeScript support
41
+ - ๐Ÿ“ฆ **Zero Dependencies** - No bloat
42
+ - ๐Ÿงช **Well Tested** - Comprehensive test coverage
43
+ - ๐Ÿ“ **Well Documented** - Clear examples and API docs
44
+
5
45
  ## Features
6
46
 
7
47
  - **Reactive Core:** Built on Angular Signals for optimal performance and reactive updates.
@@ -26,7 +66,37 @@ npm install @su-labs/notifications
26
66
  This library requires the following peer dependencies:
27
67
 
28
68
  ```sh
29
- npm install @angular/common@">=21.0.0" @angular/core@">=21.0.0" @angular/platform-browser@">=21.0.0"
69
+ npm install @angular/common@^21 @angular/core@^21
70
+ ```
71
+
72
+ ## ๐Ÿš€ Quick Start
73
+
74
+ ```typescript
75
+ // 1. Install
76
+ npm install @su-labs/notifications
77
+
78
+ // 2. Add component to your app template
79
+ // app.component.html
80
+ <su-notifications></su-notifications>
81
+ <router-outlet></router-outlet>
82
+
83
+ // 3. Show notifications from any component
84
+ import { Component, inject } from '@angular/core';
85
+ import { SuNotificationService } from '@su-labs/notifications';
86
+
87
+ @Component({
88
+ template: `<button (click)="showSuccess()">Show Success</button>`
89
+ })
90
+ export class AppComponent {
91
+ notificationService = inject(SuNotificationService);
92
+
93
+ showSuccess() {
94
+ this.notificationService.show({
95
+ type: 'success',
96
+ message: 'Operation completed!'
97
+ });
98
+ }
99
+ }
30
100
  ```
31
101
 
32
102
  ## Usage
@@ -84,7 +154,7 @@ export class MyExampleComponent {
84
154
  this.notificationService.show({
85
155
  type: 'info',
86
156
  message: 'This is a custom icon notification.',
87
- icon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-zap"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>`
157
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>`
88
158
  });
89
159
  }
90
160
  }
@@ -94,7 +164,6 @@ export class MyExampleComponent {
94
164
 
95
165
  You can configure the global position of all notifications by directly setting the position property on the service instance. This is best done during application initialization.
96
166
 
97
-
98
167
  ```ts
99
168
  // src/app/app.config.ts
100
169
  import { ApplicationConfig, inject, provideAppInitializer } from '@angular/core';
@@ -111,6 +180,69 @@ export const appConfig: ApplicationConfig = {
111
180
  };
112
181
  ```
113
182
 
183
+ ## ๐Ÿ“– API Reference
184
+
185
+ ### Service (SuNotificationService)
186
+
187
+ #### Properties
188
+
189
+ | Property | Type | Description |
190
+ |----------|------|-------------|
191
+ | `position` | `NotificationPosition` | Global notification position |
192
+
193
+ #### Methods
194
+
195
+ | Method | Parameters | Description |
196
+ |--------|------------|-------------|
197
+ | `show(config)` | `NotificationConfig` | Display a new notification |
198
+ | `dismiss(id)` | `string` | Manually dismiss a notification |
199
+
200
+ ### Types
201
+
202
+ ```typescript
203
+ type NotificationType = 'info' | 'success' | 'warning' | 'error' | 'custom';
204
+
205
+ type NotificationPosition =
206
+ | 'top-right'
207
+ | 'top-left'
208
+ | 'bottom-right'
209
+ | 'bottom-left'
210
+ | 'top-center'
211
+ | 'bottom-center';
212
+
213
+ interface NotificationConfig {
214
+ type: NotificationType;
215
+ message: string;
216
+ duration?: number; // Default: 3000ms
217
+ autoClose?: boolean; // Default: true
218
+ cssClass?: string; // Custom CSS class
219
+ icon?: string; // Custom SVG string or image URL
220
+ }
221
+ ```
222
+
223
+ ## Configuration Options
224
+
225
+ ### Notification Types
226
+
227
+ | Type | Description | Default Icon |
228
+ |------|-------------|--------------|
229
+ | `info` | Informational message | โ„น๏ธ |
230
+ | `success` | Success message | โœ… |
231
+ | `warning` | Warning message | โš ๏ธ |
232
+ | `error` | Error message | โŒ |
233
+ | `custom` | Custom styled message | ๐Ÿ”” |
234
+
235
+ ### Positions
236
+
237
+ | Position | Description |
238
+ |----------|-------------|
239
+ | `top-right` | Top right corner (default) |
240
+ | `top-left` | Top left corner |
241
+ | `top-center` | Top center |
242
+ | `bottom-right` | Bottom right corner |
243
+ | `bottom-left` | Bottom left corner |
244
+ | `bottom-center` | Bottom center |
245
+
114
246
  ## How It Works
115
247
 
116
248
  The library consists of a stateless service (`SuNotificationService`) and a presentational component (`SuNotificationComponent`).
@@ -119,6 +251,54 @@ The service manages a list of notifications using a private Signal. When you cal
119
251
 
120
252
  The component's icons are rendered using `[innerHTML]` to safely inject SVG markup into the template. Angular's `DomSanitizer` is used to prevent security risks like Cross-Site Scripting (XSS) attacks.
121
253
 
254
+ ## ๐ŸŒ Browser Compatibility
255
+
256
+ Works in all modern browsers that support:
257
+ - โœ… CSS Flexbox
258
+ - โœ… CSS Animations
259
+ - โœ… Angular 21+
260
+ - โœ… ES2022+
261
+
262
+ | Browser | Version |
263
+ |---------|---------|
264
+ | Chrome | โ‰ฅ 90 |
265
+ | Firefox | โ‰ฅ 88 |
266
+ | Safari | โ‰ฅ 14 |
267
+ | Edge | โ‰ฅ 90 |
268
+
269
+ ## ๐Ÿ”— Related Libraries
270
+
271
+ Part of the **@su-labs** suite:
272
+
273
+ - ๐Ÿ‘€ [@su-labs/visit-tracker](https://www.npmjs.com/package/@su-labs/visit-tracker) - User visit tracking
274
+ - ๐ŸŽจ [@su-labs/theme](https://www.npmjs.com/package/@su-labs/theme) - Theme management with dark mode support
275
+ - ๐Ÿ” [@su-labs/scroll-spy](https://www.npmjs.com/package/@su-labs/scroll-spy) - Scroll position tracking
276
+ - ๐Ÿ“ [@su-labs/font-size](https://www.npmjs.com/package/@su-labs/font-size) - Accessible font size controls
277
+
278
+ ## ๐Ÿ”ง Troubleshooting
279
+
280
+ ### Notifications not showing?
281
+
282
+ Make sure you've added `<su-notifications></su-notifications>` to your root component template.
283
+
284
+ ### Icons not displaying?
285
+
286
+ If using custom icons, ensure the SVG string is valid. For security, Angular sanitizes HTML by default.
287
+
288
+ ### Position not changing?
289
+
290
+ Set the position property during app initialization using `provideAppInitializer`.
291
+
292
+ ### TypeScript errors?
293
+
294
+ Ensure you have Angular 21+ and TypeScript 5.7+ installed.
295
+
296
+ ## ๐Ÿ’ฌ Support
297
+
298
+ - ๐Ÿ› Found a bug? [Open an issue](https://github.com/Greezaaa/settings-utils-lib/issues)
299
+ - ๐Ÿ’ก Have a feature request? [Start a discussion](https://github.com/Greezaaa/settings-utils-lib/discussions)
300
+ - โญ Like this library? [Give it a star!](https://github.com/Greezaaa/settings-utils-lib)
301
+
122
302
  ## Contributing
123
303
 
124
304
  If you find any bugs or have feature requests, please open an issue or submit a pull request on our [GitHub repository](https://github.com/Greezaaa/settings-utils-lib.git).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@su-labs/notifications",
3
- "version": "21.0.4",
3
+ "version": "21.0.5",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "notifications",