Sidebar UI changed

This commit is contained in:
Monil Prajapati
2023-11-09 00:33:28 +05:30
parent a19b6baa0c
commit 7ea11f67d0
2 changed files with 278 additions and 265 deletions
+2 -2
View File
@@ -76,10 +76,10 @@
"shellwords": "^0.1.1", "shellwords": "^0.1.1",
"simplebar": "^4.2.3", "simplebar": "^4.2.3",
"styled-components": "^4.4.0", "styled-components": "^4.4.0",
"webpack": "^5.88.2",
"yaml": "^1.7.2", "yaml": "^1.7.2",
"yamljs": "^0.3.0", "yamljs": "^0.3.0",
"zone.js": "^0.13.1", "zone.js": "^0.13.1"
"webpack": "^5.88.2"
}, },
"scripts": { "scripts": {
"start": "HTTPS=false&&PORT=3000 GENERATE_SOURCEMAP=false react-scripts --openssl-legacy-provider start", "start": "HTTPS=false&&PORT=3000 GENERATE_SOURCEMAP=false react-scripts --openssl-legacy-provider start",
+33 -20
View File
@@ -6,6 +6,8 @@ import { useParams, useNavigate, Link } from "react-router-dom";
import { isMobile } from "react-device-detect"; import { isMobile } from "react-device-detect";
import theme from '../theme.jsx'; import theme from '../theme.jsx';
import remarkGfm from 'remark-gfm' import remarkGfm from 'remark-gfm'
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import { import {
Grid, Grid,
@@ -19,6 +21,9 @@ import {
Typography, Typography,
Paper, Paper,
List, List,
Collapse,
ListItemButton,
ListItemText
} from "@mui/material"; } from "@mui/material";
import { import {
@@ -78,6 +83,7 @@ const Docs = (defaultprops) => {
const [data, setData] = useState(""); const [data, setData] = useState("");
const [firstrequest, setFirstrequest] = useState(true); const [firstrequest, setFirstrequest] = useState(true);
const [list, setList] = useState([]); const [list, setList] = useState([]);
const [isopen, setOpen] = useState(-1);
const [, setListLoaded] = useState(false); const [, setListLoaded] = useState(false);
const [anchorEl, setAnchorEl] = React.useState(null); const [anchorEl, setAnchorEl] = React.useState(null);
const [headingSet, setHeadingSet] = React.useState(false); const [headingSet, setHeadingSet] = React.useState(false);
@@ -98,11 +104,16 @@ const Docs = (defaultprops) => {
setAnchorEl(null); setAnchorEl(null);
} }
const handleCollapse = (index) => {
setOpen(isopen === index ? -1 : index)
};
const SidebarPaperStyle = { const SidebarPaperStyle = {
backgroundColor: theme.palette.surfaceColor, backgroundColor: theme.palette.surfaceColor,
overflowX: "hidden", overflowX: "hidden",
position: "relative", position: "relative",
padding: 30, paddingLeft: 15,
paddingRight: 15,
paddingTop: 15, paddingTop: 15,
marginTop: 15, marginTop: 15,
minHeight: "80vh", minHeight: "80vh",
@@ -110,8 +121,8 @@ const Docs = (defaultprops) => {
}; };
const SideBar = { const SideBar = {
minWidth: 250, minWidth: 300,
maxWidth: 300, width: "20%",
left: 0, left: 0,
position: "sticky", position: "sticky",
top: 50, top: 50,
@@ -724,6 +735,7 @@ const Docs = (defaultprops) => {
*/} */}
</div> </div>
// PostDataBrowser Section
const postDataBrowser = const postDataBrowser =
list === undefined || list === null ? null : ( list === undefined || list === null ? null : (
<div style={Body}> <div style={Body}>
@@ -743,50 +755,51 @@ const Docs = (defaultprops) => {
const itemMatching = props.match.params.key === undefined ? false : const itemMatching = props.match.params.key === undefined ? false :
props.match.params.key.toLowerCase() === item.toLowerCase(); props.match.params.key.toLowerCase() === item.toLowerCase();
//const [tocLines, setTocLines] = React.useState([]);
return ( return (
<li key={index} style={{ marginTop: 10 }}> <li key={index}>
<Link <ListItemButton
component={Link}
key={index} key={index}
style={hrefStyle} style={hrefStyle}
to={path} to={path}
onClick={() => { onClick={() => {
setTocLines([]); setTocLines([]);
fetchDocs(item); fetchDocs(item);
handleCollapse(index);
}} }}
> >
<Typography <ListItemText
style={{ color: itemMatching ? "#f86a3e" : "inherit" }} style={{ color: itemMatching ? "#f86a3e" : "inherit" }}
variant="body1" variant="body1"
> >
<b>> {newname}</b> {newname}
</Typography> </ListItemText>
</Link> {isopen === index ? <ExpandMoreIcon /> : <KeyboardArrowRightIcon />}
</ListItemButton>
{itemMatching && {itemMatching &&
tocLines !== null && tocLines !== null &&
tocLines !== undefined && tocLines !== undefined &&
tocLines.length > 0 ? ( tocLines.length > 0 ? (
<div style={{ marginLeft: 5 }}> <Collapse in={isopen === index} timeout="auto" unmountOnExit>
{tocLines.map((data, index) => { {tocLines.map((data, index) => {
//console.log(data)
return ( return (
<Link <ListItemButton
component={Link}
key={index} key={index}
style={innerHrefStyle} style={innerHrefStyle}
to={data.link} to={data.link}
onClick={() => {}}
> >
<Typography <ListItemText
variant="body2" variant="body2"
style={{ cursor: "pointer" }} style={{ cursor: "pointer" }}
> >
- {data.text} {data.text}
</Typography> </ListItemText>
</Link> </ListItemButton>
); );
})} })}
</div> </Collapse>
) : null} ) : null}
</li> </li>
); );
@@ -794,7 +807,7 @@ const Docs = (defaultprops) => {
</List> </List>
</Paper> </Paper>
</div> </div>
<div style={{maxWidth: 750, minWidth: 750, margin: "auto", overflow: "hidden", marginTop: 50, }}> <div style={{ width: "70%", margin: "auto", overflow: "hidden", marginTop: 50, paddingRight: 50 }}>
{props.match.params.key === undefined ? {props.match.params.key === undefined ?
mainpageInfo mainpageInfo
: :