Skip to content

Commit ae90e2d

Browse files
committed
Navbar
1 parent 31e691e commit ae90e2d

File tree

11 files changed

+125
-19
lines changed

11 files changed

+125
-19
lines changed

gatsby-browser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// custom typefaces
2-
import "@fontsource/jetbrains-mono"
2+
import "@fontsource/jetbrains-mono/400.css"
3+
import "@fontsource/jetbrains-mono/200.css"
34
// normalize CSS across browsers
45
import "./src/normalize.css"
5-
6+
import "./src/global.css"
67
// Highlighting for code blocks
78
import "prismjs/themes/prism.css"

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"@fontsource/jetbrains-mono": "^5.2.5",
12+
"classnames": "^2.5.1",
1213
"gatsby": "^5.14.1",
1314
"gatsby-plugin-feed": "^5.14.0",
1415
"gatsby-plugin-image": "^3.14.0",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.wrapper {
2+
background-color: var(--color-dark);
3+
background-image: url('../../images/bg-light.svg'), url('../../images/noise.jpg');
4+
background-repeat: no-repeat, repeat;
5+
background-position: top center, center center;
6+
min-height: 100%;
7+
}

src/components/Layout/Layout.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Link } from "gatsby"
22
import * as React from "react"
3+
import * as styles from "./Layout.module.css"
4+
import Navbar from "../Navbar/Navbar"
35

46
interface LayoutProps {
57
location: Location
@@ -10,25 +12,10 @@ interface LayoutProps {
1012
const Layout = ({ location, title, children }: LayoutProps) => {
1113
const rootPath = `/`
1214
const isRootPath = location.pathname === rootPath
13-
let header
14-
15-
if (isRootPath) {
16-
header = (
17-
<h1 className="main-heading">
18-
<Link to="/">{title}</Link>
19-
</h1>
20-
)
21-
} else {
22-
header = (
23-
<Link className="header-link-home" to="/">
24-
home
25-
</Link>
26-
)
27-
}
2815

2916
return (
30-
<div className="global-wrapper" data-is-root-path={isRootPath}>
31-
<header className="global-header">{header}</header>
17+
<div className={styles.wrapper} data-is-root-path={isRootPath}>
18+
<Navbar location={location} />
3219
<main>{children}</main>
3320
</div>
3421
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.navbar {
2+
width: 100%;
3+
}
4+
5+
.navbar ul {
6+
margin: 0;
7+
padding: 28px 0;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
gap: 0 80px;
12+
}
13+
14+
.navbar li {
15+
list-style: none;
16+
display: block;
17+
}
18+
19+
.navbar li a {
20+
text-decoration: none;
21+
color: white;
22+
font-size: 18px;
23+
font-weight: 200;
24+
}
25+
26+
.navbar li a.active {
27+
text-decoration: underline;
28+
text-decoration-color: var(--color-primary);
29+
text-underline-offset: 3px;
30+
}
31+

src/components/Navbar/Navbar.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import * as React from "react"
2+
import * as styles from "./Navbar.module.css"
3+
import { Link } from "gatsby"
4+
import classNames from "classnames";
5+
6+
interface NavbarProps {
7+
location: Location
8+
}
9+
10+
const items = [{
11+
name: "Home",
12+
link: "/"
13+
}, {
14+
name: "Experience",
15+
link: "#experience"
16+
}, {
17+
name: "Blog",
18+
link: "/blog"
19+
}, {
20+
name: "Projects",
21+
link: "#projects"
22+
}];
23+
24+
const Navbar = ({ location }: NavbarProps) => {
25+
return (
26+
<nav className={styles.navbar}>
27+
<ul>
28+
{items.map(item => (
29+
<li key={item.name}>
30+
<Link to={item.link} className={classNames({
31+
[styles.active]: item.link.startsWith("/") && location.pathname === item.link
32+
})}>{item.name}</Link>
33+
</li>
34+
))}
35+
</ul>
36+
</nav>
37+
)
38+
}
39+
40+
export default Navbar

src/global.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
html,
2+
body,
3+
#___gatsby,
4+
#gatsby-focus-wrapper {
5+
width: 100%;
6+
height: 100%;
7+
margin: 0;
8+
padding: 0;
9+
overflow-x: hidden;
10+
}
11+
12+
:root {
13+
--color-white: #fff;
14+
--color-dark: #17131b;
15+
--color-light: #c2bcc9;
16+
--color-primary: #a652da;
17+
--color-secondary: #4c3c60;
18+
}
19+
20+
body {
21+
font-family: "JetBrains Mono", monospace;
22+
color: white;
23+
}

src/global.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.css' {
2+
const classes: { [key: string]: string };
3+
export = classes;
4+
}

src/images/bg-light.svg

Lines changed: 1 addition & 0 deletions
Loading

src/images/noise.jpg

8.74 KB
Loading

0 commit comments

Comments
 (0)