feat: improve video layout

This commit is contained in:
Jeremy Kahn 2022-11-15 09:52:00 -06:00
parent 97d5b64fc1
commit f5c0eb3f16
2 changed files with 12 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import { VideoStreamType } from 'models/chat'
import { SelectedPeerStream } from './RoomVideoDisplay' import { SelectedPeerStream } from './RoomVideoDisplay'
interface PeerVideoProps { interface PeerVideoProps {
isSelectedVideo?: boolean
isSelfVideo?: boolean isSelfVideo?: boolean
numberOfVideos: number numberOfVideos: number
onVideoClick?: ( onVideoClick?: (
@ -28,6 +29,7 @@ const nextPerfectSquare = (base: number) => {
} }
export const PeerVideo = ({ export const PeerVideo = ({
isSelectedVideo,
isSelfVideo, isSelfVideo,
numberOfVideos, numberOfVideos,
onVideoClick, onVideoClick,
@ -59,7 +61,7 @@ export const PeerVideo = ({
flexDirection: 'column', flexDirection: 'column',
flexShrink: 1, flexShrink: 1,
justifyContent: 'center', justifyContent: 'center',
margin: '0 0.5em 0.5em 0.5em', mx: 'auto',
overflow: 'auto', overflow: 'auto',
py: 2, py: 2,
...(selectedPeerStream ...(selectedPeerStream
@ -70,6 +72,10 @@ export const PeerVideo = ({
width: `calc(${sizePercent}% - 1em)`, width: `calc(${sizePercent}% - 1em)`,
height: `calc(${sizePercent}% - 1em)`, height: `calc(${sizePercent}% - 1em)`,
}), }),
...(selectedPeerStream &&
!isSelectedVideo && {
width: 'min-content',
}),
}} }}
elevation={10} elevation={10}
> >
@ -90,7 +96,7 @@ export const PeerVideo = ({
}} }}
/> />
<PeerNameDisplay <PeerNameDisplay
sx={{ textAlign: 'center', display: 'block', marginTop: '1em' }} sx={{ textAlign: 'center', display: 'block', marginTop: 1, px: 1 }}
> >
{userId} {userId}
</PeerNameDisplay> </PeerNameDisplay>

View File

@ -120,12 +120,14 @@ export const RoomVideoDisplay = ({ userId }: RoomVideoDisplayProps) => {
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
overflow: 'auto', overflow: 'auto',
padding: 1,
width: '85%', width: '85%',
}} }}
> >
{selectedPeerStream && ( {selectedPeerStream && (
<Box sx={{ height: 'calc(85% - 1em)', mb: 'auto' }}> <Box sx={{ height: '85%' }}>
<PeerVideo <PeerVideo
isSelectedVideo
numberOfVideos={numberOfVideos} numberOfVideos={numberOfVideos}
onVideoClick={handleVideoClick} onVideoClick={handleVideoClick}
userId={userId} userId={userId}
@ -143,6 +145,7 @@ export const RoomVideoDisplay = ({ userId }: RoomVideoDisplayProps) => {
flexDirection: 'row', flexDirection: 'row',
flexGrow: 1, flexGrow: 1,
flexWrap: selectedPeerStream ? 'nowrap' : 'wrap', flexWrap: selectedPeerStream ? 'nowrap' : 'wrap',
justifyContent: 'center',
overflow: 'auto', overflow: 'auto',
width: '100%', width: '100%',
...(selectedPeerStream && { ...(selectedPeerStream && {