Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sidebar hidden by default in mobile view #8

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react-icons": "^4.2.0",
"react-pro-sidebar": "^0.6.0",
"react-redux": "^7.2.4",
"react-responsive": "^9.0.0-beta.5",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
Expand Down
68 changes: 39 additions & 29 deletions src/Components/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSelector, useDispatch } from "react-redux";
import { saveUserData, setAuth } from "../redux/actions";
import { makeStyles, useTheme } from '@material-ui/core/styles';
import { Route, Link, Switch, withRouter } from 'react-router-dom';
import { useMediaQuery } from 'react-responsive';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
Expand Down Expand Up @@ -95,7 +96,6 @@ const useStyles = makeStyles((theme) => ({
flexGrow: 1,
padding: theme.spacing(3),
},

}));

function MiniDrawer(props) {
Expand All @@ -106,12 +106,15 @@ function MiniDrawer(props) {
const classes = useStyles();
const theme = useTheme();
const [open, setOpen] = useState(false);
const [minWidth, setMinWidth] = useState('1224px');

const handleDrawerOpen = () => {
setMinWidth('0px');
setOpen(true);
};

const handleDrawerClose = () => {
setMinWidth('1224px');
setOpen(false);
};

Expand All @@ -127,7 +130,12 @@ function MiniDrawer(props) {
})
};


const isDesktopOrLaptop = useMediaQuery(
{
query: `(min-width: ${minWidth})`
}
);


return (
<div className={classes.root}>
Expand Down Expand Up @@ -159,7 +167,7 @@ function MiniDrawer(props) {
</Toolbar>
</AppBar>


{ isDesktopOrLaptop &&
<Drawer
variant="permanent"
className={clsx(classes.drawer, {
Expand All @@ -181,38 +189,38 @@ function MiniDrawer(props) {
{theme.direction === 'rtl' ? <ChevronRightIcon /> : <ChevronLeftIcon />}
</IconButton>
</div>

<Divider />
{loggedin ?
<List>

<ListItem button key={"Dashboard"} onClick={() => history.push("/dashboard")}>
<ListItemIcon><HomeIcon /></ListItemIcon>
<ListItemText primary={"Dashboard"} />
</ListItem>

{user && user.userType == "Faculty" &&
<ListItem button key={"Report"} onClick={() => history.push("/analysis")}>
<ListItemIcon><EqualizerIcon /></ListItemIcon>
<ListItemText primary={"Report"} />
{ loggedin ?
<List>
<ListItem button key={"Dashboard"} onClick={() => history.push("/dashboard")}>
<ListItemIcon><HomeIcon /></ListItemIcon>
<ListItemText primary={"Dashboard"} />
</ListItem>
}
<ListItem button key={"Profile"} onClick={() => history.push("/profile")}>
<ListItemIcon><AccountCircleIcon /></ListItemIcon>
<ListItemText primary={"Profile"} />
</ListItem>

</List>
:
<List>
{user && user.userType == "Faculty" &&
<ListItem button key={"Report"} onClick={() => history.push("/analysis")}>
<ListItemIcon><EqualizerIcon /></ListItemIcon>
<ListItemText primary={"Report"} />
</ListItem>
}
<ListItem button key={"Profile"} onClick={() => history.push("/profile")}>
<ListItemIcon><AccountCircleIcon /></ListItemIcon>
<ListItemText primary={"Profile"} />
</ListItem>
</List>
:
<List>

<ListItem button key={"Home"} onClick={() => history.push("/")}>
<ListItemIcon><HomeIcon /></ListItemIcon>
<ListItemText primary={"Home"} />
</ListItem>
<ListItem button key={"Home"} onClick={() => history.push("/")}>
<ListItemIcon><HomeIcon /></ListItemIcon>
<ListItemText primary={"Home"} />
</ListItem>

</List>
}
</List>
}
<Divider />

{loggedin &&
<List>
<ListItem button key={"Log Out"} onClick={singOutUser}>
Expand All @@ -222,6 +230,8 @@ function MiniDrawer(props) {
</List>
}
</Drawer>
}


<div style={{ marginTop: "10vh", width: "100%" }}>
<Switch>
Expand Down