@@ -4,6 +4,8 @@ import cn from "classnames";
44import { ReactComponent as SpinnerIndicator } from "../../assets/icons/spinner-indicator.svg" ;
55import { boundMethod } from "autobind-decorator" ;
66
7+ import { ReactComponent as RotateIconSvg } from "../../assets/icons/line/rotate.svg" ;
8+
79interface PositionalIconProps {
810 children ?: React . ReactNode ;
911 className ?: string ;
@@ -14,7 +16,11 @@ interface PositionalIconProps {
1416export class FrontIcon extends React . Component < PositionalIconProps > {
1517 render ( ) {
1618 return (
17- < div ref = { this . props . divRef } className = { cn ( "front-icon" , "positional-icon" , this . props . className ) } >
19+ < div
20+ ref = { this . props . divRef }
21+ className = { cn ( "front-icon" , "positional-icon" , this . props . className ) }
22+ onClick = { this . props . onClick }
23+ >
1824 < div className = "positional-icon-inner" > { this . props . children } </ div >
1925 </ div >
2026 ) ;
@@ -49,14 +55,11 @@ export class ActionsIcon extends React.Component<ActionsIconProps> {
4955 }
5056}
5157
52- interface StatusIndicatorProps {
53- level : StatusIndicatorLevel ;
54- className ?: string ;
55- runningCommands ?: boolean ;
56- }
57-
58- export class StatusIndicator extends React . Component < StatusIndicatorProps > {
59- iconRef : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
58+ class SyncSpin extends React . Component < {
59+ classRef ?: React . RefObject < HTMLDivElement > ;
60+ children ?: React . ReactNode ;
61+ shouldSync ?: boolean ;
62+ } > {
6063 listenerAdded : boolean = false ;
6164
6265 componentDidMount ( ) {
@@ -68,8 +71,9 @@ export class StatusIndicator extends React.Component<StatusIndicatorProps> {
6871 }
6972
7073 componentWillUnmount ( ) : void {
71- if ( this . iconRef . current != null && this . listenerAdded ) {
72- const elem = this . iconRef . current ;
74+ const classRef = this . props . classRef ;
75+ if ( classRef . current != null && this . listenerAdded ) {
76+ const elem = classRef . current ;
7377 const svgElem = elem . querySelector ( "svg" ) ;
7478 if ( svgElem != null ) {
7579 svgElem . removeEventListener ( "animationstart" , this . handleAnimationStart ) ;
@@ -79,10 +83,11 @@ export class StatusIndicator extends React.Component<StatusIndicatorProps> {
7983
8084 @boundMethod
8185 handleAnimationStart ( e : AnimationEvent ) {
82- if ( this . iconRef . current == null ) {
86+ const classRef = this . props . classRef ;
87+ if ( classRef . current == null ) {
8388 return ;
8489 }
85- const svgElem = this . iconRef . current . querySelector ( "svg" ) ;
90+ const svgElem = classRef . current . querySelector ( "svg" ) ;
8691 if ( svgElem == null ) {
8792 return ;
8893 }
@@ -94,13 +99,12 @@ export class StatusIndicator extends React.Component<StatusIndicatorProps> {
9499 }
95100
96101 syncSpinner ( ) {
97- if ( ! this . props . runningCommands ) {
98- return ;
99- }
100- if ( this . iconRef . current == null ) {
102+ const { classRef, shouldSync } = this . props ;
103+ const shouldSyncVal = shouldSync ?? true ;
104+ if ( ! shouldSyncVal || classRef . current == null ) {
101105 return ;
102106 }
103- const elem = this . iconRef . current ;
107+ const elem = classRef . current ;
104108 const svgElem = elem . querySelector ( "svg" ) ;
105109 if ( svgElem == null ) {
106110 return ;
@@ -116,6 +120,20 @@ export class StatusIndicator extends React.Component<StatusIndicatorProps> {
116120 animArr [ 0 ] . startTime = 0 ;
117121 }
118122
123+ render ( ) {
124+ return this . props . children ;
125+ }
126+ }
127+
128+ interface StatusIndicatorProps {
129+ level : StatusIndicatorLevel ;
130+ className ?: string ;
131+ runningCommands ?: boolean ;
132+ }
133+
134+ export class StatusIndicator extends React . Component < StatusIndicatorProps > {
135+ iconRef : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
136+
119137 render ( ) {
120138 const { level, className, runningCommands } = this . props ;
121139 let statusIndicator = null ;
@@ -138,6 +156,24 @@ export class StatusIndicator extends React.Component<StatusIndicatorProps> {
138156 </ CenteredIcon >
139157 ) ;
140158 }
141- return statusIndicator ;
159+ return (
160+ < SyncSpin classRef = { this . iconRef } shouldSync = { runningCommands } >
161+ { statusIndicator }
162+ </ SyncSpin >
163+ ) ;
164+ }
165+ }
166+
167+ export class RotateIcon extends React . Component < {
168+ className ?: string ;
169+ onClick ?: React . MouseEventHandler < HTMLDivElement > ;
170+ } > {
171+ iconRef : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
172+ render ( ) {
173+ return (
174+ < SyncSpin classRef = { this . iconRef } >
175+ < RotateIconSvg className = { this . props . className ?? "" } />
176+ </ SyncSpin >
177+ ) ;
142178 }
143179}
0 commit comments