Skip to content

Commit

Permalink
Merge branch 'main' into update-gist
Browse files Browse the repository at this point in the history
  • Loading branch information
magland committed Jul 30, 2024
2 parents ad27ddd + f0c7de1 commit e0b18fa
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 49 deletions.
101 changes: 54 additions & 47 deletions gui/src/app/pages/HomePage/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { ProjectContext } from "@SpCore/ProjectContextProvider";
import LoadProjectWindow from "@SpPages/LoadProjectWindow";
import SaveProjectWindow from "@SpPages/SaveProjectWindow";
import ModalWindow, { useModalWindow } from "@fi-sci/modal-window";
import { List, ListItem } from "@mui/material";
import Button from "@mui/material/Button";
import Divider from "@mui/material/Divider";
import Drawer from "@mui/material/Drawer";
import List from "@mui/material/List";
import ListItem from "@mui/material/ListItem";
import Toolbar from "@mui/material/Toolbar";
import { FunctionComponent, useContext } from "react";
import { Link } from "react-router-dom";
Expand All @@ -27,7 +26,7 @@ const exampleLinks = [
},
];

export const drawerWidth = 240;
export const drawerWidth = 180;

const Sidebar: FunctionComponent<Sidebar> = ({
hasUnsavedChanges,
Expand Down Expand Up @@ -62,53 +61,61 @@ const Sidebar: FunctionComponent<Sidebar> = ({
{/* For spacing purposes */}
<Toolbar />

<h3>Examples</h3>
<div className="Sidebar">
<h3>Examples</h3>

{exampleLinks.map((example, i) => (
<div key={i} className="SidebarContentWrapper">
<Link replace to={`?project=${example.link}`}>
{example.name}
</Link>
</div>
))}
<Divider />
<List>
<ListItem>
<Button
variant="outlined"
onClick={loadProjectOpen}
disabled={hasUnsavedChanges}
>
Load project
</Button>
</ListItem>
<List>
{exampleLinks.map((example, i) => (
<ListItem key={i}>
<Link replace to={`?project=${example.link}`}>
{example.name}
</Link>
</ListItem>
))}
</List>

<Divider />

<List>
<ListItem key="load-project">
<Button
variant="outlined"
onClick={loadProjectOpen}
disabled={hasUnsavedChanges}
>
Load project
</Button>
</ListItem>

<ListItem key="save-project">
<Button
variant="outlined"
onClick={saveProjectOpen}
disabled={hasUnsavedChanges}
>
Save project
</Button>
</ListItem>

<ListItem>
<Button
variant="outlined"
onClick={saveProjectOpen}
disabled={hasUnsavedChanges}
>
Save project
</Button>
</ListItem>
<ListItem>
{/* This will probably be removed or replaced in the future. It's just for convenience during development. */}
<Button
variant="outlined"
color="error"
onClick={() => {
const ok = window.confirm(
"Are you sure you want to clear all data in the editors?",
);
if (!ok) return;
update({ type: "clear" });
}}
>
Clear all
</Button>
</ListItem>
</List>
<ListItem key="clear-all">
<Button
variant="outlined"
color="error"
onClick={() => {
const ok = window.confirm(
"Are you sure you want to clear all data in the editors?",
);
if (!ok) return;
update({ type: "clear" });
}}
>
Clear all
</Button>
</ListItem>
</List>
</div>

<ModalWindow visible={loadProjectVisible} onClose={loadProjectClose}>
<LoadProjectWindow onClose={loadProjectClose} />
</ModalWindow>
Expand Down
14 changes: 12 additions & 2 deletions gui/src/localStyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@
}

/* Sidebar */
.SidebarContentWrapper {
margin: 5px;
.Sidebar h3 {
padding: 0px;
margin-left: 12px;
margin-bottom: 0px;
margin-top: 0px;
}

.Sidebar li {
margin-left: 12px;
margin-top: 0px;
margin-bottom: 5px;
padding: 0px;
}

/* File Upload */
Expand Down

0 comments on commit e0b18fa

Please sign in to comment.