Skip to content

Commit d48962b

Browse files
committed
feat: [#87] top navigation in place
1 parent ea7b35c commit d48962b

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

src/components/top-nav/index.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1-
type NavLinkItem = [
1+
import './styles.css';
2+
3+
type LinkItem = [
24
name: string,
35
path: string,
46
]
57

6-
const navLinks: NavLinkItem[] = [
8+
const navLinks: LinkItem[] = [
79
['Side Quests', '/projects'],
810
['About', '/about'],
911
['Logs', '/logs'],
1012
['Contact', '/contact'],
1113
]
1214

15+
//-----------------------------------------------------------------------
16+
1317
export function buildTopNav() {
1418
const navBox = document.createElement("div");
1519
const ul = document.createElement("ul");
1620

21+
navBox.id = "top-nav";
22+
23+
navLinks.forEach(link => {
24+
const [name, path] = link;
25+
const li = document.createElement("li");
26+
const a = document.createElement("a");
1727

28+
a.href = path;
29+
a.textContent = name;
1830

31+
li.appendChild(a);
32+
ul.appendChild(li);
33+
})
1934

35+
navBox.appendChild(ul);
36+
return navBox
2037
}

src/components/top-nav/styles.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#top-nav {
2+
position: fixed;
3+
top: 40px;
4+
left: 50%;
5+
transform: translateX(-50%);
6+
display: flex;
7+
text-align: center;
8+
padding: 0 50px;
9+
z-index: 10;
10+
11+
ul {
12+
display: flex;
13+
align-items: center;
14+
justify-content: space-between;
15+
gap: 50px;
16+
height: 60px;
17+
margin: 0;
18+
padding: 0 35px;
19+
list-style: none;
20+
21+
border: 2px solid rgba(255, 255, 255, 0.1);
22+
border-radius: 30px;
23+
background-color: rgba(255, 255, 255, 0.05);
24+
25+
backdrop-filter: blur(30px);
26+
-webkit-backdrop-filter: blur(30px);
27+
overflow: hidden;
28+
}
29+
30+
li a {
31+
font-family: "Handjet", sans-serif;
32+
font-size: 1.5em;
33+
font-weight: 500;
34+
text-transform: lowercase;
35+
text-decoration: none;
36+
color: #ffffff;
37+
cursor: pointer;
38+
transition: color 0.3s ease;
39+
40+
&:hover {
41+
color: #3BFFC5;
42+
}
43+
}
44+
}

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildMainLogo } from "./components/logo";
22
import { router } from "./core/router";
33
import {homeView, buildViewBase, renderView} from "./views";
4+
import {buildTopNav} from "./components/top-nav";
45

56

67
const routes = [
@@ -15,8 +16,10 @@ function init() {
1516
const body = document.getElementsByTagName("body")[0];
1617
const contentPage = buildViewBase();
1718
const mainLogo = buildMainLogo();
19+
const nav = buildTopNav();
1820

1921
body.appendChild(mainLogo);
22+
body.appendChild(nav);
2023
body.appendChild(contentPage);
2124

2225

0 commit comments

Comments
 (0)