mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 21:29:25 +00:00
layout responsivo 1ª parte
This commit is contained in:
@@ -42,7 +42,8 @@ function ListItemLink(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const MainListItems = () => {
|
const MainListItems = (props) => {
|
||||||
|
const { drawerClose } = props;
|
||||||
const { whatsApps } = useContext(WhatsAppsContext);
|
const { whatsApps } = useContext(WhatsAppsContext);
|
||||||
const { user } = useContext(AuthContext);
|
const { user } = useContext(AuthContext);
|
||||||
const [connectionWarning, setConnectionWarning] = useState(false);
|
const [connectionWarning, setConnectionWarning] = useState(false);
|
||||||
@@ -70,7 +71,7 @@ const MainListItems = () => {
|
|||||||
}, [whatsApps]);
|
}, [whatsApps]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div onClick={drawerClose}>
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
to="/"
|
to="/"
|
||||||
primary="Dashboard"
|
primary="Dashboard"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useContext } from "react";
|
import React, { useState, useContext, useEffect } from "react";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -24,14 +24,16 @@ import UserModal from "../components/UserModal";
|
|||||||
import { AuthContext } from "../context/Auth/AuthContext";
|
import { AuthContext } from "../context/Auth/AuthContext";
|
||||||
import BackdropLoading from "../components/BackdropLoading";
|
import BackdropLoading from "../components/BackdropLoading";
|
||||||
import { i18n } from "../translate/i18n";
|
import { i18n } from "../translate/i18n";
|
||||||
import { useLocalStorage } from "../hooks/useLocalStorage";
|
|
||||||
|
|
||||||
const drawerWidth = 240;
|
const drawerWidth = 240;
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
height: "100vh",
|
height: "100vh",
|
||||||
|
[theme.breakpoints.down("sm")]: {
|
||||||
|
height: "calc(100vh - 56px)",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
toolbar: {
|
toolbar: {
|
||||||
@@ -113,10 +115,25 @@ const LoggedInLayout = ({ children }) => {
|
|||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
const { handleLogout, loading } = useContext(AuthContext);
|
const { handleLogout, loading } = useContext(AuthContext);
|
||||||
const [drawerOpen, setDrawerOpen] = useLocalStorage("drawerOpen", true);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
const [drawerVariant, setDrawerVariant] = useState("permanent");
|
||||||
const { user } = useContext(AuthContext);
|
const { user } = useContext(AuthContext);
|
||||||
|
|
||||||
const handleMenu = event => {
|
useEffect(() => {
|
||||||
|
if (document.body.offsetWidth > 600) {
|
||||||
|
setDrawerOpen(true);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (document.body.offsetWidth < 600) {
|
||||||
|
setDrawerVariant("temporary");
|
||||||
|
} else {
|
||||||
|
setDrawerVariant("permanent");
|
||||||
|
}
|
||||||
|
}, [drawerOpen]);
|
||||||
|
|
||||||
|
const handleMenu = (event) => {
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
setMenuOpen(true);
|
setMenuOpen(true);
|
||||||
};
|
};
|
||||||
@@ -136,6 +153,12 @@ const LoggedInLayout = ({ children }) => {
|
|||||||
handleLogout();
|
handleLogout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const drawerClose = () => {
|
||||||
|
if (document.body.offsetWidth < 600) {
|
||||||
|
setDrawerOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <BackdropLoading />;
|
return <BackdropLoading />;
|
||||||
}
|
}
|
||||||
@@ -143,7 +166,8 @@ const LoggedInLayout = ({ children }) => {
|
|||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Drawer
|
<Drawer
|
||||||
variant="permanent"
|
variant={drawerVariant}
|
||||||
|
className={drawerOpen ? classes.drawerPaper : classes.drawerPaperClose}
|
||||||
classes={{
|
classes={{
|
||||||
paper: clsx(
|
paper: clsx(
|
||||||
classes.drawerPaper,
|
classes.drawerPaper,
|
||||||
@@ -159,7 +183,7 @@ const LoggedInLayout = ({ children }) => {
|
|||||||
</div>
|
</div>
|
||||||
<Divider />
|
<Divider />
|
||||||
<List>
|
<List>
|
||||||
<MainListItems />
|
<MainListItems drawerClose={drawerClose} />
|
||||||
</List>
|
</List>
|
||||||
<Divider />
|
<Divider />
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|||||||
Reference in New Issue
Block a user