Fix lack of sticky sidebar on "download" page - #339
Open
savetheclocktower wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
I'll give this one a day or two, but it's such a small fix that I'm inclined to land it if nobody takes the bait. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Of the three sites (main/blog/docs), this one has the most crowded navigation. I couldn't get away with defining the page header to be an explicit height; I had to make it
height: autobetween certain breakpoints so that it could cope if the navigation items wrapped to a second line.The problem with that is that we need to know what sort of
topoffset to apply to the sidebar. That sidebar isposition: stickyand if we dotop: 0, it'll fix in place as we scroll down rather than move upward out of view… but some of it will be hidden underneath the page header.So the
topvalue has to adjust based on the height of the page header.This was impossible because everything was keying off of the same CSS custom property:
--page-header-height. But when--page-header-heightwasauto, thetopcalculation failed (topcan't beauto, andautocan't have arithmetic done to it!).The fix is pretty easy and involves a few lines of JS. We want to make
--page-header-heightbe the source of truth for the page header height… but then we want to spy on its height changes so we can define a derived property that is useful for sticky offset calculation.--page-header-heightis allowed to beauto, but--actual-page-header-heightwill always be a specific value that can survive arithmetic.We actually only need this for the main site. The other two sites have fewer items in their page header navigation, so they haven't run into any scenarios where the explicit
heighthas bitten them. Only on the main site can--page-header-heightbe a non-numeric value… so it's the only place that needs to introduce a derived property to keep everything glued together.Testing
Visit https://pulsar-edit.dev/download/ and scroll down. Notice the sidebar navigation should stay on screen, but instead it moves off-screen as you scroll down.
Check out this PR branch and run it locally; the menu will work properly on the same page.