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,10 +367,26 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => { | |||||||
|               > |               > | ||||||
|                 <ErrorBoundary>{children}</ErrorBoundary> |                 <ErrorBoundary>{children}</ErrorBoundary> | ||||||
|               </RouteContent> |               </RouteContent> | ||||||
|  |               <MuiDrawer | ||||||
|  |                 sx={{ | ||||||
|  |                   flexShrink: 0, | ||||||
|  |                   pointerEvents: 'none', | ||||||
|  |                   width: peerListWidth, | ||||||
|  |                   '& .MuiDrawer-paper': { | ||||||
|  |                     width: peerListWidth, | ||||||
|  |                     boxSizing: 'border-box', | ||||||
|  |                   }, | ||||||
|  |                   ...(isPeerListOpen && { | ||||||
|  |                     pointerEvents: 'auto', | ||||||
|  |                   }), | ||||||
|  |                 }} | ||||||
|  |                 variant="persistent" | ||||||
|  |                 anchor="right" | ||||||
|  |                 open={isPeerListOpen} | ||||||
|  |               > | ||||||
|                 <PeerList |                 <PeerList | ||||||
|                   userId={userPeerId} |                   userId={userPeerId} | ||||||
|                   roomId={roomId} |                   roomId={roomId} | ||||||
|                 isPeerListOpen={isPeerListOpen} |  | ||||||
|                   onPeerListClose={handlePeerListClick} |                   onPeerListClose={handlePeerListClick} | ||||||
|                   peerList={peerList} |                   peerList={peerList} | ||||||
|                   peerConnectionTypes={peerConnectionTypes} |                   peerConnectionTypes={peerConnectionTypes} | ||||||
| @ -377,6 +394,7 @@ export const Shell = ({ appNeedsUpdate, children, userPeerId }: ShellProps) => { | |||||||
|                   peerAudios={peerAudios} |                   peerAudios={peerAudios} | ||||||
|                   connectionTestResults={connectionTestResults} |                   connectionTestResults={connectionTestResults} | ||||||
|                 /> |                 /> | ||||||
|  |               </MuiDrawer> | ||||||
|               <QRCodeDialog |               <QRCodeDialog | ||||||
|                 isOpen={isQRCodeDialogOpen} |                 isOpen={isQRCodeDialogOpen} | ||||||
|                 handleClose={handleQRCodeDialogClose} |                 handleClose={handleQRCodeDialogClose} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user