Skip to content
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

fix: ui for chat, participant list #1895

Merged
merged 4 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const Footer = ({
gap: '$10',
position: 'relative',
// To prevent it from showing over the sidepane if chat type is not overlay
zIndex: isOverlayChat ? 20 : 1,
zIndex: isOverlayChat && isChatOpen ? 20 : 1,
},
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ const VirtualizedParticipants = ({ peersOrderedByRoles = {}, isConnected, filter
direction="column"
css={{
gap: '$8',
maxHeight: '100%',
overflowY: 'auto',
overflowX: 'hidden',
pr: '$3',
pr: '$10',
mr: '-$10',
flex: '1 1 0',
}}
>
<RoleAccordion
Expand Down Expand Up @@ -316,7 +317,7 @@ export const ParticipantSearch = ({ onSearch, placeholder, inSidePane = false })
<Flex
align="center"
css={{
p: isMobile ? '$0 $6' : '$2 0',
p: isMobile ? '0' : '$2 0',
mb: '$2',
position: 'relative',
color: '$on_surface_medium',
Expand Down
129 changes: 72 additions & 57 deletions packages/roomkit-react/src/Prebuilt/components/SidePaneTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, { useEffect, useState } from 'react';
import { useMedia } from 'react-use';
import { ConferencingScreen } from '@100mslive/types-prebuilt';
import { selectPeerCount, useHMSStore } from '@100mslive/react-sdk';
import { CrossIcon } from '@100mslive/react-icons';
// @ts-ignore: No implicit Any
import { Chat } from './Chat/Chat';
// @ts-ignore: No implicit Any
import { ParticipantList } from './Footer/ParticipantList';
import { Flex, IconButton, Tabs, Text } from '../..';
import { config as cssConfig, Flex, IconButton, Tabs, Text } from '../..';
// @ts-ignore: No implicit Any
import { useRoomLayoutConferencingScreen } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
// @ts-ignore: No implicit Any
import { useSidepaneReset, useSidepaneToggle } from './AppData/useSidepane';
import { useIsSidepaneTypeOpen, useSidepaneReset, useSidepaneToggle } from './AppData/useSidepane';
// @ts-ignore: No implicit Any
import { SIDE_PANE_OPTIONS } from '../common/constants';

Expand All @@ -36,6 +38,9 @@ export const SidePaneTabs = React.memo<{
const showChat = !!elements?.chat;
const showParticipants = !!elements?.participant_list;
const hideTabs = !(showChat && showParticipants);
const isMobile = useMedia(cssConfig.media.md);
const isOverlayChat = !!elements?.chat?.is_overlay && isMobile;
const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);

useEffect(() => {
if (activeTab === SIDE_PANE_OPTIONS.CHAT && !showChat && showParticipants) {
Expand All @@ -55,66 +60,76 @@ export const SidePaneTabs = React.memo<{
h: '100%',
}}
>
{hideTabs ? (
<>
<Text variant="sm" css={{ fontWeight: '$semiBold', p: '$4', c: '$on_surface_high', pr: '$12' }}>
{showChat ? 'Chat' : `Participants (${peerCount})`}
</Text>
{showChat ? <Chat screenType={screenType} hideControls={hideControls} /> : <ParticipantList />}
</>
{isOverlayChat && isChatOpen && showChat ? (
<Chat screenType={screenType} hideControls={hideControls} />
) : (
<Tabs.Root
value={activeTab}
onValueChange={setActiveTab}
css={{
flexDirection: 'column',
size: '100%',
}}
>
<Tabs.List css={{ w: 'calc(100% - $12)', p: '$2', borderRadius: '$2', bg: '$surface_default' }}>
<Tabs.Trigger
value={SIDE_PANE_OPTIONS.CHAT}
onClick={toggleChat}
css={{
...tabTriggerCSS,
color: activeTab !== SIDE_PANE_OPTIONS.CHAT ? '$on_surface_low' : '$on_surface_high',
}}
>
Chat
</Tabs.Trigger>
<Tabs.Trigger
value={SIDE_PANE_OPTIONS.PARTICIPANTS}
onClick={toggleParticipants}
<>
{hideTabs ? (
<>
<Text variant="sm" css={{ fontWeight: '$semiBold', p: '$4', c: '$on_surface_high', pr: '$12' }}>
{showChat ? 'Chat' : `Participants (${peerCount})`}
</Text>

{showChat ? <Chat screenType={screenType} hideControls={hideControls} /> : <ParticipantList />}
</>
) : (
<Tabs.Root
value={activeTab}
onValueChange={setActiveTab}
css={{
...tabTriggerCSS,
color: activeTab !== SIDE_PANE_OPTIONS.PARTICIPANTS ? '$on_surface_low' : '$on_surface_high',
flexDirection: 'column',
size: '100%',
}}
>
Participants ({peerCount})
</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value={SIDE_PANE_OPTIONS.PARTICIPANTS} css={{ p: 0 }}>
<ParticipantList />
</Tabs.Content>
<Tabs.Content value={SIDE_PANE_OPTIONS.CHAT} css={{ p: 0 }}>
<Chat screenType={screenType} hideControls={hideControls} />
</Tabs.Content>
</Tabs.Root>
<Tabs.List css={{ w: 'calc(100% - $12)', p: '$2', borderRadius: '$2', bg: '$surface_default' }}>
<Tabs.Trigger
value={SIDE_PANE_OPTIONS.CHAT}
onClick={toggleChat}
css={{
...tabTriggerCSS,
color: activeTab !== SIDE_PANE_OPTIONS.CHAT ? '$on_surface_low' : '$on_surface_high',
}}
>
Chat
</Tabs.Trigger>
<Tabs.Trigger
value={SIDE_PANE_OPTIONS.PARTICIPANTS}
onClick={toggleParticipants}
css={{
...tabTriggerCSS,
color: activeTab !== SIDE_PANE_OPTIONS.PARTICIPANTS ? '$on_surface_low' : '$on_surface_high',
}}
>
Participants ({peerCount})
</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value={SIDE_PANE_OPTIONS.PARTICIPANTS} css={{ p: 0 }}>
<ParticipantList />
</Tabs.Content>
<Tabs.Content value={SIDE_PANE_OPTIONS.CHAT} css={{ p: 0 }}>
<Chat screenType={screenType} hideControls={hideControls} />
</Tabs.Content>
</Tabs.Root>
)}
</>
)}

{isOverlayChat && isChatOpen ? null : (
<IconButton
css={{ position: 'absolute', right: '$10', top: '$11', '@md': { top: '$8', right: '$8' } }}
onClick={e => {
e.stopPropagation();
if (activeTab === SIDE_PANE_OPTIONS.CHAT) {
toggleChat();
} else {
toggleParticipants();
}
}}
data-testid="close_chat"
>
<CrossIcon />
</IconButton>
)}
<IconButton
css={{ position: 'absolute', right: '$10', top: '$11' }}
onClick={e => {
e.stopPropagation();
if (activeTab === SIDE_PANE_OPTIONS.CHAT) {
toggleChat();
} else {
toggleParticipants();
}
}}
data-testid="close_chat"
>
<CrossIcon />
</IconButton>
</Flex>
);
});
Loading