Skip to content

Commit

Permalink
Add header to all pages
Browse files Browse the repository at this point in the history
Also add placeholder publications and about pages

Closes #33
  • Loading branch information
HDash committed Feb 3, 2025
1 parent 6f73608 commit ad9d898
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 6 deletions.
4 changes: 4 additions & 0 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import PhenotypePage from "./pages/PhenotypePage";
import CelltypePage from "./pages/CelltypePage";
import GenePage from "./pages/GenePage";
import SeverityPage from "./pages/SeverityPage";
import PublicationsPage from "./pages/PublicationsPage";
import AboutPage from "./pages/AboutPage";

function App() {
return (
Expand All @@ -19,6 +21,8 @@ function App() {
element={<SeverityPage />}
/>
<Route path="/severity" element={<SeverityPage />} />
<Route path="/publications" element={<PublicationsPage />} />
<Route path="/about" element={<AboutPage />} />
</Routes>
</BrowserRouter>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/HomeOption.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function HomeOption() {
minWidth="250px"
/>
<VioletButton
name="Search by CellType"
name="Search by Cell Type"
path="/celltype"
minWidth="250px"
/>
Expand Down
130 changes: 130 additions & 0 deletions frontend/src/components/utilities/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import React, { useState } from "react";
import { ConfigProvider, Layout, Menu } from "antd";
import { useNavigate } from "react-router-dom";

const { Header } = Layout;

const items = [
{
key: "home",
label: "Home",
path: "/"
},
{
key: "search",
label: "Search",
children: [
{
key: "phenotype",
label: "By Phenotype",
path: "/phenotype"
},
{
key: "celltype",
label: "By Cell Type",
path: "/celltype"
},
{
key: "gene",
label: "By Gene",
path: "/gene"
},
{
key: "severity",
label: "By Severity",
path: "/severity"
},
],
},
{
key: "publications",
label: "Publications",
path: "/publications"
},
{
key: "about",
label: "About",
path: "/about"
},
];

const CustomHeader = ({ activePageKey }) => {
const [selectedKey, setSelectedKey] = useState(activePageKey);
const navigate = useNavigate();

const handleMenuClick = (e) => {
setSelectedKey(e.key);
const item = findMenuItemByKey(items, e.key);
console.log(item);
if (item && item.path) {
navigate(item.path);
}
}

const findMenuItemByKey = (menuItems, key) => {
for (const item of menuItems) {
if (item.key === key) {
return item;
}
if (item.children) {
const childItem = findMenuItemByKey(item.children, key);
if (childItem) {
return childItem;
}
}
}
return null;
};

return (
<ConfigProvider
theme={{
components: {
Menu: {
darkItemColor: "#000",
darkItemSelectedBg: "#8b5cf6",
darkSubMenuItemBg: "#fff",
darkPopupBg: "#fff",
subMenuItemBg: "#fff",
subMenuItemSelectedColor: "#fff",
darkItemHoverColor: "#8b5cf6",
},
Layout: {
headerHeight: "3.2em",
}
},
}}
>
<Header
style={{
background: "#fff",
padding: 0,
display: "flex",
alignItems: "center",
position: "relative",
}}
theme="light"
>
<p style={{ textAlign: "center", marginLeft: "2em" }}>
Neurogenomics Lab
</p>
<Menu
theme="dark"
mode="horizontal"
selectedKeys={[selectedKey]}
items={items}
className="header-menu"
onClick={handleMenuClick}
style={{
position: "absolute",
left: "50%",
transform: "translateX(-50%)",
background: "#fff",
}}
/>
</Header>
</ConfigProvider>
);
};

export default CustomHeader;
14 changes: 14 additions & 0 deletions frontend/src/pages/AboutPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import CustomHeader from "../components/utilities/Header";

export default function AboutPage() {
return (
<>
<CustomHeader activePageKey="about" />
<div>
<h1>About</h1>
<p>Coming soon...</p>
</div>
</>
);
}
6 changes: 5 additions & 1 deletion frontend/src/pages/CelltypePage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from "react";
import PhenotypeTree from "../components/CellTree.jsx";
import CustomHeader from "../components/utilities/Header.jsx";
import CustomFooter from "../components/utilities/Footer.jsx";
import axios from "axios";
import {
Expand Down Expand Up @@ -581,6 +582,8 @@ export default function CelltypePage() {
}, []);

return (
<>
<CustomHeader activePageKey="celltype" />
<Layout
style={{
minHeight: "100vh",
Expand Down Expand Up @@ -684,7 +687,7 @@ export default function CelltypePage() {
}}
>
<Breadcrumb.Item href={"/"}>Home</Breadcrumb.Item>
<Breadcrumb.Item>CellType</Breadcrumb.Item>
<Breadcrumb.Item>Search by Cell Type</Breadcrumb.Item>
</Breadcrumb>
<Card
style={{
Expand Down Expand Up @@ -794,5 +797,6 @@ export default function CelltypePage() {
<CustomFooter />
</Layout>
</Layout>
</>
);
}
8 changes: 6 additions & 2 deletions frontend/src/pages/GenePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PhenotypeTableDisease2 from "../components/GeneTable2.jsx";
import CustomFooter from "../components/utilities/Footer.jsx";
import NotFound from "../components/utilities/Texts.jsx";
import { LaunchOutlined, SettingsOutlined } from "@mui/icons-material";
import CustomHeader from "../components/utilities/Header.jsx";

const { Header, Content, Sider } = Layout;

Expand Down Expand Up @@ -182,6 +183,8 @@ export default function phenotypePage() {
];

return (
<>
<CustomHeader activePageKey="gene" />
<Layout
style={{
minHeight: "100vh",
Expand Down Expand Up @@ -241,7 +244,7 @@ export default function phenotypePage() {
}}
>
<Breadcrumb.Item href={"/"}>Home</Breadcrumb.Item>
<Breadcrumb.Item>Gene</Breadcrumb.Item>
<Breadcrumb.Item>Search by Gene</Breadcrumb.Item>
</Breadcrumb>
<Card
style={{
Expand All @@ -252,7 +255,7 @@ export default function phenotypePage() {
Genes are linked to cell types and phenotypes,
revealing their role in rare diseases. This page
provides visualizations of gene-cell
typegene-diseaseand gene-phenotype
type, gene-disease, and gene-phenotype
relationships.
</p>
</Card>
Expand Down Expand Up @@ -342,5 +345,6 @@ export default function phenotypePage() {
<CustomFooter />
</Layout>
</Layout>
</>
);
}
2 changes: 2 additions & 0 deletions frontend/src/pages/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import BackgroundAnimation from "../components/BackgroundAnimation";
import HomeOption from "../components/HomeOption";
import Header from "../components/utilities/Header";

export default function HomePage() {
return (
<>
<Header activePageKey="home" />
<BackgroundAnimation />
<HomeOption />
</>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/pages/PhenotypePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import PhenotypeTableDisease from "../components/PhenotypeTableDisease.jsx";
import PhenotypeTableDisease1 from "../components/PhenotypeTableDisease1.jsx";
import PhenotypeTableDisease2 from "../components/PhenotypeTableDisease2.jsx";
import { BASE_API_URL, ONTOLOGY_API_URL } from "../../config.js";
import CustomHeader from "../components/utilities/Header.jsx";
import CustomFooter from "../components/utilities/Footer.jsx";
import NotFound from "../components/utilities/Texts.jsx";
import { SettingsOutlined } from "@mui/icons-material";
Expand Down Expand Up @@ -227,6 +228,8 @@ export default function phenotypePage() {
];

return (
<>
<CustomHeader activePageKey="phenotype" />
<Layout
style={{
minHeight: "100vh",
Expand Down Expand Up @@ -286,7 +289,7 @@ export default function phenotypePage() {
}}
>
<Breadcrumb.Item href={"/"}>Home</Breadcrumb.Item>
<Breadcrumb.Item>Phenotype</Breadcrumb.Item>
<Breadcrumb.Item>Search by Phenotype</Breadcrumb.Item>
</Breadcrumb>
<Card
style={{
Expand Down Expand Up @@ -386,5 +389,6 @@ export default function phenotypePage() {
<CustomFooter />
</Layout>
</Layout>
</>
);
}
14 changes: 14 additions & 0 deletions frontend/src/pages/PublicationsPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import CustomHeader from "../components/utilities/Header";

export default function PublicationsPage() {
return (
<>
<CustomHeader activePageKey="publications" />
<div>
<h1>Publications</h1>
<p>Coming soon...</p>
</div>
</>
);
}
6 changes: 5 additions & 1 deletion frontend/src/pages/SeverityPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
import SeveritySlider from "../components/SeveritySlider.jsx";
import SeveritySlider1 from "../components/SeveritySlider1.jsx";
import SeverityNetWork from "../components/SeverityNetWork.jsx";
import CustomHeader from "../components/utilities/Header.jsx";
import CustomFooter from "../components/utilities/Footer.jsx";
import axios from "axios";
import {
Expand Down Expand Up @@ -476,6 +477,8 @@ export default function SeverityPage() {
];

return (
<>
<CustomHeader activePageKey="severity" />
<Layout
style={{
minHeight: "100vh",
Expand Down Expand Up @@ -668,7 +671,7 @@ export default function SeverityPage() {
}}
>
<Breadcrumb.Item href={"/"}>Home</Breadcrumb.Item>
<Breadcrumb.Item>Severity</Breadcrumb.Item>
<Breadcrumb.Item>Search by Severity</Breadcrumb.Item>
</Breadcrumb>

<Card
Expand Down Expand Up @@ -729,5 +732,6 @@ export default function SeverityPage() {
<CustomFooter />
</Layout>
</Layout>
</>
);
}

0 comments on commit ad9d898

Please sign in to comment.