Skip to content

Commit

Permalink
feat: stats in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlaz committed Dec 18, 2023
1 parent 9d2b251 commit e583c4a
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ export const CallStatsLatencyChart = (props: {
animation: {
duration: 0,
},
elements: {
line: {
borderWidth: 1,
},
point: {
radius: 2,
},
},
scales: {
y: {
position: 'right',
stacked: true,
min: 0,
max: Math.max(210, Math.ceil((max + 10) / 10) * 10),
max: Math.max(180, Math.ceil((max + 10) / 10) * 10),
grid: {
display: true,
color: '#979ca0',
Expand Down
4 changes: 1 addition & 3 deletions packages/styling/src/CallStats.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.str-video__call-stats {
border-radius: var(--str-video__border-radius-lg);

background-color: var(--str-video__base-color7);
border-radius: var(--str-video__border-radius-lg);
padding: var(--str-video__spacing-md);
width: 100%;
display: flex;
Expand Down Expand Up @@ -92,7 +90,7 @@
.str-video__call-stats-line-chart-container {
position: relative;
margin: auto;
height: 250px;
height: 170px;
width: 100%;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/styling/src/_global-theme-variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
--str-video__icon--download: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGQ9Ik01MTIgNjY2LjUgMzY3LjIgNTIxLjdsMzYuMi0zNi4yIDgzIDgzVjI1Nmg1MS4ydjMxMi41bDgzLTgzIDM2LjIgMzYuMkw1MTIgNjY2LjV6bS0yMDQuOCA1MC4zVjc2OGg0MDkuNnYtNTEuMkgzMDcuMnoiLz48L3N2Zz4K');
--str-video__icon--developer: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIH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MkgxMC41MDEzTDkuMzI2MyAzLjgyNDkyWiIgZmlsbD0iI0UzRTRFNSIvPgo8L2c+Cjwvc3ZnPgo=');
Expand Down
57 changes: 33 additions & 24 deletions sample-apps/react/react-dogfood/components/ActiveCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ import { Stage } from './Stage';
import { InvitePanel, InvitePopup } from './InvitePanel/InvitePanel';
import { ChatWrapper } from './ChatWrapper';
import { ChatUI } from './ChatUI';
import { CallStatsSidebar, ToggleStatsButton } from './CallStatsWrapper';
import { ToggleSettingsTabModal } from './Settings/SettingsTabModal';
import { ToggleFeedbackButton } from './ToggleFeedbackButton';
import { ToggleDeveloperButton } from './ToggleDeveloperButton';
import { ToggleMoreOptionsListButton } from './ToggleMoreOptionsListButton';
import { ToggleLayoutButton } from './ToggleLayoutButton';
import { ToggleStatsButton } from './ToggleStatsButton';
import { ToggleParticipantListButton } from './ToggleParticipantListButton';
import { ToggleDualCameraButton } from './ToggleDualCameraButton';
import { ToggleDualMicButton } from './ToggleDualMicButton';
import { NewMessageNotification } from './NewMessageNotification';
import { UnreadCountBadge } from './UnreadCountBadge';

import { useBreakpoint, useLayoutSwitcher, useWatchChannel } from '../hooks';
import { useIsProntoEnvironment } from '../context/AppEnvironmentContext';
import {
useIsDemoEnvironment,
useIsProntoEnvironment,
} from '../context/AppEnvironmentContext';

export type ActiveCallProps = {
chatClient?: StreamChat | null;
Expand All @@ -42,12 +45,10 @@ export type ActiveCallProps = {
onJoin: (fastJoin: boolean) => void;
};

type SidebarContent = 'participants' | 'chat' | 'stats' | null;

export const ActiveCall = (props: ActiveCallProps) => {
const { chatClient, activeCall, onLeave, onJoin } = props;
const [showParticipants, setShowParticipants] = useState(false);
const [showInvitePopup, setShowInvitePopup] = useState(true);
const [showChat, setShowChat] = useState(false);

const { useParticipantCount } = useCallStateHooks();
const participantCount = useParticipantCount();

Expand All @@ -62,7 +63,13 @@ export const ActiveCall = (props: ActiveCallProps) => {
}
}, [breakpoint, layout, setLayout]);

const showSidebar = showParticipants || showChat;
const isDemoEnvironment = useIsDemoEnvironment();
const [showInvitePopup, setShowInvitePopup] = useState(isDemoEnvironment);
const [sidebarContent, setSidebarContent] = useState<SidebarContent>(null);
const showSidebar = sidebarContent != null;
const showParticipants = sidebarContent === 'participants';
const showChat = sidebarContent === 'chat';
const showStats = sidebarContent === 'stats';

// FIXME: could be replaced with "notification.message_new" but users would have to be at least members
// possible fix with "allow to join" permissions in place (expensive?)
Expand Down Expand Up @@ -107,22 +114,24 @@ export const ActiveCall = (props: ActiveCallProps) => {
{showParticipants && (
<div className="rd__participants">
<CallParticipantsList
onClose={() => setShowParticipants(false)}
onClose={() => setSidebarContent(null)}
/>
<InvitePanel />
</div>
)}

<ChatWrapper chatClient={chatClient}>
{showChat && (
{showChat && (
<ChatWrapper chatClient={chatClient}>
<div className="str-video__chat">
<ChatUI
onClose={() => setShowChat(false)}
onClose={() => setSidebarContent(null)}
channelId={activeCall.id}
/>
</div>
)}
</ChatWrapper>
</ChatWrapper>
)}

{showStats && <CallStatsSidebar />}
</div>
)}
</div>
Expand Down Expand Up @@ -167,21 +176,24 @@ export const ActiveCall = (props: ActiveCallProps) => {
</div>
</div>
<div className="str-video__call-controls--group str-video__call-controls--sidebar">
{isPronto && (
<div className="str-video__call-controls__desktop">
<ToggleStatsButton />
</div>
)}
<ToggleLayoutButton
selectedLayout={layout}
onMenuItemClick={setLayout}
/>

{isPronto && (
<div className="str-video__call-controls__desktop">
<ToggleStatsButton
active={showStats}
onClick={() => setSidebarContent(showStats ? null : 'stats')}
/>
</div>
)}

<ToggleParticipantListButton
enabled={showParticipants}
onClick={() => {
setShowParticipants((prev) => !prev);
setShowChat(false);
setSidebarContent(showParticipants ? null : 'participants');
}}
/>
<NewMessageNotification
Expand All @@ -195,10 +207,7 @@ export const ActiveCall = (props: ActiveCallProps) => {
enabled={showChat}
disabled={!chatClient}
title="Chat"
onClick={() => {
setShowChat((prev) => !prev);
setShowParticipants(false);
}}
onClick={() => setSidebarContent(showChat ? null : 'chat')}
icon="chat"
/>
</CompositeButton>
Expand Down
25 changes: 25 additions & 0 deletions sample-apps/react/react-dogfood/components/CallStatsWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
CallStats,
CompositeButton,
IconButton,
} from '@stream-io/video-react-sdk';

export const ToggleStatsButton = (props: {
active?: boolean;
onClick?: () => void;
}) => {
const { active, onClick } = props;
return (
<CompositeButton active={active} variant="primary">
<IconButton icon="stats" title="Stats" onClick={onClick} />
</CompositeButton>
);
};

export const CallStatsSidebar = () => {
return (
<div className="rd__sidebar__call-stats">
<CallStats />
</div>
);
};
33 changes: 0 additions & 33 deletions sample-apps/react/react-dogfood/components/ToggleStatsButton.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,3 @@
width: 16px;
margin-left: 20px;
}

.rd__stats-wrapper {
max-width: 400px;
}
8 changes: 6 additions & 2 deletions sample-apps/react/react-dogfood/style/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
}
}

.rd__sidebar__call-stats {
overflow-y: scroll;
}

.rd__participants {
display: flex;
flex-direction: column;
Expand All @@ -44,8 +48,8 @@
@include respond-above(sm) {
.rd__sidebar {
position: relative;
max-width: 300px;
min-width: 300px;
max-width: 350px;
min-width: 350px;
display: flex;
gap: var(--str-video__spacing-md);
height: auto;
Expand Down

0 comments on commit e583c4a

Please sign in to comment.