@@ -8,7 +8,7 @@ import styles from "./VideoControls.module.css";
8
8
import { nameInput } from "../../data/roomInputs" ;
9
9
import VideoControlsButton from "../VideoControlsButton/VideoControlsButton" ;
10
10
11
- const VideoControls = ( { stream, hasWebcam, displayName, gainStreams, handleMuted, handleFullScreen, isFullScreen} ) => {
11
+ const VideoControls = ( { stream, hasWebcam, displayName, gainStreams, handleMuted, handleFullScreen, isFullScreen, videoWidth } ) => {
12
12
const history = useHistory ( ) ;
13
13
const { setDisplayName, stream : myStream , setHasWebcam, shareScreen, setShareScreen} = useContext ( SocketContext ) ;
14
14
const { values, setValues, handleChange, clearInput} = useForm ( { volume : gainStreams ?. isHost ? 0 : 1 , username : displayName } ) ;
@@ -136,64 +136,82 @@ const VideoControls = ({stream, hasWebcam, displayName, gainStreams, handleMuted
136
136
} ;
137
137
138
138
const volumeTitle = Math . floor ( values . volume * 100 ) ;
139
+ let controlsSize = "1.2rem" ;
140
+ let disconnectWidth = "8%" ;
141
+ if ( videoWidth <= 600 ) controlsSize = "1rem" ;
142
+ if ( videoWidth <= 500 ) {
143
+ controlsSize = "0.95rem" ;
144
+ disconnectWidth = "10%" ;
145
+ }
146
+ if ( videoWidth <= 400 ) controlsSize = "0.9rem" ;
139
147
140
148
return (
141
- < div className = { styles . video__tray } onDoubleClick = { handleDoubleClick } >
142
- < EditWrapper
143
- inputs = { formInputs }
144
- handleChange = { handleChange }
145
- clearInput = { clearInput }
146
- handleSubmit = { handleSubmit }
147
- handleClick = { handleNameClick }
148
- isEditing = { isEditing }
149
- hidden = { true }
150
- formStyles = { isEditing ? "formDisplayName--active" : "formDisplayName" }
151
- >
152
- < button
153
- type = "button"
154
- className = { `${ styles . displayname } ${ isMyStream ? "" : styles [ "displayName--disabled" ] } ` }
155
- onClick = { handleNameClick }
156
- disabled = { ! isMyStream }
149
+ < div className = { styles . video__tray }
150
+ style = { {
151
+ width : `${ videoWidth <= 450 ? "100%" : "" } ` ,
152
+ "--controls__size" : `${ controlsSize } ` ,
153
+ "--disconnect__width" : `${ disconnectWidth } `
154
+ } }
155
+ onDoubleClick = { handleDoubleClick }
156
+ >
157
+ < div className = { `${ isEditing ? styles [ "formDisplayName--active" ] : styles . formDisplayName } ` } >
158
+ < EditWrapper
159
+ inputs = { formInputs }
160
+ handleChange = { handleChange }
161
+ clearInput = { clearInput }
162
+ handleSubmit = { handleSubmit }
163
+ handleClick = { handleNameClick }
164
+ isEditing = { isEditing }
165
+ hidden = { true }
157
166
>
158
- { displayName || "Silly Goose" }
159
- </ button >
160
- </ EditWrapper >
167
+ < button
168
+ type = "button"
169
+ className = { `${ styles . displayname } ${ isMyStream ? "" : styles [ "displayName--disabled" ] } ` }
170
+ onClick = { handleNameClick }
171
+ disabled = { ! isMyStream }
172
+ >
173
+ { displayName || "Silly Goose" }
174
+ </ button >
175
+ </ EditWrapper >
176
+ </ div >
161
177
< div className = { `${ styles . controls__tray } ${ isFocused ? styles [ "controls__tray--active" ] : "" } ` } >
162
178
{ isMyStream
163
179
? < >
180
+ < div className = { styles . disconnect__container } >
164
181
< VideoControlsButton
165
182
type = "button"
166
- buttonClass = " disconnect__button"
183
+ buttonClass = { ` ${ styles . disconnect__button } ${ styles . disconnect__button__padding } ` }
167
184
title = "Disconnect from call"
168
- iconClass = { `fas fa-phone-slash ${ styles . disconnect__icon } ` }
185
+ iconClass = { `fas fa-phone-slash ${ styles . controls__icon } ${ styles . disconnect__icon } ` }
169
186
handleClick = { handleDisconnectClick }
170
187
handleFocus = { handleControlsFocus }
171
188
/>
189
+ </ div >
172
190
< VideoControlsButton
173
191
buttonClass = "video__button"
174
192
title = { playVideo ? "Stop Video" : "Show Video" }
175
- iconClass = { `fas ${ ! playVideo ? `fa-video-slash ${ styles [ "button--stop" ] } ` : `fa-video` } ` }
193
+ iconClass = { `fas ${ styles . controls__icon } ${ ! playVideo ? `fa-video-slash ${ styles [ "button--stop" ] } ` : `fa-video` } ` }
176
194
handleClick = { handleVideoClick }
177
195
handleFocus = { handleControlsFocus }
178
196
/>
179
197
< VideoControlsButton
180
198
buttonClass = "mic__button"
181
199
title = { playMic ? "Mute" : "Unmute" }
182
- iconClass = { `fas ${ ! playMic ? `fa-microphone-slash ${ styles [ "button--stop" ] } ` : `fa-microphone` } ` }
200
+ iconClass = { `fas ${ styles . controls__icon } ${ ! playMic ? `fa-microphone-slash ${ styles [ "button--stop" ] } ` : `fa-microphone` } ` }
183
201
handleClick = { handleMicClick }
184
202
handleFocus = { handleControlsFocus }
185
203
/>
186
204
< VideoControlsButton
187
205
buttonClass = "screen__button"
188
206
title = { shareScreen ? "Stop Screen Share" : "Share Screen" }
189
- iconClass = { `fas fa-desktop ${ ! shareScreen ? "" : styles [ "button--stop" ] } ` }
207
+ iconClass = { `fas fa-desktop ${ styles . controls__icon } ${ ! shareScreen ? "" : styles [ "button--stop" ] } ` }
190
208
handleClick = { handleScreenClick }
191
209
handleFocus = { handleControlsFocus }
192
210
/>
193
211
</ >
194
212
: < div className = { `${ styles . volume__controls } ${ isVolumeFocused ? styles [ `volume__controls--focus` ] : "" } ` } >
195
213
< button type = "button" className = { styles . volume__button } onClick = { handleVolumeClick } onFocus = { handleControlsFocus } onBlur = { handleControlsFocus } >
196
- < i className = { `fas ${ ! isMuted ? `fa-volume-up` : `fa-volume-mute` } ${ styles . volume } ` } > </ i >
214
+ < i className = { `fas ${ styles . controls__icon } ${ ! isMuted ? `fa-volume-up` : `fa-volume-mute` } ${ styles . volume } ` } > </ i >
197
215
</ button >
198
216
< input
199
217
className = { styles . slider }
@@ -213,7 +231,7 @@ const VideoControls = ({stream, hasWebcam, displayName, gainStreams, handleMuted
213
231
< VideoControlsButton
214
232
buttonClass = "fullscreen__button"
215
233
title = { isFullScreen ? "Exit Fullscreen" : "Fullscreen" }
216
- iconClass = { `fas ${ ! isFullScreen ? "fa-expand" : "fa-compress" } ` }
234
+ iconClass = { `fas ${ styles . controls__icon } ${ ! isFullScreen ? "fa-expand" : "fa-compress" } ` }
217
235
handleClick = { handleFullScreen }
218
236
handleFocus = { handleControlsFocus }
219
237
/>
0 commit comments