@dragonworks/ngx-dashboard-widgets 20.3.2 → 21.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/README.md CHANGED
@@ -1,194 +1,194 @@
1
- # @dragonworks/ngx-dashboard-widgets
2
-
3
- Example widget collection for ngx-dashboard with Material Design 3 compliance and advanced features.
4
- You can use these widgets as inspiration or as a base for your own implementations.
5
-
6
- ## Installation
7
-
8
- ```bash
9
- npm install @dragonworks/ngx-dashboard-widgets @dragonworks/ngx-dashboard
10
- ```
11
-
12
- ## Requirements
13
-
14
- - Angular 20.2.0+
15
- - @dragonworks/ngx-dashboard 20.0.0+
16
-
17
- ## Included Example Widgets
18
-
19
- ### ArrowWidget
20
-
21
- - **Directional indicators** with 360° rotation control
22
- - **Configurable appearance**: Size, color, rotation angle
23
- - **Material Design icons** with currentColor theme support
24
- - **Settings dialog** for interactive configuration
25
-
26
- ### LabelWidget
27
-
28
- - **Text display** with rich formatting options
29
- - **Responsive sizing** with alignment controls
30
- - **Background customization** with theme-aware colors
31
- - **Font size controls** with min/max constraints
32
-
33
- ### ClockWidget
34
-
35
- - **Dual-mode display**: Analog and digital formats
36
- - **Real-time updates** with automatic timer management
37
- - **Configurable formats**: 12h/24h time, seconds display
38
- - **Component composition**: Separate analog/digital components
39
-
40
- ### RadialGaugeWidget
41
-
42
- - **Semi-circular gauge** for value visualization
43
- - **Responsive text rendering**: SVG-native with BBox scaling
44
- - **Theme integration** with MD3 color tokens
45
- - **Performance optimized** with signal-based updates
46
-
47
- ## Components & Utilities
48
-
49
- ### RadialGaugeComponent
50
-
51
- Standalone SVG gauge component:
52
-
53
- - **Dynamic sizing** with ResizeObserver integration
54
- - **Mathematical positioning** using computed transforms
55
- - **Reference text system** for consistent measurements
56
- - **Configurable display**: Value labels, legends, colors
57
- - **Accessibility features** with ARIA attributes
58
-
59
- ### ResponsiveTextDirective
60
-
61
- Text sizing directive:
62
-
63
- - **Automatic font scaling** to fit container
64
- - **Performance optimized** with canvas measurement
65
- - **Developer-friendly API**: minFontSize/maxFontSize inputs
66
- - **Ellipsis-free design** for clean appearance
67
-
68
- ## Usage
69
-
70
- ### Basic Widget Registration
71
-
72
- ```typescript
73
- // app.config.ts - Register widgets on startup
74
- export const appConfig: ApplicationConfig = {
75
- providers: [
76
- provideBrowserGlobalErrorListeners(),
77
- provideZoneChangeDetection({ eventCoalescing: true }),
78
- provideRouter(routes),
79
- provideHttpClient(),
80
- provideEnvironmentInitializer(() => {
81
- const dashboardService = inject(DashboardService);
82
- dashboardService.registerWidgetType(ArrowWidgetComponent);
83
- dashboardService.registerWidgetType(LabelWidgetComponent);
84
- dashboardService.registerWidgetType(ClockWidgetComponent);
85
- dashboardService.registerWidgetType(RadialGaugeWidgetComponent);
86
- dashboardService.registerWidgetType(RealtimeGaugeWidgetComponent);
87
- dashboardService.registerWidgetType(SparklineWidgetComponent);
88
- dashboardService.registerWidgetType(SparkbarWidgetComponent);
89
- }),
90
- ],
91
- };
92
- ```
93
-
94
- ### Using RadialGaugeComponent Standalone
95
-
96
- ```typescript
97
- import { Component } from "@angular/core";
98
- import { RadialGaugeComponent } from "@dragonworks/ngx-dashboard-widgets";
99
-
100
- @Component({
101
- selector: "app-metrics",
102
- standalone: true,
103
- imports: [RadialGaugeComponent],
104
- template: ` <ngx-dashboard-radial-gauge [value]="cpuUsage" [minValue]="0" [maxValue]="100" [label]="'CPU Usage'" [unit]="'%'" [showValueLabel]="true"> </ngx-dashboard-radial-gauge> `,
105
- })
106
- export class MetricsComponent {
107
- cpuUsage = 75;
108
- }
109
- ```
110
-
111
- ### Using ResponsiveText Directive
112
-
113
- ```typescript
114
- import { Component } from "@angular/core";
115
- import { ResponsiveTextDirective } from "@dragonworks/ngx-dashboard-widgets";
116
-
117
- @Component({
118
- selector: "app-display",
119
- standalone: true,
120
- imports: [ResponsiveTextDirective],
121
- template: `
122
- <div class="container">
123
- <span ngxDashboardResponsiveText [minFontSize]="12" [maxFontSize]="48"> Responsive Text </span>
124
- </div>
125
- `,
126
- })
127
- export class DisplayComponent {}
128
- ```
129
-
130
- ## Creating Custom Widgets
131
-
132
- ```typescript
133
- import { Component, signal } from "@angular/core";
134
- import { Widget, WidgetMetadata } from "@dragonworks/ngx-dashboard";
135
-
136
- interface MyWidgetState {
137
- text: string;
138
- color: string;
139
- }
140
-
141
- @Component({
142
- selector: "my-custom-widget",
143
- standalone: true,
144
- template: `
145
- <div [style.color]="state().color">
146
- {{ state().text }}
147
- </div>
148
- `,
149
- styleUrl: "./my-custom-widget.component.scss",
150
- })
151
- export class MyCustomWidgetComponent implements Widget {
152
- static readonly metadata: WidgetMetadata = {
153
- widgetTypeid: "@myapp/my-custom-widget",
154
- name: "My Custom Widget",
155
- description: "A custom widget example",
156
- svgIcon: "<svg>...</svg>", // Your SVG icon
157
- };
158
-
159
- state = signal<MyWidgetState>({
160
- text: "Hello World",
161
- color: "var(--mat-sys-primary)",
162
- });
163
-
164
- // Optional: Implement widget state methods
165
- dashboardGetState(): MyWidgetState {
166
- return this.state();
167
- }
168
-
169
- dashboardSetState(state?: unknown): void {
170
- if (state) {
171
- this.state.set(state as MyWidgetState);
172
- }
173
- }
174
-
175
- dashboardEditState(): void {
176
- // Open settings dialog
177
- }
178
- }
179
- ```
180
-
181
- ## Design Patterns
182
-
183
- - **Settings Dialogs**: Each widget includes MD3-compliant configuration dialogs
184
- - **Responsive Sizing**: All widgets adapt to container dimensions
185
- - **State Management**: Signal-based state with lifecycle handling
186
- - **SVG Rendering**: Vector graphics with currentColor support
187
-
188
- ## Documentation
189
-
190
- See the [main repository](https://github.com/TobyBackstrom/ngx-dashboard) for complete documentation, examples, and demo application.
191
-
192
- ## License
193
-
194
- MIT
1
+ # @dragonworks/ngx-dashboard-widgets
2
+
3
+ Example widget collection for ngx-dashboard with Material Design 3 compliance and advanced features.
4
+ You can use these widgets as inspiration or as a base for your own implementations.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @dragonworks/ngx-dashboard-widgets @dragonworks/ngx-dashboard
10
+ ```
11
+
12
+ ## Requirements
13
+
14
+ - Angular 20.2.0+
15
+ - @dragonworks/ngx-dashboard 20.0.0+
16
+
17
+ ## Included Example Widgets
18
+
19
+ ### ArrowWidget
20
+
21
+ - **Directional indicators** with 360° rotation control
22
+ - **Configurable appearance**: Size, color, rotation angle
23
+ - **Material Design icons** with currentColor theme support
24
+ - **Settings dialog** for interactive configuration
25
+
26
+ ### LabelWidget
27
+
28
+ - **Text display** with rich formatting options
29
+ - **Responsive sizing** with alignment controls
30
+ - **Background customization** with theme-aware colors
31
+ - **Font size controls** with min/max constraints
32
+
33
+ ### ClockWidget
34
+
35
+ - **Dual-mode display**: Analog and digital formats
36
+ - **Real-time updates** with automatic timer management
37
+ - **Configurable formats**: 12h/24h time, seconds display
38
+ - **Component composition**: Separate analog/digital components
39
+
40
+ ### RadialGaugeWidget
41
+
42
+ - **Semi-circular gauge** for value visualization
43
+ - **Responsive text rendering**: SVG-native with BBox scaling
44
+ - **Theme integration** with MD3 color tokens
45
+ - **Performance optimized** with signal-based updates
46
+
47
+ ## Components & Utilities
48
+
49
+ ### RadialGaugeComponent
50
+
51
+ Standalone SVG gauge component:
52
+
53
+ - **Dynamic sizing** with ResizeObserver integration
54
+ - **Mathematical positioning** using computed transforms
55
+ - **Reference text system** for consistent measurements
56
+ - **Configurable display**: Value labels, legends, colors
57
+ - **Accessibility features** with ARIA attributes
58
+
59
+ ### ResponsiveTextDirective
60
+
61
+ Text sizing directive:
62
+
63
+ - **Automatic font scaling** to fit container
64
+ - **Performance optimized** with canvas measurement
65
+ - **Developer-friendly API**: minFontSize/maxFontSize inputs
66
+ - **Ellipsis-free design** for clean appearance
67
+
68
+ ## Usage
69
+
70
+ ### Basic Widget Registration
71
+
72
+ ```typescript
73
+ // app.config.ts - Register widgets on startup
74
+ export const appConfig: ApplicationConfig = {
75
+ providers: [
76
+ provideBrowserGlobalErrorListeners(),
77
+ provideZoneChangeDetection({ eventCoalescing: true }),
78
+ provideRouter(routes),
79
+ provideHttpClient(),
80
+ provideEnvironmentInitializer(() => {
81
+ const dashboardService = inject(DashboardService);
82
+ dashboardService.registerWidgetType(ArrowWidgetComponent);
83
+ dashboardService.registerWidgetType(LabelWidgetComponent);
84
+ dashboardService.registerWidgetType(ClockWidgetComponent);
85
+ dashboardService.registerWidgetType(RadialGaugeWidgetComponent);
86
+ dashboardService.registerWidgetType(RealtimeGaugeWidgetComponent);
87
+ dashboardService.registerWidgetType(SparklineWidgetComponent);
88
+ dashboardService.registerWidgetType(SparkbarWidgetComponent);
89
+ }),
90
+ ],
91
+ };
92
+ ```
93
+
94
+ ### Using RadialGaugeComponent Standalone
95
+
96
+ ```typescript
97
+ import { Component } from "@angular/core";
98
+ import { RadialGaugeComponent } from "@dragonworks/ngx-dashboard-widgets";
99
+
100
+ @Component({
101
+ selector: "app-metrics",
102
+ standalone: true,
103
+ imports: [RadialGaugeComponent],
104
+ template: ` <ngx-dashboard-radial-gauge [value]="cpuUsage" [minValue]="0" [maxValue]="100" [label]="'CPU Usage'" [unit]="'%'" [showValueLabel]="true"> </ngx-dashboard-radial-gauge> `,
105
+ })
106
+ export class MetricsComponent {
107
+ cpuUsage = 75;
108
+ }
109
+ ```
110
+
111
+ ### Using ResponsiveText Directive
112
+
113
+ ```typescript
114
+ import { Component } from "@angular/core";
115
+ import { ResponsiveTextDirective } from "@dragonworks/ngx-dashboard-widgets";
116
+
117
+ @Component({
118
+ selector: "app-display",
119
+ standalone: true,
120
+ imports: [ResponsiveTextDirective],
121
+ template: `
122
+ <div class="container">
123
+ <span ngxDashboardResponsiveText [minFontSize]="12" [maxFontSize]="48"> Responsive Text </span>
124
+ </div>
125
+ `,
126
+ })
127
+ export class DisplayComponent {}
128
+ ```
129
+
130
+ ## Creating Custom Widgets
131
+
132
+ ```typescript
133
+ import { Component, signal } from "@angular/core";
134
+ import { Widget, WidgetMetadata } from "@dragonworks/ngx-dashboard";
135
+
136
+ interface MyWidgetState {
137
+ text: string;
138
+ color: string;
139
+ }
140
+
141
+ @Component({
142
+ selector: "my-custom-widget",
143
+ standalone: true,
144
+ template: `
145
+ <div [style.color]="state().color">
146
+ {{ state().text }}
147
+ </div>
148
+ `,
149
+ styleUrl: "./my-custom-widget.component.scss",
150
+ })
151
+ export class MyCustomWidgetComponent implements Widget {
152
+ static readonly metadata: WidgetMetadata = {
153
+ widgetTypeid: "@myapp/my-custom-widget",
154
+ name: "My Custom Widget",
155
+ description: "A custom widget example",
156
+ svgIcon: "<svg>...</svg>", // Your SVG icon
157
+ };
158
+
159
+ state = signal<MyWidgetState>({
160
+ text: "Hello World",
161
+ color: "var(--mat-sys-primary)",
162
+ });
163
+
164
+ // Optional: Implement widget state methods
165
+ dashboardGetState(): MyWidgetState {
166
+ return this.state();
167
+ }
168
+
169
+ dashboardSetState(state?: unknown): void {
170
+ if (state) {
171
+ this.state.set(state as MyWidgetState);
172
+ }
173
+ }
174
+
175
+ dashboardEditState(): void {
176
+ // Open settings dialog
177
+ }
178
+ }
179
+ ```
180
+
181
+ ## Design Patterns
182
+
183
+ - **Settings Dialogs**: Each widget includes MD3-compliant configuration dialogs
184
+ - **Responsive Sizing**: All widgets adapt to container dimensions
185
+ - **State Management**: Signal-based state with lifecycle handling
186
+ - **SVG Rendering**: Vector graphics with currentColor support
187
+
188
+ ## Documentation
189
+
190
+ See the [main repository](https://github.com/TobyBackstrom/ngx-dashboard) for complete documentation, examples, and demo application.
191
+
192
+ ## License
193
+
194
+ MIT