Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | import {
KeyboardDoubleArrowLeft,
KeyboardDoubleArrowRight,
} from "@mui/icons-material";
import { styled } from "@mui/material";
import { useTranslation } from "i18n";
import { GLOBAL } from "i18n/namespaces";
import React from "react";
import { theme } from "theme";
import IconButton from "./IconButton";
export const DEFAULT_DRAWER_WIDTH = 420;
interface ResizeableDrawerProps {
children: React.ReactNode;
nonScrollableChildren?: React.ReactNode;
onDrawerWidthChange: (width: number) => void;
showDragger?: boolean;
}
const DrawerContentWrapper = styled("div")(() => ({
display: "flex",
flexDirection: "row",
height: "100%",
width: "100%",
position: "relative",
}));
const StyledDragger = styled("div")(({ theme }) => ({
width: "8px",
borderLeft: `1px solid ${theme.palette.divider}`,
backgroundColor: theme.palette.grey[50],
display: "flex",
alignItems: "center",
justifyContent: "center",
position: "relative",
}));
const ScrollableContent = styled("div")(({ theme }) => ({
overflowY: "auto",
overflowX: "hidden",
height: "100%",
width: "100%",
}));
const FlexColumn = styled("div")({
display: "flex",
flexDirection: "column",
height: "100%",
width: "100%",
});
export default function ResizeableDrawer({
children,
nonScrollableChildren,
onDrawerWidthChange,
showDragger,
}: ResizeableDrawerProps) {
const { t } = useTranslation([GLOBAL]);
const [isExpanded, setIsExpanded] = React.useState(false);
const handleDrawerExpansion = () => {
setIsExpanded(!isExpanded);
onDrawerWidthChange(
isExpanded ? DEFAULT_DRAWER_WIDTH : Math.floor(window?.innerWidth * 0.6),
);
};
return (
<DrawerContentWrapper>
<FlexColumn>
<ScrollableContent>{children}</ScrollableContent>
{nonScrollableChildren}
</FlexColumn>
{showDragger && (
<StyledDragger>
<IconButton
onClick={handleDrawerExpansion}
aria-label={t(`global:${isExpanded ? "retract" : "expand"}`)}
sx={{
fontSize: "24px",
backgroundColor: theme.palette.common.white,
border: `1px solid ${theme.palette.divider}`,
height: "35px",
width: "35px",
zIndex: 100,
transition: "all 0.2s ease-in-out",
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)",
"&:hover": {
backgroundColor: theme.palette.grey[50],
borderColor: theme.palette.grey[400],
boxShadow: "0 2px 6px rgba(0, 0, 0, 0.15)",
transform: "scale(1.05)",
},
"&:active": {
transform: "scale(0.98)",
backgroundColor: theme.palette.grey[100],
},
}}
>
{isExpanded ? (
<KeyboardDoubleArrowLeft
sx={{
"&:hover": {
color: theme.palette.primary.main,
},
}}
/>
) : (
<KeyboardDoubleArrowRight
sx={{
"&:hover": {
color: theme.palette.primary.main,
},
}}
/>
)}
</IconButton>
</StyledDragger>
)}
</DrawerContentWrapper>
);
}
|