mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c05ef39c7 |
No files matched your search
@@ -1,9 +1,46 @@
|
|||||||
import React from 'react';
|
import React, { createContext, useRef, useState } from 'react';
|
||||||
import { AppWrapperTypes } from '../interface/InterfaceUI';
|
import { AppWrapperTypes } from '../interface/InterfaceUI';
|
||||||
|
import { Computer } from '@material-ui/icons';
|
||||||
|
import PhoneDrawer from './PhoneDrawer';
|
||||||
|
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => console.log(),
|
||||||
|
icon: <Computer color="inherit" />,
|
||||||
|
text: 'Item Thing',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const AppWrapper = ({
|
||||||
|
children,
|
||||||
|
style,
|
||||||
|
handleClickAway,
|
||||||
|
sideMenu,
|
||||||
|
appName,
|
||||||
|
...props
|
||||||
|
}: AppWrapperTypes) => {
|
||||||
|
const ref = useRef();
|
||||||
|
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
export const AppWrapper = ({ children, style, handleClickAway, ...props }: AppWrapperTypes) => {
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
style={{
|
style={{
|
||||||
padding: 0,
|
padding: 0,
|
||||||
@@ -17,6 +54,13 @@ export const AppWrapper = ({ children, style, handleClickAway, ...props }: AppWr
|
|||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<PhoneDrawer
|
||||||
|
open={open}
|
||||||
|
handleClose={() => setOpen(false)}
|
||||||
|
appTitle={'Side Menu Thing'}
|
||||||
|
containerEl={ref.current}
|
||||||
|
items={items}
|
||||||
|
/>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
ListItem,
|
||||||
|
List,
|
||||||
|
ListItemText,
|
||||||
|
ListItemIcon,
|
||||||
|
Drawer,
|
||||||
|
Typography,
|
||||||
|
Box,
|
||||||
|
Divider,
|
||||||
|
Button,
|
||||||
|
useTheme,
|
||||||
|
} from '@material-ui/core';
|
||||||
|
import { ChevronLeft, Settings } from '@material-ui/icons';
|
||||||
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
interface DrawerItem {
|
||||||
|
onClick: () => void;
|
||||||
|
text: string;
|
||||||
|
icon?: JSX.Element;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BackAction = ({ handleClose }) => (
|
||||||
|
<Button
|
||||||
|
component={Box}
|
||||||
|
display="flex"
|
||||||
|
flexDirection="row"
|
||||||
|
alignItems="center"
|
||||||
|
left="16px"
|
||||||
|
position="absolute"
|
||||||
|
bottom="16px"
|
||||||
|
onClick={handleClose}
|
||||||
|
>
|
||||||
|
<ChevronLeft color="secondary" />
|
||||||
|
<Typography variant="body1" color="textSecondary">
|
||||||
|
Close
|
||||||
|
</Typography>
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
|
interface PhoneDrawer {
|
||||||
|
open: boolean;
|
||||||
|
handleClose: () => void;
|
||||||
|
containerEl: Element;
|
||||||
|
items: DrawerItem[];
|
||||||
|
appTitle?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
sidebarTitle: {
|
||||||
|
marginLeft: 20,
|
||||||
|
color: theme.palette.secondary.contrastText,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const PhoneDrawer: React.FC<PhoneDrawer> = ({
|
||||||
|
items,
|
||||||
|
open,
|
||||||
|
containerEl,
|
||||||
|
handleClose,
|
||||||
|
appTitle,
|
||||||
|
}) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
open={open}
|
||||||
|
onClose={() => {}}
|
||||||
|
PaperProps={{ style: { position: 'absolute', width: '70%' } }}
|
||||||
|
BackdropProps={{ style: { position: 'absolute' } }}
|
||||||
|
ModalProps={{
|
||||||
|
container: containerEl,
|
||||||
|
style: { position: 'absolute' },
|
||||||
|
}}
|
||||||
|
variant="temporary"
|
||||||
|
>
|
||||||
|
<Box height="100%">
|
||||||
|
<Box
|
||||||
|
display="flex"
|
||||||
|
flexDirection="row"
|
||||||
|
alignItems="center"
|
||||||
|
p={2}
|
||||||
|
bgcolor={theme.palette.secondary.main}
|
||||||
|
>
|
||||||
|
<Settings htmlColor={theme.palette.secondary.contrastText} />
|
||||||
|
{appTitle && (
|
||||||
|
<Typography variant="h6" className={classes.sidebarTitle}>
|
||||||
|
{appTitle}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
<List disablePadding>
|
||||||
|
{items.map((item) => (
|
||||||
|
<>
|
||||||
|
<ListItem
|
||||||
|
button
|
||||||
|
onClick={item.onClick}
|
||||||
|
style={{ color: theme.palette.text.secondary }}
|
||||||
|
>
|
||||||
|
{item?.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
|
||||||
|
<ListItemText primary={item.text} />
|
||||||
|
</ListItem>
|
||||||
|
<Divider />
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
<BackAction handleClose={handleClose} />
|
||||||
|
</Box>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PhoneDrawer;
|
||||||
@@ -9,7 +9,9 @@ export interface AppContentTypes {
|
|||||||
|
|
||||||
export interface AppWrapperTypes {
|
export interface AppWrapperTypes {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
appName?: string;
|
||||||
children?: JSX.Element | JSX.Element[];
|
children?: JSX.Element | JSX.Element[];
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
handleClickAway?: (...args: any[]) => void;
|
handleClickAway?: (...args: any[]) => void;
|
||||||
|
sideMenu?: string[];
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user