Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
navbar various fixes
  • Loading branch information
crikfilippo committed Nov 19, 2024
commit ee4ae55e097a3be01239264db0ce4aa9e4235f3f
31 changes: 16 additions & 15 deletions css/components/navbar.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:root {
--nav-size-base: calc(clamp(40px,4vw,60px) / 1.2) ;
--nav-size-base: calc(clamp(50px,5vw,70px));
}

.nav-logo img {
Expand All @@ -8,22 +8,22 @@
}

.nav-logo {
height: calc(var(--nav-size-base) * 1.3 );
max-width: calc(var(--nav-size-base) * 4 );
height: calc(var(--nav-size-base) / 1.3 );
width: min-content;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
gap: calc(var(--nav-size-base) / 4);
}

nav.header-navbar {
nav.navbar {
width: 100%;
height: auto;
height: var(--nav-size-base);
position: sticky;
top: 0;
left: 0;
z-index: 2;
z-index: 3;
display: flex;
flex-direction: row;
align-content: center;
Expand All @@ -32,9 +32,10 @@ nav.header-navbar {
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
justify-content: space-between;
box-sizing: border-box;
}

nav.header-navbar:before {
nav.navbar:before {
content: "";
display: block;
position: absolute;
Expand All @@ -50,9 +51,9 @@ nav.header-navbar:before {
}

.nav-toggle {
width: var(--nav-size-base);
height: var(--nav-size-base);
gap: calc(var(--nav-size-base) / 12);
width: calc(var(--nav-size-base) / 1.4);
height: calc(var(--nav-size-base) / 1.6);
gap: 10%;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
Expand All @@ -63,10 +64,10 @@ nav.header-navbar:before {

span.nav-line {
display: block;
width: 90%;
height: calc(var(--nav-size-base)/5);
background: var(--neutral-600);
border-radius: 5px;
width: 100%;
height: 25%;
background: var(--neutral-700);
border-radius: 2px;
transition: 50ms;
position: relative;
top: 0;
Expand All @@ -78,7 +79,7 @@ span.nav-line {

.nav-toggle.show #nav-line-3 {
opacity: 0;
top: 20px;
/* top: 20px; */
height: 0;
}

Expand Down
12 changes: 7 additions & 5 deletions js/components/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export class Navbar {
this.id = id;
this.nav = document.getElementById(id);
if(!this.nav){ throw new Error(`element "${id}" not found`); }
this.nav.classList.add('header-navbar');
this.nav.classList.add('navbar');

//get logo path/text
this.hasLogo = (this.nav.querySelector('img') && this.nav.querySelector('img').src) ? true : false;
this.logoPath = this.hasLogo ? this.nav.querySelector('img').src : undefined;
this.siteTitle = document.querySelector('head title');
this.siteTitle = siteTitle ?? (this.siteTitle.innerText ?? 'Lorem Ipsum');
this.siteTitle = siteTitle ?? (this.siteTitle.innerText ?? '');


//get menu items
Expand All @@ -42,7 +42,7 @@ export class Navbar {
this.nav.querySelectorAll('a').forEach((a)=>{

var page = {};
page.href = a.href ?? '#';
page.href = a.href ?? '';
page.text = a.innerText ?? 'Page';
this.pages.push(page);

Expand Down Expand Up @@ -124,9 +124,9 @@ export class Navbar {

for(var i = 0; i < this.pages.length; i++){

var li = document.createElement('li')
var li = document.createElement('li');
var a = document.createElement('a');
a.href = this.pages[i].href;
if(this.pages[i].href.length > 0){ a.href = this.pages[i].href; }
a.innerText = this.pages[i].text;
li.appendChild(a);
ul.appendChild(li);
Expand All @@ -143,3 +143,5 @@ export class Navbar {
}


//initialize first available
//document.addEventListener("DOMContentLoaded", () => {let navMain = new Navbar('nav-main');});