Skip to content
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

Make plots ribbon sticky on scroll #2759

Merged
merged 2 commits into from
Nov 15, 2022
Merged

Make plots ribbon sticky on scroll #2759

merged 2 commits into from
Nov 15, 2022

Conversation

shcheklein
Copy link
Member

Closes #2731

Screen.Recording.2022-11-11.at.6.46.11.PM.mov

(writing it here primarily for the sake of future generation wondering how to use intersection observer API / react-intersection-observer to handle top nav bar / menu that changes its size):

  • rootMargin can be used to offset the root / parent element to the height of the menu. It works well if menu / nav bar height is stable. But would require creating a new observer when / if size changes. It breaks the point of using it and complicates code, etc, etc. See also Allow dynamically changing rootMargin w3c/IntersectionObserver#428
  • Idea here is simple - let's offset the main parent element by a small margin (1-10px) and require full intersection with the menu (threshold is 1 or close to that)

I was not able to make 1.0 threshold work (some pixels are not visible in the sticky mode?), but it work well with 0.95-0.99, etc.

@shcheklein shcheklein added product PR that affects product A: plots Area: plots webview, side panel and everything related labels Nov 12, 2022
@shcheklein shcheklein force-pushed the stick-ribbon branch 2 times, most recently from 354f9cc to 1062145 Compare November 13, 2022 05:05
@@ -1,4 +1,5 @@
.webviewWrapper {
width: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this to min-content would solve the following bug:

Screen.Recording.2022-11-14.at.8.58.31.AM.mov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this bug is in main and not part of this pr. Could be fixed separately :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more apparent with a sticky banner though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @sroy3, good catch. The fix proposed changes the whole UX in a way that we probably don't want. Instead of the ribbon taking always size of the viewport only and overflowing items, it's now taking the whole space (defined by the most wide plot). I'm not sure this is a good idea. Also, plots size control will move to the edge if we do it this way

I can find a way to fill the space with something, but the whole layout might change after the #2747 and further changes?

Copy link
Contributor

@sroy3 sroy3 Nov 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it is not as simple as that a change. What I'd do is make the ribbon 100% and create a div inside (ribbon-content or something else) and give it a width of 100vw (might have to calculate padding in there).

But yeah once #2585 is completely done, we shouldn't have horizontal scrollbars for the whole webview.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's skip it for now and get back to it after #2585 is done then

top: 0;
width: 100%;
z-index: 100;
background-color: var(--vscode-editor-background);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable $bg-color maps to var(--vscode-editor-background). We try to only use scss variables (easier to use and understand).

Copy link
Contributor

@julieg18 julieg18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@codeclimate
Copy link

codeclimate bot commented Nov 15, 2022

Code Climate has analyzed commit cfd8330 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 96.7% (0.0% change).

View more on Code Climate.

@shcheklein shcheklein merged commit be2adc3 into main Nov 15, 2022
@shcheklein shcheklein deleted the stick-ribbon branch November 15, 2022 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: plots Area: plots webview, side panel and everything related product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pin plots ribbon
3 participants