refactor(shell): move MuiDrawer out of PeerList
This commit is contained in:
parent
c170edb692
commit
dfd4131959
@ -1,6 +1,5 @@
|
|||||||
import { PropsWithChildren } from 'react'
|
import { PropsWithChildren } from 'react'
|
||||||
import { Route, Routes } from 'react-router-dom'
|
import { Route, Routes } from 'react-router-dom'
|
||||||
import MuiDrawer from '@mui/material/Drawer'
|
|
||||||
import List from '@mui/material/List'
|
import List from '@mui/material/List'
|
||||||
import ListItemIcon from '@mui/material/ListItemIcon'
|
import ListItemIcon from '@mui/material/ListItemIcon'
|
||||||
import ListItemText from '@mui/material/ListItemText'
|
import ListItemText from '@mui/material/ListItemText'
|
||||||
@ -28,7 +27,6 @@ export const peerListWidth = 300
|
|||||||
export interface PeerListProps extends PropsWithChildren {
|
export interface PeerListProps extends PropsWithChildren {
|
||||||
userId: string
|
userId: string
|
||||||
roomId: string | undefined
|
roomId: string | undefined
|
||||||
isPeerListOpen: boolean
|
|
||||||
onPeerListClose: () => void
|
onPeerListClose: () => void
|
||||||
peerList: Peer[]
|
peerList: Peer[]
|
||||||
peerConnectionTypes: Record<string, PeerConnectionType>
|
peerConnectionTypes: Record<string, PeerConnectionType>
|
||||||
@ -40,7 +38,6 @@ export interface PeerListProps extends PropsWithChildren {
|
|||||||
export const PeerList = ({
|
export const PeerList = ({
|
||||||
userId,
|
userId,
|
||||||
roomId,
|
roomId,
|
||||||
isPeerListOpen,
|
|
||||||
onPeerListClose,
|
onPeerListClose,
|
||||||
peerList,
|
peerList,
|
||||||
peerConnectionTypes,
|
peerConnectionTypes,
|
||||||
@ -49,23 +46,7 @@ export const PeerList = ({
|
|||||||
connectionTestResults,
|
connectionTestResults,
|
||||||
}: PeerListProps) => {
|
}: PeerListProps) => {
|
||||||
return (
|
return (
|
||||||
<MuiDrawer
|
<>
|
||||||
sx={{
|
|
||||||
flexShrink: 0,
|
|
||||||
pointerEvents: 'none',
|
|
||||||
width: peerListWidth,
|
|
||||||
'& .MuiDrawer-paper': {
|
|
||||||
width: peerListWidth,
|
|
||||||
boxSizing: 'border-box',
|
|
||||||
},
|
|
||||||
...(isPeerListOpen && {
|
|
||||||
pointerEvents: 'auto',
|
|
||||||
}),
|
|
||||||
}}
|
|
||||||
variant="persistent"
|
|
||||||
anchor="right"
|
|
||||||
open={isPeerListOpen}
|
|
||||||
>
|
|
||||||
<PeerListHeader>
|
<PeerListHeader>
|
||||||
<IconButton onClick={onPeerListClose} aria-label="Close peer list">
|
<IconButton onClick={onPeerListClose} aria-label="Close peer list">
|
||||||
<ChevronRightIcon />
|
<ChevronRightIcon />
|
||||||
@ -132,6 +113,6 @@ export const PeerList = ({
|
|||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
</List>
|
</List>
|
||||||
</MuiDrawer>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import CssBaseline from '@mui/material/CssBaseline'
|
|||||||
import { ThemeProvider, createTheme } from '@mui/material/styles'
|
import { ThemeProvider, createTheme } from '@mui/material/styles'
|
||||||
import Box from '@mui/material/Box'
|
import Box from '@mui/material/Box'
|
||||||
import { AlertColor } from '@mui/material/Alert'
|
import { AlertColor } from '@mui/material/Alert'
|
||||||
|
import MuiDrawer from '@mui/material/Drawer'
|
||||||
import { useWindowSize } from '@react-hook/window-size'
|
import { useWindowSize } from '@react-hook/window-size'
|
||||||
|
|
||||||
import { ShellContext } from 'contexts/ShellContext'
|
import { ShellContext } from 'contexts/ShellContext'
|
||||||
@ -26,7 +27,7 @@ import { UpgradeDialog } from './UpgradeDialog'
|
|||||||
import { ShellAppBar } from './ShellAppBar'
|
import { ShellAppBar } from './ShellAppBar'
|
||||||
import { NotificationArea } from './NotificationArea'
|
import { NotificationArea } from './NotificationArea'
|
||||||
import { RouteContent } from './RouteContent'
|
import { RouteContent } from './RouteContent'
|
||||||
import { PeerList } from './PeerList'
|
import { PeerList, peerListWidth } from './PeerList'
|
||||||
import { QRCodeDialog } from './QRCodeDialog'
|
import { QRCodeDialog } from './QRCodeDialog'
|
||||||
import { RoomShareDialog } from './RoomShareDialog'
|
import { RoomShareDialog } from './RoomShareDialog'
|
||||||
import { useConnectionTest } from './useConnectionTest'
|
import { useConnectionTest } from './useConnectionTest'
|
||||||
@ -366,17 +367,34 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => {
|
|||||||
>
|
>
|
||||||
<ErrorBoundary>{children}</ErrorBoundary>
|
<ErrorBoundary>{children}</ErrorBoundary>
|
||||||
</RouteContent>
|
</RouteContent>
|
||||||
<PeerList
|
<MuiDrawer
|
||||||
userId={userPeerId}
|
sx={{
|
||||||
roomId={roomId}
|
flexShrink: 0,
|
||||||
isPeerListOpen={isPeerListOpen}
|
pointerEvents: 'none',
|
||||||
onPeerListClose={handlePeerListClick}
|
width: peerListWidth,
|
||||||
peerList={peerList}
|
'& .MuiDrawer-paper': {
|
||||||
peerConnectionTypes={peerConnectionTypes}
|
width: peerListWidth,
|
||||||
audioState={audioState}
|
boxSizing: 'border-box',
|
||||||
peerAudios={peerAudios}
|
},
|
||||||
connectionTestResults={connectionTestResults}
|
...(isPeerListOpen && {
|
||||||
/>
|
pointerEvents: 'auto',
|
||||||
|
}),
|
||||||
|
}}
|
||||||
|
variant="persistent"
|
||||||
|
anchor="right"
|
||||||
|
open={isPeerListOpen}
|
||||||
|
>
|
||||||
|
<PeerList
|
||||||
|
userId={userPeerId}
|
||||||
|
roomId={roomId}
|
||||||
|
onPeerListClose={handlePeerListClick}
|
||||||
|
peerList={peerList}
|
||||||
|
peerConnectionTypes={peerConnectionTypes}
|
||||||
|
audioState={audioState}
|
||||||
|
peerAudios={peerAudios}
|
||||||
|
connectionTestResults={connectionTestResults}
|
||||||
|
/>
|
||||||
|
</MuiDrawer>
|
||||||
<QRCodeDialog
|
<QRCodeDialog
|
||||||
isOpen={isQRCodeDialogOpen}
|
isOpen={isQRCodeDialogOpen}
|
||||||
handleClose={handleQRCodeDialogClose}
|
handleClose={handleQRCodeDialogClose}
|
||||||
|
Loading…
Reference in New Issue
Block a user