@@ -12,6 +12,7 @@ type Props = {
12
12
steps ?: Step [ ] | Node [ ] ;
13
13
onClickNode ?: onClickNode ;
14
14
showIcons ?: boolean ;
15
+ animate ?: boolean ;
15
16
} ;
16
17
17
18
declare global {
@@ -26,6 +27,7 @@ const Graph: React.FC<Props> = ({
26
27
type = 'status' ,
27
28
onClickNode,
28
29
showIcons = true ,
30
+ animate = true ,
29
31
} ) => {
30
32
// Calculate width based on flowchart type and graph breadth
31
33
const width = React . useMemo ( ( ) => {
@@ -58,11 +60,11 @@ const Graph: React.FC<Props> = ({
58
60
} ;
59
61
60
62
// Define FontAwesome icons for each status with colors and animations
61
- const statusIcons = {
63
+ const statusIcons : { [ key : number ] : string } = {
62
64
[ NodeStatus . None ] :
63
- "<i class='fas fa-circle-notch fa-spin ' style='color: #3b82f6; animation: spin 2s linear infinite'></i>" ,
65
+ "<i class='fas fa-circle-notch' style='color: #3b82f6; animation: spin 2s linear infinite; '></i>" ,
64
66
[ NodeStatus . Running ] :
65
- "<i class='fas fa-spinner fa-spin ' style='color: #22c55e; animation: spin 1s linear infinite'></i>" ,
67
+ "<i class='fas fa-spinner' style='color: #22c55e; animation: spin 1s linear infinite; '></i>" ,
66
68
[ NodeStatus . Error ] :
67
69
"<i class='fas fa-exclamation-circle' style='color: #ef4444'></i>" ,
68
70
[ NodeStatus . Cancel ] : "<i class='fas fa-ban' style='color: #ec4899'></i>" ,
@@ -71,6 +73,12 @@ const Graph: React.FC<Props> = ({
71
73
[ NodeStatus . Skipped ] :
72
74
"<i class='fas fa-forward' style='color: #64748b'></i>" ,
73
75
} ;
76
+ if ( ! animate ) {
77
+ // Remove animations if disabled
78
+ Object . keys ( statusIcons ) . forEach ( ( key : string ) => {
79
+ statusIcons [ + key ] = statusIcons [ + key ] . replace ( / a n i m a t i o n : .* ?; / g, '' ) ;
80
+ } ) ;
81
+ }
74
82
75
83
const graph = React . useMemo ( ( ) => {
76
84
if ( ! steps ) return '' ;
@@ -138,12 +146,24 @@ const Graph: React.FC<Props> = ({
138
146
}
139
147
140
148
// Define node styles for different states with refined colors
141
- dat . push ( 'classDef none fill:#f0f9ff,stroke:#93c5fd,color:#1e40af,stroke-width:1.2px,white-space:nowrap' ) ;
142
- dat . push ( 'classDef running fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap' ) ;
143
- dat . push ( 'classDef error fill:#fef2f2,stroke:#fca5a5,color:#aa1010,stroke-width:1.2px,white-space:nowrap' ) ;
144
- dat . push ( 'classDef cancel fill:#fdf2f8,stroke:#f9a8d4,color:#9d174d,stroke-width:1.2px,white-space:nowrap' ) ;
145
- dat . push ( 'classDef done fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap' ) ;
146
- dat . push ( 'classDef skipped fill:#f8fafc,stroke:#cbd5e1,color:#475569,stroke-width:1.2px,white-space:nowrap' ) ;
149
+ dat . push (
150
+ 'classDef none fill:#f0f9ff,stroke:#93c5fd,color:#1e40af,stroke-width:1.2px,white-space:nowrap'
151
+ ) ;
152
+ dat . push (
153
+ 'classDef running fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap'
154
+ ) ;
155
+ dat . push (
156
+ 'classDef error fill:#fef2f2,stroke:#fca5a5,color:#aa1010,stroke-width:1.2px,white-space:nowrap'
157
+ ) ;
158
+ dat . push (
159
+ 'classDef cancel fill:#fdf2f8,stroke:#f9a8d4,color:#9d174d,stroke-width:1.2px,white-space:nowrap'
160
+ ) ;
161
+ dat . push (
162
+ 'classDef done fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap'
163
+ ) ;
164
+ dat . push (
165
+ 'classDef skipped fill:#f8fafc,stroke:#cbd5e1,color:#475569,stroke-width:1.2px,white-space:nowrap'
166
+ ) ;
147
167
148
168
// Add custom link styles
149
169
dat . push ( ...linkStyles ) ;
@@ -220,4 +240,4 @@ const graphStatusMap = {
220
240
[ NodeStatus . Cancel ] : ':::cancel' ,
221
241
[ NodeStatus . Success ] : ':::done' ,
222
242
[ NodeStatus . Skipped ] : ':::skipped' ,
223
- } ;
243
+ } ;
0 commit comments