-
Notifications
You must be signed in to change notification settings - Fork 736
Ui improvements #16
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
Merged
Merged
Ui improvements #16
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
acb9d29
Make ParticipantStrip scrollable
1e2a141
Display room name when connected to a room
66adae0
create MainParticipant component
aa70f8e
Create MainParticipantInfo component
995f915
Add MainParticipant to room
86a5dbc
Lint
e6e3bc8
Merge branch 'development' into ui-improvements
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import MainParticipantInfo from '../MainParticipantInfo/MainParticipantInfo'; | ||
| import ParticipantTracks from '../ParticipantTracks/ParticipantTracks'; | ||
| import React from 'react'; | ||
| import useMainSpeaker from '../../hooks/useMainSpeaker/useMainSpeaker'; | ||
|
|
||
| export default function MainParticipant() { | ||
| const mainParticipant = useMainSpeaker(); | ||
| return ( | ||
| /* audio is disabled for this participant component because this participant's audio | ||
| is already being rendered in the <ParticipantStrip /> component. */ | ||
| <MainParticipantInfo participant={mainParticipant}> | ||
| <ParticipantTracks participant={mainParticipant} disableAudio /> | ||
| </MainParticipantInfo> | ||
| ); | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/components/MainParticipantInfo/MainParticipantInfo.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import React from 'react'; | ||
| import MainParticipantInfo from './MainParticipantInfo'; | ||
| import { shallow } from 'enzyme'; | ||
| import usePublications from '../../hooks/usePublications/usePublications'; | ||
|
|
||
| jest.mock('../../hooks/useParticipantNetworkQualityLevel/useParticipantNetworkQualityLevel', () => () => 4); | ||
|
|
||
| jest.mock('../../hooks/usePublications/usePublications'); | ||
|
|
||
| const mockUsePublications = usePublications as jest.Mock<any>; | ||
|
|
||
| describe('the MainParticipantInfo component', () => { | ||
| it('should render correctly', () => { | ||
| mockUsePublications.mockImplementation(() => []); | ||
| const wrapper = shallow( | ||
| <MainParticipantInfo participant={{ identity: 'mockIdentity' } as any}>mock children</MainParticipantInfo> | ||
| ); | ||
| expect(wrapper).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should add hideVideoProp to InfoContainer component when video is disabled', () => { | ||
| mockUsePublications.mockImplementation(() => [{ trackName: 'camera', isTrackEnabled: false }]); | ||
| const wrapper = shallow( | ||
| <MainParticipantInfo participant={{ identity: 'mockIdentity' } as any}>mock children</MainParticipantInfo> | ||
| ); | ||
| expect( | ||
| wrapper | ||
| .find('Styled(div)') | ||
| .at(1) | ||
| .prop('hideVideo') | ||
| ).toEqual(true); | ||
| }); | ||
|
|
||
| it('should not add hideVideoProp to InfoContainer component when video is enabled', () => { | ||
| mockUsePublications.mockImplementation(() => [{ trackName: 'camera', isTrackEnabled: true }]); | ||
| const wrapper = shallow( | ||
| <MainParticipantInfo participant={{ identity: 'mockIdentity' } as any}>mock children</MainParticipantInfo> | ||
| ); | ||
| expect( | ||
| wrapper | ||
| .find('Styled(div)') | ||
| .at(1) | ||
| .prop('hideVideo') | ||
| ).toEqual(false); | ||
| }); | ||
| }); |
47 changes: 47 additions & 0 deletions
47
src/components/MainParticipantInfo/MainParticipantInfo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import React from 'react'; | ||
| import { styled } from '@material-ui/core/styles'; | ||
| import { LocalParticipant, RemoteParticipant } from 'twilio-video'; | ||
| import usePublications from '../../hooks/usePublications/usePublications'; | ||
| import usePublicationIsTrackEnabled from '../../hooks/usePublicationIsTrackEnabled/usePublicationIsTrackEnabled'; | ||
|
|
||
| const Container = styled('div')({ | ||
| position: 'relative', | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| }); | ||
|
|
||
| const InfoContainer = styled('div')({ | ||
| position: 'absolute', | ||
| zIndex: 1, | ||
| height: '100%', | ||
| padding: '0.4em', | ||
| width: '100%', | ||
| background: ({ hideVideo }: { hideVideo?: boolean }) => (hideVideo ? 'black' : 'transparent'), | ||
| }); | ||
|
|
||
| const Identity = styled('h4')({ | ||
| background: 'rgba(0, 0, 0, 0.7)', | ||
| padding: '0.1em 0.3em', | ||
| margin: '1em', | ||
| fontSize: '1.2em', | ||
| display: 'inline-block', | ||
| }); | ||
|
|
||
| interface ParticipantInfoProps { | ||
| participant: LocalParticipant | RemoteParticipant; | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| export default function ParticipantInfo({ participant, children }: ParticipantInfoProps) { | ||
| const publications = usePublications(participant); | ||
| const isVideoEnabled = usePublicationIsTrackEnabled(publications.find(p => p.trackName === 'camera')); | ||
|
|
||
| return ( | ||
| <Container> | ||
| <InfoContainer hideVideo={!isVideoEnabled}> | ||
| <Identity>{participant.identity}</Identity> | ||
| </InfoContainer> | ||
| {children} | ||
| </Container> | ||
| ); | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/components/MainParticipantInfo/__snapshots__/MainParticipantInfo.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`the MainParticipantInfo component should render correctly 1`] = ` | ||
| <Styled(div)> | ||
| <Styled(div) | ||
| hideVideo={true} | ||
| > | ||
| <Styled(h4)> | ||
| mockIdentity | ||
| </Styled(h4)> | ||
| </Styled(div)> | ||
| mock children | ||
| </Styled(div)> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💯