File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { ANIMATION_STATES } from '@/data'
2
+ import type { ValueOf } from '@/utils/types'
3
+
4
+ type AnimationState = ValueOf < typeof ANIMATION_STATES >
5
+
6
+ const animationStateTextMap : Record < AnimationState , string > = {
7
+ [ ANIMATION_STATES . IDLE ] : 'Ready' ,
8
+ [ ANIMATION_STATES . HANDSHAKE ] : 'Establishing Connection' ,
9
+ [ ANIMATION_STATES . DATA_TRANSFER ] : 'Transferring Data' ,
10
+ [ ANIMATION_STATES . TERMINATION ] : 'Terminating Connection' ,
11
+ [ ANIMATION_STATES . COMPLETE ] : 'Connection Closed' ,
12
+ }
13
+
14
+ interface Props {
15
+ animationState : AnimationState
16
+ }
17
+
18
+ function ConnectionStatus ( props : Props ) {
19
+ const pulseClassName =
20
+ props . animationState === ANIMATION_STATES . IDLE
21
+ ? 'bg-yellow-500'
22
+ : props . animationState === ANIMATION_STATES . COMPLETE
23
+ ? 'bg-green-500'
24
+ : 'bg-blue-500 animate-pulse'
25
+
26
+ return (
27
+ < div className = "absolute bottom-4 left-1/2 transform -translate-x-1/2 bg-background/80 backdrop-blur-sm p-2 rounded-lg border shadow-sm" >
28
+ < div className = "flex items-center space-x-2" >
29
+ < div className = { `w-3 h-3 rounded-full ${ pulseClassName } ` } />
30
+ < span className = "text-sm font-medium" >
31
+ { animationStateTextMap [ props . animationState ] }
32
+ </ span >
33
+ </ div >
34
+ </ div >
35
+ )
36
+ }
37
+
38
+ export default ConnectionStatus
You can’t perform that action at this time.
0 commit comments