Above looks good, works the same way the navbar persists through scrolling, the style that allows it to be persistent through scrolling is putting this <position: sticky;> in the .p-staffBar class
But there is a problem - the nav-bar is already persistent through scrolling, so the staff-bar will not be visible as they will not be stacked properly - and doing JUST this will effectively render it useless but ( and I'm starting to guess here) the the z-index of the staff-bar should be 1 less than that of the nav-bar, so if it's 400, make staff-bar 399 , although I added this and it didn't seem to matter when testing, could be due to the bruce-force way I'm using top overriding it. try it out anyway.
adding <top:0> to the staff-bar seems to be essential, makes sense.
This does not solve the problem yet, as they are not stacked properly - we need to add a top value to the nav-bar to have it give some space for the staff-bar, this may not be the best way to do it as it's kind of brute-forcy, but anyway, so - The problem with a static top value is the size of the elements might change based on screen-size, or more specifically browser window size, which is especially important if you're on your phone or tablet etc.
Best would be to add a top value equivalent to the height of the staffBar to the nav-bar - this cannot be achieved by css, but it should be very easy with js or so, see example below:
// If the heights of the staff-bar or nav-bar do not change in relation to the browser window size then this should not be necessary at all, and Noah's solution should do.
I tried in console, seemed to work - should at least help.
code:
// check if the .is-sticky class is applied, so it happens only when scrolled down. (the class applies when the nav-bar becomes sticky, i.e when you've scrolled far down enough that the top of your
// browser window has gone over the navbar element
const staffBarHeight = document.getElementsByClassName('p-staffBar')[0].offsetHeight
// You can make the above change dynamically without a refresh, not going to get into it though. add an event listener for window resizing
// check if the .is-sticky class is applied, so it happens only when scrolled down. (the class applies when the nav-bar becomes sticky, i.e when you've scrolled far down enough that the top of your
// browser window has gone over the navbar element
const staffBarHeight = document.getElementsByClassName('p-staffBar')[0].offsetHeight
// You can make the above change dynamically without a refresh, not going to get into it though. add an event listener for window resizing
window.onscroll = function () {
if (document.querySelector('.p-navSticky.is-sticky') !== null ) {
document.getElementsByClassName('p-staffBar')[0].style.top = 0
document.getElementsByClassName('p-staffBar')[0].style.zIndex = 399;
document.querySelector('.p-staffBar').style.position = 'sticky';
document.getElementsByClassName('p-navSticky')[0].style.top = staffBarHeight + 'px';
}
}
this doesn't look great but not the worst ever, I'd consider reducing the size of the nav-bar element if a change like this is considered to be pushed to live