-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d6968f
commit 4703903
Showing
4 changed files
with
124 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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
96 changes: 96 additions & 0 deletions
96
packages/roomkit-react/src/Prebuilt/components/VideoLayouts/WhiteboardLayout.tsx
This file contains 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,96 @@ | ||
import React, { useEffect, useMemo } from 'react'; | ||
import { useMedia } from 'react-use'; | ||
import { selectPeerByCondition, selectWhiteboard, useHMSStore, useWhiteboard } from '@100mslive/react-sdk'; | ||
import { Box } from '../../../Layout'; | ||
import { config as cssConfig } from '../../../Theme'; | ||
import { InsetTile } from '../InsetTile'; | ||
import { SecondaryTiles } from '../SecondaryTiles'; | ||
import { LayoutMode } from '../Settings/LayoutSettings'; | ||
import { LayoutProps } from './interface'; | ||
import { ProminenceLayout } from './ProminenceLayout'; | ||
// @ts-ignore: No implicit Any | ||
import { useSetUiSettings } from '../AppData/useUISettings'; | ||
// @ts-ignore: No implicit Any | ||
import { UI_SETTINGS } from '../../common/constants'; | ||
|
||
const WhiteboardEmbed = () => { | ||
const isMobile = useMedia(cssConfig.media.md); | ||
const { iframeRef } = useWhiteboard(isMobile); | ||
|
||
return ( | ||
<Box | ||
css={{ | ||
mx: '$8', | ||
flex: '3 1 0', | ||
'@lg': { | ||
flex: '2 1 0', | ||
display: 'flex', | ||
alignItems: 'center', | ||
}, | ||
}} | ||
> | ||
<iframe | ||
title="Whiteboard View" | ||
ref={iframeRef} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
border: 0, | ||
borderRadius: '0.75rem', | ||
}} | ||
allow="autoplay; clipboard-write;" | ||
referrerPolicy="no-referrer" | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
export const WhiteboardLayout = ({ peers, onPageChange, onPageSize, edgeToEdge }: LayoutProps) => { | ||
const whiteboard = useHMSStore(selectWhiteboard); | ||
const whiteboardOwner = useHMSStore(selectPeerByCondition(peer => peer.customerUserId === whiteboard?.owner)); | ||
const [layoutMode, setLayoutMode] = useSetUiSettings(UI_SETTINGS.layoutMode); | ||
const isMobile = useMedia(cssConfig.media.md); | ||
const hasSidebar = !isMobile && layoutMode === LayoutMode.SIDEBAR; | ||
const secondaryPeers = useMemo(() => { | ||
if (layoutMode === LayoutMode.SPOTLIGHT) { | ||
return []; | ||
} | ||
if (isMobile || layoutMode === LayoutMode.SIDEBAR) { | ||
return whiteboardOwner | ||
? [whiteboardOwner, ...peers.filter(p => p.id !== whiteboardOwner?.id)] //keep active sharing peer as first tile | ||
: peers; | ||
} | ||
return peers.filter(p => p.id !== whiteboardOwner?.id); | ||
}, [whiteboardOwner, peers, isMobile, layoutMode]); | ||
|
||
useEffect(() => { | ||
if (isMobile) { | ||
setLayoutMode(LayoutMode.GALLERY); | ||
return; | ||
} | ||
if (layoutMode === LayoutMode.SIDEBAR) { | ||
return; | ||
} | ||
setLayoutMode(LayoutMode.SIDEBAR); | ||
return () => { | ||
// reset to gallery once whiteboard is stopped | ||
setLayoutMode(LayoutMode.GALLERY); | ||
}; | ||
}, [isMobile]); // eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
return ( | ||
<ProminenceLayout.Root edgeToEdge={edgeToEdge} hasSidebar={hasSidebar}> | ||
<ProminenceLayout.ProminentSection> | ||
<WhiteboardEmbed /> | ||
</ProminenceLayout.ProminentSection> | ||
<SecondaryTiles | ||
peers={secondaryPeers} | ||
onPageChange={onPageChange} | ||
onPageSize={onPageSize} | ||
edgeToEdge={edgeToEdge} | ||
hasSidebar={hasSidebar} | ||
/> | ||
{layoutMode === LayoutMode.SPOTLIGHT && whiteboardOwner && <InsetTile peerId={whiteboardOwner?.id} />} | ||
</ProminenceLayout.Root> | ||
); | ||
}; |
This file contains 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
69 changes: 0 additions & 69 deletions
69
packages/roomkit-react/src/Prebuilt/layouts/WhiteboardView.tsx
This file was deleted.
Oops, something went wrong.