您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LobbyParticipantList.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @flow
  2. import { makeStyles } from '@material-ui/core/styles';
  3. import React, { useCallback } from 'react';
  4. import { useTranslation } from 'react-i18next';
  5. import { useSelector, useDispatch } from 'react-redux';
  6. import { withPixelLineHeight } from '../../base/styles/functions.web';
  7. import { admitMultiple } from '../../lobby/actions.web';
  8. import { getLobbyState } from '../../lobby/functions';
  9. import { LobbyParticipantItem } from './LobbyParticipantItem';
  10. const useStyles = makeStyles(theme => {
  11. return {
  12. headingContainer: {
  13. alignItems: 'center',
  14. display: 'flex',
  15. justifyContent: 'space-between'
  16. },
  17. heading: {
  18. ...withPixelLineHeight(theme.typography.heading7),
  19. color: theme.palette.text02
  20. },
  21. link: {
  22. ...withPixelLineHeight(theme.typography.labelBold),
  23. color: theme.palette.link01,
  24. cursor: 'pointer'
  25. }
  26. };
  27. });
  28. export const LobbyParticipantList = () => {
  29. const {
  30. lobbyEnabled,
  31. knockingParticipants: participants
  32. } = useSelector(getLobbyState);
  33. const { t } = useTranslation();
  34. const classes = useStyles();
  35. const dispatch = useDispatch();
  36. const admitAll = useCallback(() => {
  37. dispatch(admitMultiple(participants));
  38. }, [ dispatch, participants ]);
  39. if (!lobbyEnabled || !participants.length) {
  40. return null;
  41. }
  42. return (
  43. <>
  44. <div className = { classes.headingContainer }>
  45. <div className = { classes.heading }>
  46. {t('participantsPane.headings.lobby', { count: participants.length })}
  47. </div>
  48. <div
  49. className = { classes.link }
  50. onClick = { admitAll }>{t('lobby.admitAll')}</div>
  51. </div>
  52. <div>
  53. {participants.map(p => (
  54. <LobbyParticipantItem
  55. key = { p.id }
  56. participant = { p } />)
  57. )}
  58. </div>
  59. </>
  60. );
  61. };