Skip to content

Make sidebar fixed #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2023
Merged

Conversation

joseemds
Copy link
Contributor

@joseemds joseemds commented Mar 3, 2023

This pull make the sidebar fixed, eliminating the need to scroll all the way up to change pages. With this change, users can easily access the sidebar navigation while browsing through the content.

This change only affects desktop users, and the mobile experience remains the same as before.

Before

before.mp4

After

after.mp4

(Sorry for the low quality videos, i don't know how to setup OBS properly)

@jpgrayson
Copy link
Collaborator

Hi @joseemds. I like this idea and I appreciate this PR.

However I'm seeing it break on desktop when the browser is wider than 768px, but not wide enough that the fixed-position header fits in the left-hand margin of <main>. In these circumstances, the header thus masks the left-hand side of the main body. It is not obvious to me how to tweak the CSS to resolve this problem (which, IIRC, is why there currently isn't a fixed header). This problem needs to be resolved in order for me to accept this PR.

@jpgrayson
Copy link
Collaborator

Actually, here's one idea. I added this to the new media query to ensure enough margin in the <div> that holds <main> and it seemed to work okay:

  body > div > div {
    margin-left: 12rem;
  }

So the complete media query becomes:

@media (min-width: 768px) {
  body > div > header {
    position: fixed;
    height: 100%;
  }
  body > div > div {
    margin-left: 12rem;
  }
}

The 12rem margin is derived from the header's flex-basis of 10rem; i.e. to be a little wider than that.

I'm not confident that this is a bullet-proof approach. Let me know what you think.

@joseemds
Copy link
Contributor Author

@jpgrayson Hi, Sorry for the delayed response, initially I tried to replicate the behavior that we want using overflow: hidden in the body, and only making the main content scrollable, but had some problems with some parts not being scrollable.

I tried locally the margin-left: 12rem and it looks pretty similar with the current version of the website. I will push a commit with the margin-left: 12rem addition

@jpgrayson jpgrayson merged commit 091ae1e into stacked-git:src Apr 1, 2023
@jpgrayson
Copy link
Collaborator

Thanks again for driving this change, @joseemds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants