@@ -3,17 +3,17 @@ import styled from 'styled-components';
3
3
4
4
import { ReadyState } from '../../context/websocket-client/use-ws-ready-state' ;
5
5
6
- const Button = styled . button ( {
6
+ const Button = styled . button < { warning ?: boolean } > ( ( { warning } ) => ( {
7
7
paddingRight : 'var(--padding-md)' ,
8
8
paddingLeft : 'var(--padding-md)' ,
9
9
textAlign : 'center' ,
10
- background : 'var(--color-surprise)' ,
10
+ background : warning ? 'var(--color-danger)' : 'var(--color-surprise)' ,
11
11
color : 'var(--color-font-surprise)' ,
12
12
flex : '0 0 100px' ,
13
13
':hover' : {
14
14
filter : 'brightness(0.8)' ,
15
15
} ,
16
- } ) ;
16
+ } ) ) ;
17
17
18
18
interface ActionButtonProps {
19
19
requestId : string ;
@@ -38,11 +38,12 @@ const ActionButton: FC<ActionButtonProps> = ({ requestId, readyState }) => {
38
38
className = "urlbar__send-btn"
39
39
name = "websocketActionCloseBtn"
40
40
type = "button"
41
+ warning
41
42
onClick = { ( ) => {
42
43
window . main . webSocketConnection . close ( { requestId } ) ;
43
44
} }
44
45
>
45
- Close
46
+ Disconnect
46
47
</ Button >
47
48
) ;
48
49
} ;
@@ -72,20 +73,40 @@ const WebSocketIcon = styled.span({
72
73
color : 'var(--color-notice)' ,
73
74
display : 'flex' ,
74
75
alignItems : 'center' ,
75
- paddingRight : 'var(--padding-md)' ,
76
76
paddingLeft : 'var(--padding-md)' ,
77
77
} ) ;
78
78
79
+ const ConnectionStatus = styled . span ( {
80
+ color : 'var(--color-success)' ,
81
+ display : 'flex' ,
82
+ alignItems : 'center' ,
83
+ paddingLeft : 'var(--padding-md)' ,
84
+ } ) ;
85
+ const ConnectionCircle = styled . span ( {
86
+ backgroundColor : 'var(--color-success)' ,
87
+ marginRight : 'var(--padding-sm)' ,
88
+ width : 10 ,
89
+ height : 10 ,
90
+ borderRadius : '50%' ,
91
+ } ) ;
92
+
79
93
export const WebSocketActionBar : FC < ActionBarProps > = ( { requestId, workspaceId, defaultValue, onChange, readyState } ) => {
94
+ const isOpen = readyState === ReadyState . OPEN ;
80
95
const handleSubmit = ( event : FormEvent < HTMLFormElement > ) => {
81
96
event . preventDefault ( ) ;
82
97
window . main . webSocketConnection . create ( { requestId, workspaceId } ) ;
83
98
} ;
84
99
85
100
return (
86
101
< >
87
- < WebSocketIcon > WS</ WebSocketIcon >
88
- < Form aria-disabled = { readyState === ReadyState . OPEN } id = "websocketUrlForm" onSubmit = { handleSubmit } >
102
+ { ! isOpen && < WebSocketIcon > WS</ WebSocketIcon > }
103
+ { isOpen && (
104
+ < ConnectionStatus >
105
+ < ConnectionCircle />
106
+ CONNECTED
107
+ </ ConnectionStatus >
108
+ ) }
109
+ < Form aria-disabled = { isOpen } id = "websocketUrlForm" onSubmit = { handleSubmit } >
89
110
< Input
90
111
name = "websocketUrlInput"
91
112
disabled = { readyState === ReadyState . OPEN }
0 commit comments