Skip to content
Snippets Groups Projects
Commit 1617a062 authored by danieldeng2's avatar danieldeng2
Browse files

Add support for external links in sidebars

parent fef3e892
No related branches found
No related tags found
No related merge requests found
...@@ -11,8 +11,9 @@ export interface SideBarTabGroupProp { ...@@ -11,8 +11,9 @@ export interface SideBarTabGroupProp {
buttons: { buttons: {
title: string; title: string;
icon?: IconDefinition; icon?: IconDefinition;
active?: boolean; active?: boolean;
activeURL?: string; activeURL?: string;
externalURL?: string;
}[]; }[];
} }
...@@ -20,38 +21,54 @@ const SideBarTabGroup: React.FC<SideBarTabGroupProp> = ({ ...@@ -20,38 +21,54 @@ const SideBarTabGroup: React.FC<SideBarTabGroupProp> = ({
title, title,
buttons, buttons,
}: SideBarTabGroupProp) => { }: SideBarTabGroupProp) => {
let displayButtons = buttons.map(({ title, icon, active, activeURL }) => { let displayButtons = buttons.map(
let FAicon; ({ title, icon, active, activeURL, externalURL }) => {
if (icon) { let FAicon;
FAicon = ( if (icon) {
<FontAwesomeIcon className={styles.tabGroupButtonSvg} icon={icon} /> FAicon = (
); <FontAwesomeIcon className={styles.tabGroupButtonSvg} icon={icon} />
} );
if (activeURL !== undefined){ }
return ( if (activeURL !== undefined) {
<Button return (
as={NavLink} <Button
to={activeURL} as={NavLink}
activeClassName={"active"} to={activeURL}
className={styles.tabGroupButton} activeClassName={"active"}
key={title} className={styles.tabGroupButton}
> key={title}
{title} >
{FAicon} {title}
</Button> {FAicon}
); </Button>
} );
}
return ( if (externalURL !== undefined) {
<Button return (
className={classNames({ active: active }, styles.tabGroupButton)} <Button
key={title} href={externalURL}
> target="_blank"
{title} className={styles.tabGroupButton}
{FAicon} key={title}
</Button> >
); {title}
}); {FAicon}
</Button>
);
}
return (
<Button
className={classNames({ active: active }, styles.tabGroupButton)}
key={title}
>
{title}
{FAicon}
</Button>
);
}
);
return ( return (
<> <>
......
...@@ -2,25 +2,34 @@ import React from "react"; ...@@ -2,25 +2,34 @@ import React from "react";
import LeftBar from "components/organisms/LeftBar"; import LeftBar from "components/organisms/LeftBar";
import SideBarTabGroup from "components/molecules/SideBarTabGroup"; import SideBarTabGroup from "components/molecules/SideBarTabGroup";
import { faGitlab } from "@fortawesome/free-brands-svg-icons"; import { faGitlab } from "@fortawesome/free-brands-svg-icons";
import { faFlask, faAward, faDatabase } from "@fortawesome/free-solid-svg-icons"; import { faFlask, faAward, faDatabase, faEnvelopeOpen } from "@fortawesome/free-solid-svg-icons";
const LeftBarHome: React.FC = () => { const LeftBarHome: React.FC = () => {
let linkButtons = [ let linkButtons = [
{ {
title: "GitLab", title: "GitLab",
icon: faGitlab, icon: faGitlab,
externalURL: "https://gitlab.doc.ic.ac.uk/",
}, },
{ {
title: "LabTS", title: "Outlook",
icon: faFlask, icon: faEnvelopeOpen,
externalURL: "https://outlook.office.com/",
}, },
{ {
title: "DocPA", title: "DocPA",
icon: faAward, icon: faAward,
externalURL: "https://docpa.doc.ic.ac.uk/",
},
{
title: "LabTS",
icon: faFlask,
externalURL: "https://teaching.doc.ic.ac.uk/labts",
}, },
{ {
title: "teachDB", title: "teachDB",
icon: faDatabase, icon: faDatabase,
externalURL: "https://teachdb.doc.ic.ac.uk/db/",
}, },
]; ];
......
...@@ -2,31 +2,49 @@ import React from "react"; ...@@ -2,31 +2,49 @@ import React from "react";
import LeftBar from "components/organisms/LeftBar"; import LeftBar from "components/organisms/LeftBar";
import SideBarTabGroup from "components/molecules/SideBarTabGroup"; import SideBarTabGroup from "components/molecules/SideBarTabGroup";
import { faDiscourse } from "@fortawesome/free-brands-svg-icons"; import { faDiscourse } from "@fortawesome/free-brands-svg-icons";
import { useParams } from "react-router-dom";
const LeftBarModule: React.FC = () => { const LeftBarModule: React.FC = () => {
let outlineButtons = [ let { id } = useParams();
let piazzaClasses: {
[index: string]: string;
} = {
CO140: "k0r3c04qwhj3e",
CO142: "k0r3c156mj35b",
CO112: "k0r3by316kp6",
CO145: "k0r3c1h4zik5y",
};
let piazzaLink = "https://piazza.com/class/";
if (piazzaClasses[id] !== undefined && piazzaClasses[id]) {
piazzaLink += piazzaClasses[id];
}
let outlineButtons = [
{ {
title: "Overview", title: "Overview",
activeURL: "overview", activeURL: "overview",
}, },
{ {
title: "Coursework", title: "Coursework",
activeURL: "coursework", activeURL: "coursework",
}, },
{ {
title: "Materials", title: "Materials",
activeURL: "materials", activeURL: "materials",
}, },
{ {
title: "Piazza", title: "Piazza",
icon: faDiscourse, icon: faDiscourse,
}, externalURL: piazzaLink,
},
]; ];
return ( return (
<LeftBar> <LeftBar>
<SideBarTabGroup title="Outline" buttons={outlineButtons} /> <SideBarTabGroup title="Outline" buttons={outlineButtons} />
</LeftBar> </LeftBar>
); );
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment