-
Notifications
You must be signed in to change notification settings - Fork 20
Sticky sidebar #141
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
base: main
Are you sure you want to change the base?
Sticky sidebar #141
Conversation
|
hi @tjex |
|
hi @tjex i picked out just the css and div change just to take a quick look. one thing i noticed is that the "Side Navigation" component takes precedence over the "Table of Contents" component. ie you aren't able to see a page's table of contents until you scroll all the way to the bottom of the page. for example here is the "Git Revision" plugin page locally: vs compared to the live site where you can see the full Table of Contents component (at least until you scroll the main page content past it) ideawhat if the side panel containing the navigation and table of contents components scrolled separately from the main page content. when your mouse is hovered over the left-hand side you can scroll to see the full page listing and the TOC. then when you move your mouse over to the main content the left-hand side would stay frozen and scrolling would manipulate the main page content instead. **edit to add: |
|
for implementation if we want to add/remove styles based on feature flag we can add a section here: |
|
Thanks for making it :) We'll potentially be going with mkdocs for the documentation of zk. And would like to use this theme if so! So, great catch about the TOC only effectively becoming usable once we reach the bottom of the screen. It is quite a tricky one in a way. My initial reaction would be to put the TOC on the right side anyway, which is a pretty common layout these days for docs and reduces the amount of vertical movement with the eyes / mouse. But it still wouldn't be a robust solution in general, as perhaps someone out there has a stack of menu items, that already goes out of frame (or they're viewing on a very small screen). Then their own nav menu wouldn't be fully usable until they reach the bottom of the screen. Hmm. I'm not sure how tricky it is to implement that the side nav is scrollable itself, I'd expect not so bad. As an interim solution, what are your thoughts on putting the TOC on the right side, and setting them as sticky via a config feature option? I'd say for the vast majority of cases, this would suffice? In essence, if someone has a nav bar so full, that it's already exiting the screen, then they would have no use for a scrolling side bar anyway (so they wouldn't even enable it)? |
|
hi @tjex related to this issue: i am going to upgrade to v0.7.5 and see if this resolves the sticky problem without extra work from us. |
|
v0.7.4 merged |
|
hi @tjex Sticky Side Panel Override CSS: MkDocs Extra CSS Feature: |
|
Hi again... Sorry about going silent. I tried to implement the css override on the latest state of HEAD and it didn't make the sidebar stick. |
|
hey @tjex, no worries! |
|
I meant the latest commit of this
|


Resolves #140
Description
Sticky sidebars are a great UI functionality, as the user doesn't need to scroll up to access menu / nav items. This PR implements this behaviour idiomatically with the original
terminal.cssapproach and uses global variables for spacing that are already in use within the code base.This is a draft PR for now as merging in the current state would create a 'breaking change' of sorts to current users. Their sidebars would all become sticky by default.
I'm therefore looking for some feedback as how best to toggle this functionality via theme options, e.g,
navigation.side.sticky = true{%- if "navigation.side.sticky" in features -%} make sticky {%- endif -%}I tried to create an
if - elseblock inside-panel.htmlto insert the div elements required for the sticky sidebar. As withoutdivelements, the sidebar will not stick (also a bit of a hacky solution?). Along the lines of this. But I get an error aboutblock side_navbeing included twice:{%- set features = config.theme.features or [] -%} {%- if "navigation.side.hide" not in features -%} {%- if "navigation.side.sticky" in features -%} <div> <aside id="terminal-mkdocs-side-panel"> {%- block side_nav %}{% include "partials/side-nav/side-nav.html" %}{%- endblock side_nav %} {%- block side_toc %}{% include "partials/side-panel/side-toc.html" %}{%- endblock side_toc %} </aside> </div> {%- else -%} <aside id="terminal-mkdocs-side-panel"> {%- block side_nav %}{% include "partials/side-nav/side-nav.html" %}{%- endblock side_nav %} {%- block side_toc %}{% include "partials/side-panel/side-toc.html" %}{%- endblock side_toc %} </aside> {%- endif -%} {%- endif -%}Testing
The theme can be built and served directly:
make build-locally-and-serve.Then select a menu item that shows a page with enough content to scroll, and scroll down the page.
Make a narrow screen so the sidebars become top flex boxes, and scroll again (sidebar is static again).
Checklist