-
Notifications
You must be signed in to change notification settings - Fork 133
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
Improve the fixed header approach to remove "header padding fouc" #1560
Comments
Some existing solutions / compromises:
In general it seems like there is no "easy / ideal way out". The core of the problem is that style detection of the header height is required, something that isn't too common. |
I ended up sidetracking here and there and drafted 3 solutions below on top of the OP's, all of which achieve the aim of "no more fouc" but each has pros and cons.
Honestly not too sure which we should go with.
Wdyt? @jonahtanjz ps: the tests in the PRs will be updated once this is resolved |
I am also leaning towards option 1 as it is the simplest implementation-wise compared to the other options.
Perhaps we can introduce a new component to MarkBind to support announcement bar? This seems like a good addition as currently announcements have to be implemented manually by the user. Having a native announcement bar in MarkBind should make it easier for users to add elements before/after the header and also toggle between fixed/non-fixed bar accordingly (#1631). This will also help to resolve most of the concerns if we go with Option 1. |
*Missed mentioning: while simple incrementally, option 3/4 should be the simplest when considered in whole.
Thanks for raising this.. hmm... I think we should we leave the announcement bar design to the author, since its one of the reasons of having expressive layouts. Also quite a few announcement bar designs to account for in a single component. More importantly it shouldn't be too much trouble to design this one-off thing from the author side (maybe @damithc can chip in here w.r.t to that discussion). But I'm ok if this can add enough value otherwise. (e.g. navbars are also one off but feature rich enough to warrant them) But more importantly (not sure if this was accounted for) supporting this would ultimately still require implementing sticky positioning (via option 2 or 3) as well. I think that discussion thread also brings up again whether supporting something like a Previously I imagined you could place the banner below the header as a workaround (but didn't recall that discussion). Wonder if we should go with 3/4 after all as such, it seems to be more generalisable although not optimal-looking. (at best the header is hidden when you scroll down) Likely problematic food for thought: To implement a fixed-positioned header, maybe instead we provide some instructions in the documentation on how to do so, following the most common solution around:
i.e. author manually measures the header size on some screen sizes and sets the or we can support both options 1 & 4, and advise when to use each in the documentation. maybe one thing we can agree on first is that option 2 is definitely not the way to go (interesting experiment but difficult to explain and too complex (not even done yet) in implementation 😅) |
Personally, I think it would be a good addition to have an announcement bar component (or minimally give an example of how to achieve that in our UG). I think the one that's on the 2103 website is an excellent example of such a use case and I feel that this can be generalized to other situations as well for our potential users. Perhaps going further, we may also consider supporting a "toast" component in the future.
Just to chip in, I feel that if we can mitigate the cons here then this solution looks pretty good. Actually, I am not sure what you mean by "announcement at the top of the page but should not follow the header as you scroll downward)", so initially the announcement will be at the top, and if you scroll down, it follows? (In that case, perhaps if the announcement is dismissible, then this would still be somewhat ok?)...just some thoughts for discussion :) |
Flexibility for authors is good. If we can leave room for that, we should. And yes, that should be accompanied by good examples in the UG. |
Agreed, some instructions would be nice 😬 As for the component, below code example is taken from the 2103 site; I think it's really easy to construct on the author side, and may be counterproductive for us to limit the design using a component (at least, I can't imagine how we can provide flexibility in such a component 😅).
Toasts sound good! I think we can open up a separate issue for it.
Pretty much what's described here #1631. Dismissible sounds good but ideally the reader shouldn't have to act on this at all :)
If you mean sticky positioning (but without the cons of that too) that would be solution 2, but its a little too complex for comfort. (see https://github.com/MarkBind/markbind/pull/1930/files#diff-6ae0c610a951c1b0540c673c0f37f26de23750e00c3c85c6e92ce5ddad97b89bR52) I imagine there also are many edge cases (ref the scroll handling) not withstanding the window resizing ones I haven't accounted for. Might be good to stick to something simpler / predictable for an option ( |
I think as mentioned earlier in your comment, option 3 is quite damaging to the page nav (the header + first item get hidden behind). I personally prefer option 1 over option 3 (option 4 may be a better alternative).
I think this can be a good compromise if we allow user to choose one.
For option 1, maybe instead of an announcement bar component, we can include in the documentation to give it a certain Something like this: <div id="header_banner_top">...</div>
<header fixed>
...
</header>
<div id="header_banner_bottom">...</div> This gives users flexibility to customize their own banners as well as allows for non-fixed banners with fixed header. |
👍, I'll go with this then, then try to get @damithc in the PR to see from a author perspective if it checks out.
(for (for
the same issue of the page nav / sitenav being hidden appears in this case too unfortunately, since they are no longer affected by fixed-header-padding. |
Ahh ok I see the issue.
Yup let's go with this. |
Is your request related to a problem?
Browser refresh:

Describe the solution you'd like
Experiment with a dynamic positioning approach, e.g. https://www.w3schools.com/howto/howto_js_sticky_header.asp.
Describe alternatives you've considered
Additional context
#1534 eliminates fouc from vue rendering but fouc from the style detection of headers at runtime remains.
The text was updated successfully, but these errors were encountered: