-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finalize grid mode #699
Finalize grid mode #699
Changes from 7 commits
1442950
35ccd13
a1d4c6e
920ff1e
4c5490e
ab05ffb
fe2738d
2690dc8
0d40256
c29ad7d
0b36cbc
10dcd10
b1a0e71
a365f34
e5f8b1f
55f7c9f
4e3fbaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import React from 'react'; | |
import ArrowBack from '@material-ui/icons/ArrowBack'; | ||
import ArrowForward from '@material-ui/icons/ArrowForward'; | ||
import clsx from 'clsx'; | ||
import { GRID_MODE_ASPECT_RATIO, GRID_MODE_MARGIN } from '../../constants'; | ||
import { GRID_VIEW_ASPECT_RATIO, GRID_VIEW_MARGIN } from '../../constants'; | ||
import { IconButton, makeStyles } from '@material-ui/core'; | ||
import { Pagination } from '@material-ui/lab'; | ||
import Participant from '../Participant/Participant'; | ||
|
@@ -11,11 +11,13 @@ import useVideoContext from '../../hooks/useVideoContext/useVideoContext'; | |
import { usePagination } from '../../hooks/usePagination/usePagination'; | ||
import useDominantSpeaker from '../../hooks/useDominantSpeaker/useDominantSpeaker'; | ||
import useGridParticipants from '../../hooks/useGridParticipants/useGridParticipants'; | ||
import { useAppState } from '../../state'; | ||
|
||
const CONTAINER_GUTTER = '50px'; | ||
|
||
const useStyles = makeStyles({ | ||
container: { | ||
background: '#121C2D', | ||
position: 'relative', | ||
gridArea: '1 / 1 / 2 / 3', | ||
}, | ||
|
@@ -72,23 +74,28 @@ const useStyles = makeStyles({ | |
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
lastPage: { | ||
alignContent: 'flex-start', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about centered here? In some cases, flex-start makes the participants on the last page higher than all the rest, like this: I think centered participants on the last page might be ideal, but I'm curious what you think? It also has the advantage of getting rid of all the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep sounds good. I really didn't have an opinion here, and I didn't know what was best. So centering it is! |
||
}, | ||
}); | ||
|
||
export function GridView() { | ||
const classes = useStyles(); | ||
const { maxGridParticipants } = useAppState(); | ||
const { room } = useVideoContext(); | ||
const gridParticipants = useGridParticipants(); | ||
const dominantSpeaker = useDominantSpeaker(true); | ||
|
||
const { paginatedParticipants, setCurrentPage, currentPage, totalPages } = usePagination([ | ||
const { paginatedParticipants, setCurrentPage, currentPage, totalPages, isLastPage } = usePagination([ | ||
room!.localParticipant, | ||
...gridParticipants, | ||
]); | ||
|
||
const { participantVideoWidth, containerRef } = useGridLayout(paginatedParticipants.length); | ||
const gridLayoutParticipantCount = currentPage === 1 ? paginatedParticipants.length : maxGridParticipants; | ||
const { participantVideoWidth, containerRef } = useGridLayout(gridLayoutParticipantCount); | ||
|
||
const participantWidth = `${participantVideoWidth}px`; | ||
const participantHeight = `${Math.floor(participantVideoWidth * GRID_MODE_ASPECT_RATIO)}px`; | ||
const participantHeight = `${Math.floor(participantVideoWidth * GRID_VIEW_ASPECT_RATIO)}px`; | ||
|
||
return ( | ||
<div className={classes.container}> | ||
|
@@ -121,11 +128,14 @@ export function GridView() { | |
/> | ||
)} | ||
</div> | ||
<div className={classes.participantContainer} ref={containerRef}> | ||
<div | ||
className={clsx(classes.participantContainer, { [classes.lastPage]: currentPage > 1 && isLastPage })} | ||
ref={containerRef} | ||
> | ||
{paginatedParticipants.map(participant => ( | ||
<div | ||
key={participant.sid} | ||
style={{ width: participantWidth, height: participantHeight, margin: GRID_MODE_MARGIN }} | ||
style={{ width: participantWidth, height: participantHeight, margin: GRID_VIEW_MARGIN }} | ||
> | ||
<Participant | ||
participant={participant} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -36,7 +36,7 @@ export default function Menu(props: { buttonClassName?: string }) { | |||||
const [menuOpen, setMenuOpen] = useState(false); | ||||||
const [settingsOpen, setSettingsOpen] = useState(false); | ||||||
|
||||||
const { isFetching, updateRecordingRules, roomType, setIsGridModeActive, isGridModeActive } = useAppState(); | ||||||
const { isFetching, updateRecordingRules, roomType, setIsGridViewActive, isGridViewActive } = useAppState(); | ||||||
const { setIsChatWindowOpen } = useChatContext(); | ||||||
const isRecording = useIsRecording(); | ||||||
const { room, setIsBackgroundSelectionOpen } = useVideoContext(); | ||||||
|
@@ -137,18 +137,18 @@ export default function Menu(props: { buttonClassName?: string }) { | |||||
|
||||||
<MenuItem | ||||||
onClick={() => { | ||||||
setIsGridModeActive(isGrid => !isGrid); | ||||||
setIsGridViewActive(isGrid => !isGrid); | ||||||
setMenuOpen(false); | ||||||
}} | ||||||
> | ||||||
<IconContainer> | ||||||
{isGridModeActive ? ( | ||||||
{isGridViewActive ? ( | ||||||
<CollaborationViewIcon style={{ fill: '#707578', width: '0.9em' }} /> | ||||||
) : ( | ||||||
<GridViewIcon style={{ fill: '#707578', width: '0.9em' }} /> | ||||||
)} | ||||||
</IconContainer> | ||||||
<Typography variant="body1">{isGridModeActive ? 'Collaboration Mode' : 'Grid Mode'}</Typography> | ||||||
<Typography variant="body1">{isGridViewActive ? 'Collaboration View' : 'Grid View'}</Typography> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</MenuItem> | ||||||
|
||||||
<MenuItem onClick={() => setAboutOpen(true)}> | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import useIsTrackSwitchedOff from '../../hooks/useIsTrackSwitchedOff/useIsTrackS | |
import usePublications from '../../hooks/usePublications/usePublications'; | ||
import useTrack from '../../hooks/useTrack/useTrack'; | ||
import useParticipantIsReconnecting from '../../hooks/useParticipantIsReconnecting/useParticipantIsReconnecting'; | ||
import { GRID_MODE_MARGIN } from '../../constants'; | ||
import { GRID_VIEW_MARGIN } from '../../constants'; | ||
import { useAppState } from '../../state'; | ||
|
||
const borderWidth = 2; | ||
|
@@ -116,7 +116,7 @@ const useStyles = makeStyles((theme: Theme) => | |
bottom: 0, | ||
left: 0, | ||
}, | ||
typeography: { | ||
typography: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙂 |
||
color: 'white', | ||
[theme.breakpoints.down('sm')]: { | ||
fontSize: '0.75rem', | ||
|
@@ -128,11 +128,9 @@ const useStyles = makeStyles((theme: Theme) => | |
cursorPointer: { | ||
cursor: 'pointer', | ||
}, | ||
dominantSpeaker: { | ||
border: `solid ${borderWidth}px #7BEAA5`, | ||
margin: `${GRID_MODE_MARGIN} - borderWidth`, | ||
}, | ||
mobileGridMode: { | ||
gridView: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about adding a border-radius of, say, 6px or 8px? Without the white border in grid view (which I think looks great), the corners feel a touch too sharp. I think we could even have presentation view use the same border-radius of 6 or 8px. Or presentation view could stay at 4px. It'll take some playing with but I think that the grid view corners could be more rounded. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, not sure why I haven't noticed this before, but I think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think that all looks a lot better! |
||
background: '#121C2D', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
border: `${theme.participantBorderWidth}px solid transparent`, | ||
[theme.breakpoints.down('sm')]: { | ||
position: 'relative', | ||
width: '100%', | ||
|
@@ -145,6 +143,10 @@ const useStyles = makeStyles((theme: Theme) => | |
}, | ||
}, | ||
}, | ||
dominantSpeaker: { | ||
border: `solid ${borderWidth}px #7BEAA5`, | ||
margin: `${GRID_VIEW_MARGIN} - borderWidth`, | ||
}, | ||
}) | ||
); | ||
|
||
|
@@ -181,7 +183,7 @@ export default function ParticipantInfo({ | |
const audioTrack = useTrack(audioPublication) as LocalAudioTrack | RemoteAudioTrack | undefined; | ||
const isParticipantReconnecting = useParticipantIsReconnecting(participant); | ||
|
||
const { isGridModeActive } = useAppState(); | ||
const { isGridViewActive } = useAppState(); | ||
|
||
const classes = useStyles(); | ||
|
||
|
@@ -191,7 +193,7 @@ export default function ParticipantInfo({ | |
[classes.hideParticipant]: hideParticipant, | ||
[classes.cursorPointer]: Boolean(onClick), | ||
[classes.dominantSpeaker]: isDominantSpeaker, | ||
[classes.mobileGridMode]: isGridModeActive, | ||
[classes.gridView]: isGridViewActive, | ||
})} | ||
onClick={onClick} | ||
data-cy-participant={participant.identity} | ||
|
@@ -206,7 +208,7 @@ export default function ParticipantInfo({ | |
)} | ||
<span className={classes.identity}> | ||
<AudioLevelIndicator audioTrack={audioTrack} /> | ||
<Typography variant="body1" className={classes.typeography} component="span"> | ||
<Typography variant="body1" className={classes.typography} component="span"> | ||
{participant.identity} | ||
{isLocalParticipant && ' (You)'} | ||
</Typography> | ||
|
@@ -222,7 +224,7 @@ export default function ParticipantInfo({ | |
)} | ||
{isParticipantReconnecting && ( | ||
<div className={classes.reconnectingContainer}> | ||
<Typography variant="body1" className={classes.typeography}> | ||
<Typography variant="body1" className={classes.typography}> | ||
Reconnecting... | ||
</Typography> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in a few spots, so it would probably be good to add to the theme.