css(` nav-bar { position: fixed; top: 0px; left: 0px; width: 100vw; z-index: 1; height: 100px; } .title-div { position: absolute; left: 2em; top: 2em; display: flex; align-items: center; } .links-div { position: absolute; right: 3em; top: 2.75em; display: flex; } .logo-p { font-size: 2em; margin: 0 0 0 15px; letter-spacing: 1px; text-align: center; } .nav-hamburger { margin-right: 8vw; display: none; max-height:40px; } .nav-link { font-size: 1em; margin: 0 0 0 15px; letter-spacing: 1px; } @media only screen and (max-width: 820px) { nav-bar a { text-decoration: none; color: var(--green); } .title-div { position: static } .logo { width: 10vw; } .logo-p { font-size: 8vw; margin: 0 0 0 1vw; } .nav-hamburger { display: block; } .links-div { display:none; } .outer-nav { position: fixed; left: 0; top: 0; width: 100%; height: 20vw; background: var(--tan); display: flex; z-index: 1; justify-content: space-between; align-items: center; padding: 0 3vw; max-height:80px; } } `) export default class NavBar extends HTMLElement { connectedCallback() { this.innerHTML += /* html */ `

Hyperia

`; // Track which anchor was pressed down let activeLink = null; // Get all anchor tags inside this element const anchors = this.querySelectorAll('a'); anchors.forEach(anchor => { anchor.addEventListener('mousedown', (e) => { activeLink = anchor; }); }); // Listen globally for mouseup, to detect release anywhere document.addEventListener('mouseup', (e) => { if (activeLink) { // Navigate to the href of the activeLink window.location.href = activeLink.href; activeLink = null; } }); const hamburger = this.querySelectorAll("img")[1] const sidebar = document.querySelector("side-bar"); hamburger.addEventListener("click", () => { if (sidebar.style.right === "0vw") { sidebar.style.right = "-100vw"; } else { sidebar.style.right = "0vw"; } }); } } customElements.define("nav-bar", NavBar)