@lukfel/ng-scaffold 20.0.55 → 20.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
@@ -11,19 +11,27 @@ This Angular library provides a foundational scaffold for modern web and mobile
11
11
 
12
12
 
13
13
  ## Installation
14
- Install the package using npm:
14
+ Install the package using `npm install` or `ng add` (with experimental Angular schematics):
15
15
 
16
16
  ```sh
17
17
  npm install @lukfel/ng-scaffold
18
18
  ```
19
19
 
20
+ ```sh
21
+ ng add @lukfel/ng-scaffold
22
+ ```
20
23
 
24
+ The ng add command will additionally try to perform the following actions:
25
+ * Import `ScaffoldModule`
26
+ * Inject `ScaffoldService` and initialize `ScaffoldConfig`
27
+ * Wrap template with `<lf-scaffold>`
28
+ * Include styles
21
29
 
22
30
 
23
31
  ## Module
24
32
  Import the `ScaffoldModule` into your `app.module.ts` file.
25
33
 
26
- * **Note:** (Optional) The library includes a built-in logging service called `Logger`, which logs library deugging events when a `ScaffoldLibraryConfig` is provided and `debugging` is set to `true`. Logging is automatically disabled in production mode when `production` is set to `true`.
34
+ * **Note:** (Optional) The library includes a built-in logging service called `Logger`, which logs library debugging events when a `ScaffoldLibraryConfig` is provided and `debugging` is set to `true`. Logging is automatically disabled in production mode when `production` is set to `true`.
27
35
 
28
36
  ```ts
29
37
  import { ScaffoldModule } from '@lukfel/ng-scaffold';
@@ -41,6 +49,75 @@ export class AppModule { }
41
49
 
42
50
 
43
51
 
52
+ ## Configuration
53
+ Import the `ScaffoldService` in `app.component.ts` to manage the `ScaffoldConfig`.
54
+
55
+ ```ts
56
+ import { ScaffoldService } from '@lukfel/ng-scaffold';
57
+
58
+ export class AppComponent {
59
+
60
+ public scaffoldConfig: ScaffoldConfig = {
61
+ // Create your own config or generate it at https://lukfel.github.io/ng-scaffold
62
+ };
63
+
64
+ constructor(private scaffoldService: ScaffoldService) {
65
+ this.scaffoldService.scaffoldConfig = this.scaffoldConfig;
66
+ }
67
+ }
68
+ ```
69
+
70
+ ### (Optional) Update Configuration
71
+ The `ScaffoldService` provides `updateScaffoldProperty()` to partially update the `ScaffoldConfig` in a type-safe way. It performs an immutable update, creating a new configuration object with the updated property and emits the new state.
72
+
73
+ ```ts
74
+ import { ScaffoldService, DrawerConfig, HeaderConfig, MenuButton } from '@lukfel/ng-scaffold';
75
+
76
+ export class AppComponent {
77
+
78
+ constructor(private scaffoldService: ScaffoldService) {
79
+ this.scaffoldService.scaffoldConfig = this.scaffoldConfig;
80
+ }
81
+
82
+ // Example #1: Toggle the drawer open state
83
+ public toggleDrawer(): void {
84
+ const currentDrawerConfig: DrawerConfig = this.scaffoldService.scaffoldConfig.drawerConfig!;
85
+ const updatedDrawerConfig: DrawerConfig = { ...currentDrawerConfig, open: !currentDrawerConfig.open };
86
+ this.scaffoldService.updateScaffoldProperty('drawerConfig', updatedDrawerConfig);
87
+ }
88
+
89
+ // Example #2: Enable the header input field
90
+ public enableHeaderInput(): void {
91
+ const currentHeaderConfig: HeaderConfig = this.scaffoldService.scaffoldConfig.headerConfig!;
92
+ const updatedHeaderConfig: HeaderConfig = { ...currentHeaderConfig, inputConfig: { enable: true } };
93
+ this.scaffoldService.updateScaffoldProperty('headerConfig', updatedHeaderConfig);
94
+ }
95
+
96
+ // Example #2: Add new button to navbar
97
+ public addNavbarButton(button: MenuButton): void {
98
+ const currentNavbarConfig: NavbarConfig = this.scaffoldService.scaffoldConfig.navbarConfig!;
99
+ const updatedNavbarConfig: NavbarConfig = { ...currentNavbarConfig, menuButtons: [...currentNavbarConfig.menuButtons!, button] };
100
+ this.scaffoldService.updateScaffoldProperty('navbarConfig', updatedNavbarConfig);
101
+ }
102
+ }
103
+ ```
104
+
105
+
106
+
107
+
108
+ ## Template
109
+ Wrap your application’s content inside the `lf-scaffold` component in `app.component.html`.
110
+
111
+ ```html
112
+ <lf-scaffold>
113
+ <ng-container drawerContent></ng-container> <!-- (Optional) content projection for drawer -->
114
+ <router-outlet></router-outlet>
115
+ </lf-scaffold>
116
+ ```
117
+
118
+
119
+
120
+
44
121
  ## Styling
45
122
  Import the styles in your `styles.scss` and apply a default theme.
46
123
 
@@ -51,7 +128,7 @@ Import the styles in your `styles.scss` and apply a default theme.
51
128
  @include lf.scaffold-theme(); // include a default theme
52
129
  ```
53
130
 
54
- ### Custom Themes (Optional)
131
+ ### (Optional) Custom Themes
55
132
  To customize the default theme, define a new theme map specifying `primary`, `accent`, and `warn` colors using Material palettes. Enabling the `dark` option applies a dark theme. Pass your custom theme to `lf.scaffold-theme($my-theme)`.
56
133
 
57
134
  ```scss
@@ -68,7 +145,7 @@ $my-theme: (
68
145
  @include lf.scaffold-theme($my-theme);
69
146
  ```
70
147
 
71
- ### Multiple Themes (Optional)
148
+ ### (Optional) Multiple Themes
72
149
  To switch between multiple themes dynamically, define additional themes using `lf.scaffold-colors($theme, 'theme-class')`, then apply the class to the `<body class="theme-class">` tag.
73
150
 
74
151
  * **Note:** The `ThemeService` allows dynamic theme switching.
@@ -94,7 +171,7 @@ $my-theme2: (
94
171
  @include lf.scaffold-colors($my-theme2, 'my-theme2'); // Set additional themes with lf.scaffold-colors(...)
95
172
  ```
96
173
 
97
- ### Custom Typography (Optional)
174
+ ### (Optional) Custom Typography
98
175
  To change the default typography from Roboto, pass an additional parameter ``font-family`` in the theme map.
99
176
 
100
177
  * **Note:** Don't forget to also import and set the font-family in the styles.
@@ -121,83 +198,10 @@ body {
121
198
 
122
199
 
123
200
 
124
- ## Template
125
- Wrap your application’s content inside the `lf-scaffold` component in `app.component.html`.
126
-
127
- ```html
128
- <lf-scaffold>
129
- <!-- (Optional) drawer content shows inside the left drawer if enabled -->
130
- <ng-container drawerContent></ng-container>
131
- <router-outlet></router-outlet>
132
- </lf-scaffold>
133
- ```
134
-
135
-
136
-
137
-
138
- ## Configuration
139
- Import the `ScaffoldService` in `app.component.ts` to manage the `ScaffoldConfig` settings.
140
-
141
- ```ts
142
- import { ScaffoldService } from '@lukfel/ng-scaffold';
143
-
144
- export class AppComponent {
145
- constructor(private scaffoldService: ScaffoldService) {}
146
- }
147
- ```
148
-
149
- ### Initialize Configuration
150
- Define the `ScaffoldConfig` in your `app.component.ts` and initialize the `scaffoldConfig` property in `ScaffoldService`.
151
-
152
- * **Notes:**
153
- * If a sub-configuration (e.g. `headerConfig`) is missing or does not have `enable: true`, the corresponding UI element will not be displayed.
154
-
155
- ```ts
156
- import { ScaffoldService, ScaffoldConfig } from '@lukfel/ng-scaffold';
157
-
158
- export class AppComponent {
159
-
160
- public scaffoldConfig: ScaffoldConfig = {
161
- scrollPositionRestoration: true,
162
- headerConfig: { enable: true, title: 'Scaffold', subtitle: 'by Lukas Felbinger' },
163
- navbarConfig: { enable: true },
164
- footerConfig: { enable: true, copyright: '© Lukas Felbinger 2025' },
165
- floatingButtonConfig: { enable: true }
166
- };
167
-
168
- constructor(private scaffoldService: ScaffoldService) {
169
- this.scaffoldService.scaffoldConfig = this.scaffoldConfig;
170
- }
171
- }
172
- ```
173
-
174
- ### Update Configuration (immutable, partial)
175
- The `ScaffoldService` provides a method `updateScaffoldProperty()` to partially update the `ScaffoldConfig` in a type-safe way. It performs an immutable update, creating a new configuration object with the updated property and emits the new state.
176
-
177
- ```ts
178
- import { ScaffoldService, DrawerConfig } from '@lukfel/ng-scaffold';
179
-
180
- export class AppComponent {
181
-
182
- constructor(private scaffoldService: ScaffoldService) {
183
- this.scaffoldService.scaffoldConfig = this.scaffoldConfig;
184
- }
185
-
186
- public toggleDrawer(): void {
187
- const currentDrawerConfig: DrawerConfig = this.scaffoldService.scaffoldConfig.drawerConfig;
188
- const updatedDrawerConfig: DrawerConfig = { ...currentDrawerConfig, open: !currentDrawerConfig.open };
189
- this.scaffoldService.updateScaffoldProperty('drawerConfig', updatedDrawerConfig);
190
- }
191
- }
192
- ```
193
-
194
-
195
-
196
-
197
201
  ## Events
198
202
  There are two ways to listen to scaffold user events (button clicks, input changes, ...):
199
203
 
200
- ### Option 1 (Recommended) – Subscribe to Observables
204
+ ### (Recommended) Option 1 – Subscribe to Event Observables
201
205
  Subscribe to the event Observables and listen to changes
202
206
  ```ts
203
207
  constructor(private scaffoldService: ScaffoldService, private router: Router) {
@@ -250,7 +254,7 @@ public navbarButtonClickEvent(id: string): void {
250
254
 
251
255
 
252
256
 
253
- ## Additional Services
257
+ ## (Optional) Additional Services
254
258
  This library includes several utility services:
255
259
 
256
260
  - **`Logger`** – Development-only logging
@@ -509,7 +513,7 @@ public onPlaceholderButtonClick(): void {
509
513
 
510
514
 
511
515
 
512
- ## Interceptors
516
+ ## (Optional) Interceptors
513
517
  Intercept HTTP Calls and automatically show a loading spinner.
514
518
 
515
519
  * **Note:** The loading spinner can also be manually shown by udpating the value for `scaffoldConfig.loading` in the `ScaffoldService`