|
| 1 | +const header = document.querySelector("header"); |
| 2 | + |
| 3 | +const h1 = document.createElement("h1"); |
| 4 | +h1.innerHTML = "Smart Cooking ©"; |
| 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); |
0 commit comments