sgh-navbar 0.0.54 → 0.0.57

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 CHANGED
@@ -1,33 +1,589 @@
1
- # SghNavbar
1
+ # SGH-Navbar Library
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.0.
3
+ [![npm version](https://badge.fury.io/js/sgh-navbar.svg)](https://badge.fury.io/js/sgh-navbar)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
5
 
5
- ## Code scaffolding
6
+ A comprehensive Angular navigation library that provides a responsive sidebar navigation, toolbar with theme switching, breadcrumbs, and client management features.
6
7
 
7
- Run `ng generate component component-name --project sgh-navbar` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project sgh-navbar`.
8
- > Note: Don't forget to add `--project sgh-navbar` or else it will be added to the default project in your `angular.json` file.
8
+ ## Table of Contents
9
9
 
10
- ## Build
10
+ - [Features](#features)
11
+ - [Installation](#installation)
12
+ - [Quick Start](#quick-start)
13
+ - [Components](#components)
14
+ - [Configuration](#configuration)
15
+ - [Customization](#customization)
16
+ - [API Reference](#api-reference)
17
+ - [Examples](#examples)
18
+ - [Troubleshooting](#troubleshooting)
19
+ - [Development](#development)
20
+ - [License](#license)
11
21
 
12
- Run `ng build sgh-navbar` to build the project. The build artifacts will be stored in the `dist/` directory.
22
+ ## Features
13
23
 
14
- ## Publishing
24
+ **Rich Feature Set**
25
+ - 🎨 **Multiple Themes** - Built-in theme switching (Default, Light, Blue)
26
+ - 🔧 **Highly Configurable** - Extensive customization options
27
+ - 📱 **Responsive Design** - Mobile-friendly collapsible navigation
28
+ - 🧭 **Navigation Management** - Multi-level menu support with animations
29
+ - 👥 **Client Management** - Built-in client/sub-client selection
30
+ - 🍞 **Breadcrumbs** - Automatic breadcrumb generation
31
+ - 🔔 **Notifications** - Notification panel support
32
+ - 👤 **User Profile** - Profile dropdown integration
33
+ - ⚡ **Performance Optimized** - Lazy loading and memory leak prevention
34
+ - 🎯 **Type Safe** - Full TypeScript support
15
35
 
16
- After building your library with `ng build sgh-navbar`, go to the dist folder `cd dist/sgh-navbar` and run `npm publish`.
36
+ ## Installation
17
37
 
18
- ## Running unit tests
38
+ ### Prerequisites
19
39
 
20
- Run `ng test sgh-navbar` to execute the unit tests via [Karma](https://karma-runner.github.io).
40
+ - Angular 19.x
41
+ - Angular Material 19.x
42
+ - Angular CDK 19.x
43
+ - RxJS 7.x
21
44
 
22
- ## Further help
45
+ ### Install via npm
23
46
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
47
+ ```bash
48
+ npm install sgh-navbar
49
+ ```
25
50
 
26
- ## Version details
51
+ ### Install Peer Dependencies
27
52
 
28
- # Angular Version Library Version Description
29
- 15 0.0.43
30
- 16 0.0.50
31
- 17 0.0.51
32
- 18 0.0.52
33
- 19 0.0.53
53
+ ```bash
54
+ npm install @angular/material @angular/cdk @angular/animations @angular/forms
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ### 1. Import the Module
60
+
61
+ ```typescript
62
+ // app.module.ts
63
+ import { NgModule } from '@angular/core';
64
+ import { BrowserModule } from '@angular/platform-browser';
65
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
66
+ import { SghNavbarModule } from 'sgh-navbar';
67
+
68
+ import { AppComponent } from './app.component';
69
+
70
+ @NgModule({
71
+ declarations: [AppComponent],
72
+ imports: [
73
+ BrowserModule,
74
+ BrowserAnimationsModule, // Required for animations
75
+ SghNavbarModule
76
+ ],
77
+ providers: [],
78
+ bootstrap: [AppComponent]
79
+ })
80
+ export class AppModule { }
81
+ ```
82
+
83
+ ### 2. Basic Implementation
84
+
85
+ ```typescript
86
+ // app.component.ts
87
+ import { Component } from '@angular/core';
88
+ import {
89
+ SidenavData,
90
+ ToolbarData,
91
+ DEFAULT_SIDENAV_CONFIG,
92
+ DEFAULT_TOOLBAR_CONFIG
93
+ } from 'sgh-navbar';
94
+
95
+ @Component({
96
+ selector: 'app-root',
97
+ template: `
98
+ <lib-sgh-navbar
99
+ [sidenavData]="sidenavConfig"
100
+ [toolbarData]="toolbarConfig"
101
+ [expanded]="isNavExpanded"
102
+ [showBreadcrumbs]="true"
103
+ (toggleSidebarEvent)="onToggleSidebar($event)"
104
+ (searchInputEvent)="onSearch($event)"
105
+ (clientChange)="onClientChange($event)"
106
+ (subClientChange)="onSubClientChange($event)">
107
+
108
+ <!-- Your main content goes here -->
109
+ <div class="main-content">
110
+ <router-outlet></router-outlet>
111
+ </div>
112
+
113
+ </lib-sgh-navbar>
114
+ `
115
+ })
116
+ export class AppComponent {
117
+ isNavExpanded = false;
118
+ sidenavConfig: SidenavData = DEFAULT_SIDENAV_CONFIG;
119
+ toolbarConfig: ToolbarData = DEFAULT_TOOLBAR_CONFIG;
120
+
121
+ onToggleSidebar(expanded: boolean): void {
122
+ this.isNavExpanded = expanded;
123
+ }
124
+
125
+ onSearch(searchTerm: string): void {
126
+ console.log('Search:', searchTerm);
127
+ }
128
+
129
+ onClientChange(client: any): void {
130
+ console.log('Client changed:', client);
131
+ }
132
+
133
+ onSubClientChange(subClient: any): void {
134
+ console.log('Sub-client changed:', subClient);
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### 3. Add Required Styles
140
+
141
+ ```scss
142
+ // styles.scss or in your component
143
+ @import '~@angular/material/prebuilt-themes/indigo-pink.css';
144
+
145
+ // Optional: Add Font Awesome for icons
146
+ @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css');
147
+
148
+ // Basic layout styles
149
+ body {
150
+ margin: 0;
151
+ font-family: Roboto, sans-serif;
152
+ }
153
+
154
+ .main-content {
155
+ padding: 20px;
156
+ min-height: calc(100vh - 64px);
157
+ }
158
+ ```
159
+
160
+ ## Components
161
+
162
+ ### Main Component: `<lib-sgh-navbar>`
163
+
164
+ The primary component that wraps your entire application layout.
165
+
166
+ #### Inputs
167
+ - `sidenavData: SidenavData` - Configuration for sidebar navigation
168
+ - `toolbarData: ToolbarData` - Configuration for toolbar
169
+ - `expanded: boolean` - Controls sidebar expanded state
170
+ - `showBreadcrumbs: boolean` - Show/hide breadcrumb navigation
171
+
172
+ #### Outputs
173
+ - `toggleSidebarEvent: EventEmitter<boolean>` - Sidebar toggle events
174
+ - `searchInputEvent: EventEmitter<string>` - Search input events
175
+ - `clientChange: EventEmitter<ClientListItem>` - Client selection events
176
+ - `subClientChange: EventEmitter<SubClientListItem>` - Sub-client selection events
177
+ - `sidenavToggle: EventEmitter<any>` - Sidenav toggle events
178
+
179
+ ### Individual Components
180
+
181
+ #### `<sgh-toolbar>`
182
+ Top navigation bar with logo, search, notifications, and user profile.
183
+
184
+ #### `<sgh-sidenav>`
185
+ Collapsible sidebar navigation with multi-level menu support.
186
+
187
+ #### `<sgh-sublevel-menu>`
188
+ Handles nested navigation menu items with animations.
189
+
190
+ #### `<sgh-notification-list>`
191
+ Dropdown notification panel.
192
+
193
+ #### `<sgh-menu-list-item>`
194
+ Individual menu item with expand/collapse functionality.
195
+
196
+ ## Configuration
197
+
198
+ ### Sidenav Configuration
199
+
200
+ ```typescript
201
+ import { SidenavData, INavbarData } from 'sgh-navbar';
202
+
203
+ const customSidenavConfig: SidenavData = {
204
+ navData: [
205
+ {
206
+ label: 'Dashboard',
207
+ icon: 'dashboard',
208
+ routeLink: '/dashboard',
209
+ visible: true,
210
+ items: [
211
+ {
212
+ label: 'Analytics',
213
+ icon: 'analytics',
214
+ routeLink: '/dashboard/analytics',
215
+ visible: true
216
+ },
217
+ {
218
+ label: 'Reports',
219
+ icon: 'assessment',
220
+ routeLink: '/dashboard/reports',
221
+ visible: true,
222
+ items: [
223
+ {
224
+ label: 'Sales Report',
225
+ icon: '',
226
+ routeLink: '/dashboard/reports/sales',
227
+ visible: true
228
+ }
229
+ ]
230
+ }
231
+ ]
232
+ },
233
+ {
234
+ label: 'Users',
235
+ icon: 'people',
236
+ routeLink: '/users',
237
+ visible: true
238
+ },
239
+ {
240
+ label: 'Settings',
241
+ icon: 'settings',
242
+ routeLink: '/settings',
243
+ visible: true
244
+ }
245
+ ],
246
+ bgColor: '#2c3e50',
247
+ imgSm: 'assets/logo-sm.png',
248
+ imgLg: 'assets/logo-lg.png',
249
+ activeRole: 'Administrator'
250
+ };
251
+ ```
252
+
253
+ ### Toolbar Configuration
254
+
255
+ ```typescript
256
+ import { ToolbarData, ThemeOption, ClientListItem } from 'sgh-navbar';
257
+
258
+ const customToolbarConfig: ToolbarData = {
259
+ themeOptions: [
260
+ {
261
+ name: 'Dark Theme',
262
+ value: 'dark-theme',
263
+ checked: true
264
+ },
265
+ {
266
+ name: 'Light Theme',
267
+ value: 'light-theme',
268
+ checked: false
269
+ },
270
+ {
271
+ name: 'Blue Theme',
272
+ value: 'blue-theme',
273
+ checked: false
274
+ }
275
+ ],
276
+ bgColor: '#1976d2',
277
+ img: 'assets/company-logo.svg',
278
+ searchEnable: true,
279
+ notificationEnable: true,
280
+ profileEnable: true,
281
+ settingsEnable: true,
282
+ profileView: false,
283
+ profileContent: `
284
+ <div class="profile-info">
285
+ <h4>John Doe</h4>
286
+ <p>Administrator</p>
287
+ <button class="btn-logout">Logout</button>
288
+ </div>
289
+ `,
290
+ clientConfigurationEnable: true,
291
+ applicationConfigurationEnable: true,
292
+ clientList: [
293
+ {
294
+ text: 'Acme Corporation',
295
+ value: 'ACME_CORP',
296
+ selected: true,
297
+ subClientList: [
298
+ {
299
+ text: 'Marketing Department',
300
+ value: 'MARKETING',
301
+ checked: true
302
+ },
303
+ {
304
+ text: 'Sales Department',
305
+ value: 'SALES',
306
+ checked: false
307
+ }
308
+ ]
309
+ }
310
+ ]
311
+ };
312
+ ```
313
+
314
+ ## API Reference
315
+
316
+ ### Interfaces
317
+
318
+ #### `SidenavData`
319
+ ```typescript
320
+ interface SidenavData {
321
+ navData: INavbarData[];
322
+ bgColor: string;
323
+ imgSm: string;
324
+ imgLg: string;
325
+ client?: ClientListItem;
326
+ subclient?: SubClientListItem;
327
+ activeRole?: string;
328
+ }
329
+ ```
330
+
331
+ #### `INavbarData`
332
+ ```typescript
333
+ interface INavbarData {
334
+ routeLink: string;
335
+ icon: string;
336
+ label: string;
337
+ visible: boolean;
338
+ expanded?: boolean;
339
+ items?: INavbarData[];
340
+ customLinkCSS?: string;
341
+ }
342
+ ```
343
+
344
+ #### `ToolbarData`
345
+ ```typescript
346
+ interface ToolbarData {
347
+ themeOptions: ThemeOption[];
348
+ clientList?: ClientListItem[];
349
+ bgColor: string;
350
+ img: string;
351
+ searchEnable?: boolean;
352
+ notificationEnable?: boolean;
353
+ profileEnable?: boolean;
354
+ settingsEnable?: boolean;
355
+ profileView?: boolean;
356
+ profileContent?: string;
357
+ clientConfigurationEnable?: boolean;
358
+ applicationConfigurationEnable?: boolean;
359
+ isThemeCollapsed?: boolean;
360
+ isNotifNavCollapsed?: boolean;
361
+ }
362
+ ```
363
+
364
+ ## Examples
365
+
366
+ ### Basic E-commerce Application
367
+
368
+ ```typescript
369
+ import { Component } from '@angular/core';
370
+ import { SidenavData, ToolbarData } from 'sgh-navbar';
371
+
372
+ @Component({
373
+ selector: 'app-ecommerce',
374
+ template: `
375
+ <lib-sgh-navbar
376
+ [sidenavData]="sidenavConfig"
377
+ [toolbarData]="toolbarConfig"
378
+ [expanded]="navExpanded">
379
+ <router-outlet></router-outlet>
380
+ </lib-sgh-navbar>
381
+ `
382
+ })
383
+ export class EcommerceComponent {
384
+ navExpanded = false;
385
+
386
+ sidenavConfig: SidenavData = {
387
+ navData: [
388
+ {
389
+ label: 'Dashboard',
390
+ icon: 'dashboard',
391
+ routeLink: '/dashboard',
392
+ visible: true
393
+ },
394
+ {
395
+ label: 'Products',
396
+ icon: 'inventory',
397
+ routeLink: '/products',
398
+ visible: true,
399
+ items: [
400
+ {
401
+ label: 'All Products',
402
+ icon: 'list',
403
+ routeLink: '/products/list',
404
+ visible: true
405
+ },
406
+ {
407
+ label: 'Add Product',
408
+ icon: 'add',
409
+ routeLink: '/products/add',
410
+ visible: true
411
+ }
412
+ ]
413
+ },
414
+ {
415
+ label: 'Orders',
416
+ icon: 'shopping_cart',
417
+ routeLink: '/orders',
418
+ visible: true
419
+ }
420
+ ],
421
+ bgColor: '#1976d2',
422
+ imgSm: 'assets/logo-sm.png',
423
+ imgLg: 'assets/logo-lg.png'
424
+ };
425
+
426
+ toolbarConfig: ToolbarData = {
427
+ themeOptions: [
428
+ { name: 'Blue Theme', value: 'blue-theme', checked: true },
429
+ { name: 'Dark Theme', value: 'dark-theme', checked: false }
430
+ ],
431
+ bgColor: '#1976d2',
432
+ img: 'assets/company-logo.svg',
433
+ searchEnable: true,
434
+ notificationEnable: true,
435
+ profileEnable: true,
436
+ settingsEnable: true
437
+ };
438
+ }
439
+ ```
440
+
441
+ ### Custom Theme Example
442
+
443
+ ```scss
444
+ // custom-theme.scss
445
+ .my-custom-theme {
446
+ // Toolbar customization
447
+ .toolbar-main-wrapper {
448
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
449
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
450
+ }
451
+
452
+ // Sidebar customization
453
+ .sgh-sidebar {
454
+ background: linear-gradient(180deg, #2c3e50 0%, #3498db 100%);
455
+
456
+ .sidebar_div a {
457
+ color: #ecf0f1;
458
+ transition: all 0.3s ease;
459
+
460
+ &:hover {
461
+ background: rgba(52, 152, 219, 0.2);
462
+ transform: translateX(5px);
463
+ }
464
+
465
+ &.item-active {
466
+ background: rgba(52, 152, 219, 0.3);
467
+ border-left: 4px solid #3498db;
468
+ }
469
+ }
470
+ }
471
+ }
472
+ ```
473
+
474
+ ## Troubleshooting
475
+
476
+ ### Common Issues
477
+
478
+ #### 1. **Animations not working**
479
+ ```typescript
480
+ // Make sure you have BrowserAnimationsModule imported
481
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
482
+
483
+ @NgModule({
484
+ imports: [
485
+ BrowserAnimationsModule // Required for animations
486
+ ]
487
+ })
488
+ ```
489
+
490
+ #### 2. **Icons not displaying**
491
+ ```html
492
+ <!-- Add Font Awesome to your index.html -->
493
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
494
+ ```
495
+
496
+ #### 3. **Styles not applied**
497
+ ```scss
498
+ // Make sure to import Angular Material theme
499
+ @import '~@angular/material/prebuilt-themes/indigo-pink.css';
500
+ ```
501
+
502
+ #### 4. **Navigation not working**
503
+ ```typescript
504
+ // Ensure RouterModule is configured
505
+ import { RouterModule } from '@angular/router';
506
+
507
+ @NgModule({
508
+ imports: [
509
+ RouterModule.forRoot(routes)
510
+ ]
511
+ })
512
+ ```
513
+
514
+ ## Development
515
+
516
+ ### Building the Library
517
+
518
+ ```bash
519
+ # Build the library
520
+ ng build sgh-navbar
521
+
522
+ # Build in watch mode
523
+ ng build sgh-navbar --watch
524
+ ```
525
+
526
+ ### Running Tests
527
+
528
+ ```bash
529
+ # Run unit tests
530
+ ng test sgh-navbar
531
+
532
+ # Run tests with coverage
533
+ ng test sgh-navbar --code-coverage
534
+ ```
535
+
536
+ ### Publishing
537
+
538
+ ```bash
539
+ # Build the library
540
+ ng build sgh-navbar
541
+
542
+ # Navigate to dist folder
543
+ cd dist/sgh-navbar
544
+
545
+ # Publish to npm
546
+ npm publish
547
+ ```
548
+
549
+ ## Version History
550
+
551
+ | Angular Version | Library Version | Description |
552
+ |----------------|-----------------|-------------|
553
+ | 15 | 0.0.43 | Initial release |
554
+ | 16 | 0.0.50 | Angular 16 support |
555
+ | 17 | 0.0.51 | Angular 17 support |
556
+ | 18 | 0.0.52 | Angular 18 support |
557
+ | 19 | 0.0.54 | Angular 19 support, Major fixes and improvements |
558
+ | 19 | 0.0.57 | Enhanced layout behavior, responsive design improvements |
559
+
560
+ ### Latest Changes (v0.0.55)
561
+ - ✅ Fixed notification component typo
562
+ - ✅ Added proper TypeScript types throughout
563
+ - ✅ Updated component selectors to use sgh- prefix
564
+ - ✅ Extracted hardcoded configurations
565
+ - ✅ Added proper error handling and null checks
566
+ - ✅ Improved performance and memory management
567
+ - ✅ Added comprehensive documentation
568
+ - ✅ **Enhanced Layout Behavior**: Content area now properly moves right and adjusts width when sidebar is open
569
+ - ✅ **Responsive Design**: Smart layout adjustments for desktop (content shifts), tablet (content shifts), and mobile (overlay mode)
570
+ - ✅ **Smooth Animations**: Added smooth transitions for layout changes and content positioning
571
+ - ✅ **Visual Enhancements**: Added subtle shadows and overlay effects for better depth perception
572
+ - ✅ **Fixed Toggle Logic**: Resolved double-click toggle issue - sidebar now toggles correctly with single click
573
+
574
+ ## Browser Support
575
+
576
+ - Chrome 60+
577
+ - Firefox 60+
578
+ - Safari 12+
579
+ - Edge 79+
580
+ - iOS Safari 12+
581
+ - Android Browser 81+
582
+
583
+ ## License
584
+
585
+ This project is licensed under the MIT License.
586
+
587
+ ---
588
+
589
+ **Made with ❤️ by the SGH Team**