@nettyapps/ntybase 0.0.1

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 ADDED
@@ -0,0 +1,166 @@
1
+ # Netty Base Library
2
+
3
+ Netty Base Library
4
+ The @nettyapps/ntybase library provides foundational services and components for Angular applications, including theme management, authentication, alerts, menus, and AG-Grid integration.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @nettyapps/ntybase
10
+ ```
11
+
12
+ ## Theme Management Systems
13
+
14
+ The `@nettyapps/ntybase` library provides flexible theme management through two complementary systems:
15
+
16
+ 1. Color Palette - For primary/secondary color schemes
17
+ 2. App Theme - For light/dark mode system
18
+
19
+ ### Adding New Color Themes
20
+
21
+ #### Generating Custom Color Palettes with Angular Material
22
+
23
+ Angular Material provides a powerful schematic for automatically generating complete color palettes from base colors, eliminating the need to manually create theme files.
24
+
25
+ #### 1. Install Required Packages
26
+
27
+ First ensure you have `@angular/material` and `@angular/cdk` installed:
28
+
29
+ ```bash
30
+ npm install @angular/material @angular/cdk
31
+ ```
32
+
33
+ ##### 2. Generate a Custom Palette
34
+
35
+ Use the Angular CLI to generate a custom palette:
36
+
37
+ ```bash
38
+ ng generate @angular/material:theme-color
39
+ ```
40
+
41
+ #### 3. Output Structure
42
+
43
+ The schematic will generate:
44
+
45
+ ```
46
+ src/
47
+ └── app/
48
+ └── themes/
49
+ ├── custom-themes.css # Your custom palette definition
50
+ └── deep-bluetheme.css # Generated palette variables
51
+ ```
52
+
53
+ #### 4. Using the Generated Theme
54
+
55
+ Import and use your theme:
56
+
57
+ `custom-themes.css`:
58
+
59
+ ```scss
60
+ @import "./deep-bluetheme.css";
61
+ ```
62
+
63
+ `styles.scss`:
64
+
65
+ ```scss
66
+ @use "@angular/material" as mat;
67
+ @include mat.core();
68
+ @import "./app/themes/custom-themes.css";
69
+ ```
70
+
71
+ Here's an example of the generated theme CSS that will be available in `deep-blue-theme.css`
72
+
73
+ ```scss
74
+ /* Note: Color palettes are generated from primary: #1976D2 */
75
+ .deep-blue-theme {
76
+ /* COLOR SYSTEM VARIABLES */
77
+ color-scheme: dark;
78
+
79
+ /* Required field */
80
+ --mat-sys-required: light-dark(var(--mat-sys-secondary-container), var(--mat-sys-inverse-primary));
81
+ --mat-sys-user-info: light-dark(var(--mat-sys-secondary-container), var(--mat-sys-primary));
82
+ --mat-sys-user-text: light-dark(var(--mat-sys-on-primary-container), var(--mat-sys-on-primary));
83
+
84
+ /* Primary palette variables */
85
+ --mat-sys-primary: light-dark(#005faf, #a5c8ff);
86
+ --mat-sys-on-primary: light-dark(#ffffff, #00315f);
87
+ --mat-sys-primary-container: light-dark(#d4e3ff, #004786);
88
+ --mat-sys-on-primary-container: light-dark(#001c3a, #d4e3ff);
89
+ --mat-sys-inverse-primary: light-dark(#a5c8ff, #005faf);
90
+ --mat-sys-primary-fixed: light-dark(#d4e3ff, #d4e3ff);
91
+ --mat-sys-primary-fixed-dim: light-dark(#a5c8ff, #a5c8ff);
92
+ --mat-sys-on-primary-fixed: light-dark(#001c3a, #001c3a);
93
+ --mat-sys-on-primary-fixed-variant: light-dark(#004786, #004786);
94
+
95
+ /* Secondary palette variables */
96
+ --mat-sys-secondary: light-dark(#475f84, #afc8f1);
97
+ --mat-sys-on-secondary: light-dark(#ffffff, #163153);
98
+ --mat-sys-secondary-container: light-dark(#d4e3ff, #2f486a);
99
+ --mat-sys-on-secondary-container: light-dark(#001c3a, #d4e3ff);
100
+ --mat-sys-secondary-fixed: light-dark(#d4e3ff, #d4e3ff);
101
+ --mat-sys-secondary-fixed-dim: light-dark(#afc8f1, #afc8f1);
102
+ --mat-sys-on-secondary-fixed: light-dark(#001c3a, #001c3a);
103
+ --mat-sys-on-secondary-fixed-variant: light-dark(#2f486a, #2f486a);
104
+ }
105
+ ```
106
+
107
+ ### Configuring ColorPalette Service
108
+
109
+ #### Define Your Theme Colors
110
+
111
+ After generating your palettes, integrate them with the ColorPalette service:
112
+
113
+ ```typescript
114
+ import { ColorPalette } from '@nettyapps/ntybase';
115
+
116
+ private colorPalette = inject(ColorPalette);
117
+
118
+ constructor() {
119
+ this.loadCustomThemes();
120
+ }
121
+
122
+ private loadCustomThemes(): void {
123
+ const customThemes = [
124
+ {
125
+ id: 'deep-blue',
126
+ primary: '#1976D2',
127
+ displayName: 'Deep Blue',
128
+ },
129
+ {
130
+ id: 'green',
131
+ primary: '#00796B',
132
+ displayName: 'Green'
133
+ },
134
+ {
135
+ id: 'orange',
136
+ primary: '#E65100',
137
+ displayName: 'Orange'
138
+ },
139
+ {
140
+ id: 'purple',
141
+ primary: '#6200EE',
142
+ displayName: 'Purple'
143
+ },
144
+ {
145
+ id: 'red',
146
+ primary: '#C2185B',
147
+ displayName: 'Red'
148
+ },
149
+ {
150
+ id: 'blue-orange',
151
+ primary: '#0D5EA6',
152
+ displayName: 'Blue/Orange'
153
+ },
154
+ {
155
+ id: 'gray',
156
+ primary: '#555',
157
+ displayName: 'Gray'
158
+ },
159
+ ];
160
+
161
+ this.colorPalette.setThemes(customThemes);
162
+
163
+ // Set default theme
164
+ this.colorPalette.setTheme('green');
165
+ }
166
+ ```