Skip to content

Commit 13d7ee6

Browse files
author
Vianpyro
committed
Refactor header structure and move navigation to JavaScript
1 parent 32249e9 commit 13d7ee6

File tree

3 files changed

+50
-26
lines changed

3 files changed

+50
-26
lines changed

authentication.html

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@
1010
</head>
1111

1212
<body>
13-
<header>
14-
<h1>Smart Cooking &copy;</h1>
15-
<nav>
16-
<a id="home" title="Home">
17-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
18-
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
19-
<path d="M5 12H3l9-9l9 9h-2M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-7" />
20-
<path d="M9 21v-6a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v6" />
21-
</g>
22-
</svg>
23-
</a>
24-
</nav>
25-
</header>
13+
<header></header>
2614

2715
<main>
2816
<section id="login">
@@ -61,6 +49,7 @@ <h1>Smart Cooking &copy;</h1>
6149

6250
<footer id="footer-copyright"></footer>
6351

52+
<script src="javascript/header.js" defer></script>
6453
<script src="javascript/main.js"></script>
6554
<script src="javascript/authentication.js" defer></script>
6655
<script src="javascript/footer.js" defer></script>

javascript/header.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const header = document.querySelector("header");
2+
3+
const h1 = document.createElement("h1");
4+
h1.innerHTML = "Smart Cooking &copy;";
5+
6+
const nav = document.createElement("nav");
7+
8+
const a = document.createElement("a");
9+
a.id = "home";
10+
a.title = "Home";
11+
12+
function createHomeIcon() {
13+
const svgNS = "http://www.w3.org/2000/svg"; // SVG namespace
14+
15+
// Create the SVG element
16+
const svg = document.createElementNS(svgNS, 'svg');
17+
svg.setAttribute('xmlns', svgNS);
18+
svg.setAttribute('viewBox', '0 0 24 24');
19+
20+
// Create the path element
21+
const path1 = document.createElementNS(svgNS, 'path');
22+
const path2 = document.createElementNS(svgNS, 'path');
23+
path1.setAttribute('fill', 'none');
24+
path2.setAttribute('fill', 'none');
25+
path1.setAttribute('stroke-linecap', 'round');
26+
path2.setAttribute('stroke-linecap', 'round');
27+
path1.setAttribute('stroke-linejoin', 'round');
28+
path2.setAttribute('stroke-linejoin', 'round');
29+
path1.setAttribute('stroke-width', '2');
30+
path2.setAttribute('stroke-width', '2');
31+
path1.setAttribute("d", "M5 12H3l9-9l9 9h-2M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-7");
32+
path2.setAttribute("d", "M9 21v-6a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v6");
33+
34+
// Append the path to the SVG
35+
svg.appendChild(path1);
36+
svg.appendChild(path2);
37+
38+
return svg;
39+
}
40+
41+
const homeIcon = createHomeIcon();
42+
43+
a.appendChild(homeIcon);
44+
nav.appendChild(a);
45+
header.appendChild(h1);
46+
header.appendChild(nav);

profile.html

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,15 @@
1111
</head>
1212

1313
<body>
14-
<header>
15-
<h1>Smart Cooking &copy;</h1>
16-
<nav>
17-
<a id="home" title="Home">
18-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
19-
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
20-
<path d="M5 12H3l9-9l9 9h-2M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-7" />
21-
<path d="M9 21v-6a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v6" />
22-
</g>
23-
</svg>
24-
</a>
25-
</nav>
26-
</header>
14+
<header></header>
2715

2816
<main>
2917
<button id="logout">Logout</button>
3018
</main>
3119

3220
<footer id="footer-copyright"></footer>
3321

22+
<script src="javascript/header.js"></script>
3423
<script src="javascript/main.js"></script>
3524
<script src="javascript/profile.js" defer></script>
3625
<script src="javascript/footer.js" defer></script>

0 commit comments

Comments
 (0)