From 6c8847a37168a08eb9a7c77d4ed702477729b34f Mon Sep 17 00:00:00 2001 From: Julien Torrent Date: Wed, 6 Oct 2021 16:37:53 +0200 Subject: [PATCH] feat: display chat as side pannel --- src/components/common/ChatPannel.js | 99 +++++++++++++++++++++++++++++ src/components/main/MainScreen.js | 6 +- 2 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 src/components/common/ChatPannel.js diff --git a/src/components/common/ChatPannel.js b/src/components/common/ChatPannel.js new file mode 100644 index 00000000..c596309f --- /dev/null +++ b/src/components/common/ChatPannel.js @@ -0,0 +1,99 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import clsx from 'clsx'; +import { makeStyles, useTheme } from '@material-ui/core/styles'; +import IconButton from '@material-ui/core/IconButton'; +import MenuIcon from '@material-ui/icons/Menu'; +import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; +import ChevronRightIcon from '@material-ui/icons/ChevronRight'; +import { Box, Paper, Slide } from '@material-ui/core'; +import { HEADER_HEIGHT } from '../../config/constants'; + +const drawerWidth = 400; + +const useStyles = makeStyles((theme) => ({ + root: { + display: 'flex', + }, + drawer: { + width: drawerWidth, + flexShrink: 0, + }, + drawerHeader: { + display: 'flex', + alignItems: 'center', + padding: theme.spacing(0, 1), + // necessary for content to be below app bar + justifyContent: 'flex-start', + }, + content: { + flexGrow: 1, + padding: theme.spacing(3), + transition: theme.transitions.create('margin', { + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.leavingScreen, + }), + }, + contentShift: { + transition: theme.transitions.create('margin', { + easing: theme.transitions.easing.easeOut, + duration: theme.transitions.duration.enteringScreen, + }), + marginRight: 0, + }, +})); + +// eslint-disable-next-line react/prop-types +export default function PersistentDrawerRight({ children, sideContent }) { + const classes = useStyles(); + const theme = useTheme(); + const [open, setOpen] = React.useState(false); + + const handleDrawerOpen = () => { + setOpen(!open); + }; + + const handleDrawerClose = () => { + setOpen(false); + }; + + return ( +
+
+ + + + +
+ {children} +
+ + + + +
+ + {theme.direction === 'rtl' ? : } + +
+ {sideContent} +
+
+
+
+ ); +} + +PersistentDrawerRight.propTypes = { + children: PropTypes.arrayOf(PropTypes.element).isRequired, + sideContent: PropTypes.arrayOf(PropTypes.element).isRequired, +} diff --git a/src/components/main/MainScreen.js b/src/components/main/MainScreen.js index a76ba3a7..7b309f9a 100644 --- a/src/components/main/MainScreen.js +++ b/src/components/main/MainScreen.js @@ -11,6 +11,7 @@ import Item from '../common/Item'; import { hooks } from '../../config/queryClient'; import HeaderRightContent from './HeaderRightContent'; import ItemHeader from '../common/ItemHeader'; +import ChatPannel from '../common/ChatPannel'; const MainScreen = () => { @@ -47,8 +48,9 @@ const MainScreen = () => { headerLeftContent={leftContent} headerRightContent={} > - {content} - + ]}> + {content} + ); };