frontpage/components/Blog/Navigation.tsx

40 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-10-03 01:19:43 +02:00
/* eslint-disable @next/next/no-img-element */
2022-09-30 16:14:30 +02:00
import type { NextPage } from "next";
2022-10-03 01:19:43 +02:00
import Link from "next/link";
2022-10-16 00:05:44 +02:00
import { Terminal, Sun, Moon } from "phosphor-react";
2022-10-03 01:19:43 +02:00
import styles from "../../styles/Blog/Navigation.module.scss";
2022-09-30 16:14:30 +02:00
const Navigation: NextPage<{}> = () => {
2022-10-16 00:05:44 +02:00
const switchTheme = () => {
if (typeof document === "undefined") return;
const current = document.documentElement.getAttribute("data-theme") || "dark";
const setTo = current === "dark" ? "light" : "dark";
document.documentElement.setAttribute("data-theme", setTo);
if (typeof window !== "undefined") window.localStorage.setItem("theme", setTo);
};
2022-10-03 01:19:43 +02:00
return <nav className={styles.navigation}>
2022-10-08 14:07:56 +02:00
<Link href={"/"}>
2022-10-16 00:05:44 +02:00
<a className={`nostyle ${styles.imgContainer}`}>
2022-10-08 14:07:56 +02:00
<picture>
<source srcSet="/icon.png" type="image/png" />
<img src="/icon.png" alt={"Website icon, a red eye"} className={styles.logo} />
</picture>
</a>
2022-10-03 01:19:43 +02:00
</Link>
2022-10-16 00:05:44 +02:00
<div className={styles.navLink}><Link href={"/"}><a className="nostyle">Projects</a></Link></div>
<div className={styles.navLink}><Link href={"/"}><a className="nostyle">About me</a></Link></div>
<div className={styles.spacer}></div>
<Terminal size={"1.5em"} />
<div className={styles.themeSwitch}>
<Sun className={styles.lightTheme} size={"1.5em"} onClick={switchTheme} />
<Moon className={styles.darkTheme} size={"1.5em"} onClick={switchTheme} />
</div>
2022-09-30 19:23:14 +02:00
</nav>;
2022-09-30 16:14:30 +02:00
};
export default Navigation;