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

Select the number of items per row from slider #3405

Merged
merged 12 commits into from
Mar 8, 2023
Merged

Conversation

sroy3
Copy link
Contributor

@sroy3 sroy3 commented Mar 6, 2023

Part of #2585

Demo

Screen.Recording.2023-03-07.at.1.45.23.PM.mov

Demo on a bigger screen (higher maximum number of plots per row)

Screen.Recording.2023-03-07.at.1.47.07.PM.mov

Scope

  • Remove the resizer on each plot and add a slider to select the number of plots per row
  • Slider is only available if there are plots in the section
  • Slider is not available in the comparison table (still no resize in that section)
  • Maximum number of plots per row is dynamic. It changes with the screen size. Minimum width of one plot is 300px

@sroy3 sroy3 added the product PR that affects product label Mar 6, 2023
@sroy3 sroy3 self-assigned this Mar 6, 2023
@sroy3 sroy3 changed the base branch from main to icons-story March 6, 2023 16:00
@sroy3
Copy link
Contributor Author

sroy3 commented Mar 6, 2023

Just used the current controls we had, but we could probably change this for a slider. We can either add more options or add a custom option at the end for the user to specify what they want. In the end, it does simplify things by a lot, it'll be way easier to maintain, and will definitely improve performance.

@sroy3 sroy3 mentioned this pull request Mar 6, 2023
10 tasks
@shcheklein
Copy link
Member

Thanks, @sroy3 !

Let's do a few changes (going forward, I know this is just a POC):

  • Add a very explicit message before the icon that this is about plots layout
  • Let's not limit it by 4? I'm not sure why we have this limitation tbh.
  • Q: how does it affect the large plots?

@sroy3
Copy link
Contributor Author

sroy3 commented Mar 6, 2023

Thanks, @sroy3 !

Let's do a few changes (going forward, I know this is just a POC):

  • Add a very explicit message before the icon that this is about plots layout

There are tooltips that pop pretty much instantly on these icon buttons. All plots controls are centralized there. Discovery shouldn't be hard. If we add a message, we'd have to rethink that whole menu. We have more important actions without obvious labels either. As a matter of fact, most of the actions in the extension are only one icon and a tooltip. We can try to find better icons as well if necessary.

Screen.Recording.2023-03-06.at.1.33.35.PM.mov

Screenshot 2023-03-06 at 1 34 38 PM

  • Let's not limit it by 4? I'm not sure why we have this limitation tbh.

I can do that easily (more than before). I think we had limited to 4 because on a small screen it starts being quite small and calculating break points becomes more difficult the smaller the screen is (but we do not have those break points anymore, everything is done by css). We should limit this to how much then? 10? Should we just have a numerical input instead? By the way should these icon buttons simply open a quick pick / quick input like the buttons for custom plots? We currently have 2 strategies here, custom controls and using quick pick / quick inputs. I'll generalize them at the same time (use the quick picks / inputs).

  • Q: how does it affect the large plots?

It doesn't for now. But we could maybe do some calculations to make it fit. Something like, if there are 4 items per rows and the large plot has 2 revisions in it, then place 2 plots on the row. But if there are 3 items per row or 4+ revisions, stick to 1 plot per row. This will get better if we increase the possible number of items per row.

@shcheklein
Copy link
Member

There are tooltips that pop pretty much instantly on these icon buttons.

Yep, but I think it's not enough unfortunately. With resize the issue is that I (as a user) expect it to be naturally part of the plots (e.g. grip, an icon on the plot, etc). It's less natural and no single standard way to make it part of the menu. Thus I would advocate for explicit controls (text + something) vs buttons only. We can always optimize it back, but there is no reason for us to make it harder for people to find.

But we could maybe do some calculations to make it fit.

Yep, sounds good (there are some details still to clarify, but initial approach sounds reasonable to me).

Base automatically changed from icons-story to main March 6, 2023 19:55
@sroy3 sroy3 changed the title Select the number of items per row from picker Select the number of items per row from slider Mar 7, 2023
@sroy3
Copy link
Contributor Author

sroy3 commented Mar 7, 2023

Demo was updated

@sroy3 sroy3 marked this pull request as ready for review March 7, 2023 21:21
@sroy3 sroy3 requested a review from shcheklein March 7, 2023 21:25
Copy link
Member

@mattseddon mattseddon left a comment

Choose a reason for hiding this comment

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

👍🏻

color: $fg-color;
}

.slider {
Copy link
Member

Choose a reason for hiding this comment

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

Might be a good time to revisit the in-plot sliders and match them with the background?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I get what you mean, aren't both slider the same?

Copy link
Member

@mattseddon mattseddon Mar 8, 2023

Choose a reason for hiding this comment

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

The background color of the slider in the plots could take the webview background color ($bg-color) instead of $plot-block-bg-color.

https://github.com/iterative/vscode-dvc/blob/main/webview/src/plots/components/styles.module.scss#L51

Just a suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I'll do that as a quick follow-up, no problem

FOUR: 4
}
/* eslint-enable sort-keys-fix/sort-keys-fix */
export const DefaultNumberOfItemsPerRow = 2
Copy link
Member

Choose a reason for hiding this comment

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

[Q] Should this be calculated based on the screen size?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure myself, just asking the question.

Copy link
Member

Choose a reason for hiding this comment

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

[N] Should use screaming snake case. e.g NUM_OF_COMMITS_TO_SHOW

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[N] Should use screaming snake case. e.g NUM_OF_COMMITS_TO_SHOW

I got confused and was wondering about this because of other variables not using this format. Will change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[Q] Should this be calculated based on the screen size?

Good question. I could try this as a follow up. Currently the default vale is set in the extension, so I'd have to reset everything to undefined to then calculate it in the webview. I'd probably select the middle value by default.

extension/src/plots/vega/util.ts Outdated Show resolved Hide resolved
webview/src/plots/components/App.test.tsx Outdated Show resolved Hide resolved
webview/src/plots/components/App.test.tsx Outdated Show resolved Hide resolved
@@ -42,6 +44,8 @@ export const CheckpointPlotsWrapper: React.FC = () => {
menu={menu}
nbItemsPerRow={nbItemsPerRow}
sectionCollapsed={isCollapsed}
changeNbItemsPerRow={changeSize}
Copy link
Member

Choose a reason for hiding this comment

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

[C] I just realised that updating both Custom and Trend plots is going to collide with #3404

cc @julieg18

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, there, for sure, will be some collisions. Though I don't think they'll be anything too hard to correct :)

webview/src/plots/components/styles.module.scss Outdated Show resolved Hide resolved
webview/src/plots/components/Plots.tsx Outdated Show resolved Hide resolved
webview/src/plots/components/PlotsContainer.tsx Outdated Show resolved Hide resolved
webview/src/plots/components/webviewSlice.ts Outdated Show resolved Hide resolved
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!

onChange: (newValue: number) => void
}

export const MinMaxSlider: React.FC<MinMaxSliderProps> = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if there is anything that can be done about it but the slider jumps sometimes when the plot rows increase:

Screen.Recording.2023-03-08.at.8.27.14.AM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way to solving that would be to make sure the last section is at least 100vh which does not always look good, especially when it's empty or have very few plots. I'm wondering though if we shouldn't have one width slider for all plots instead of resizing per section.

@sroy3
Copy link
Contributor Author

sroy3 commented Mar 8, 2023

Newest demo:

Screen.Recording.2023-03-08.at.10.27.54.AM.mov

@codeclimate
Copy link

codeclimate bot commented Mar 8, 2023

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

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

This pull request will bring the total coverage in the repository to 95.7%.

View more on Code Climate.

@sroy3 sroy3 merged commit b48c80d into main Mar 8, 2023
@sroy3 sroy3 deleted the items-per-row-control branch March 8, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants