Skip to content

Add a slider to resize plots vertically#3428

Merged
sroy3 merged 10 commits intomainfrom
resize-plots-height
Mar 14, 2023
Merged

Add a slider to resize plots vertically#3428
sroy3 merged 10 commits intomainfrom
resize-plots-height

Conversation

@sroy3
Copy link
Contributor

@sroy3 sroy3 commented Mar 8, 2023

Part of #2585

Screen.Recording.2023-03-08.at.3.42.06.PM.mov

@sroy3 sroy3 added the product PR that affects product label Mar 8, 2023
@sroy3 sroy3 self-assigned this Mar 8, 2023
@sroy3 sroy3 marked this pull request as ready for review March 10, 2023 14:44

export const CustomPlotsWrapper: React.FC = () => {
const { plotsIds, nbItemsPerRow, isCollapsed } = useSelector(
const { plotsIds, nbItemsPerRow, isCollapsed, height } = useSelector(

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

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!

<>
<div
className={styles.sizeSliders}
data-testid="nb-items-per-row-slider"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename this id since it now holds two different sliders? Or maybe give each slider their own id 🤔

/>
</div>
{changeSize && hasItems && maxNbPlotsPerRow > 1 && (
<>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this <></> wrapper needed?

}

.ratioVerticalNormal .plot {
aspect-ratio: 3 /4;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming we want to keep things consistent 😄

Suggested change
aspect-ratio: 3 /4;
aspect-ratio: 3 / 4;

className={styles.sizeSliders}
data-testid="nb-items-per-row-slider"
>
<div className={styles.sizeSlider}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's just me, but it seems the two sliders on top of each other cause the header to have some empty space 🤔

What about having them side by side?

Screenshot 2023-03-12 at 4 43 55 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Could be complicated but I think we should consolidate everything into the section header and make it sticky (as per #3443 (review)). WDYT?

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 think it'll make the whole thing too bulky. I also like the fact that when we collapse the section, we don't see the sliders anymore. It's more of a distraction otherwise. Having them side by side isn't a bad idea. But I'll make the headers sticky as well.

Copy link
Contributor

@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.

Change LGTM.

One issue that I managed to create was y-axis label overflow (cc @julieg18):

image

Screen.Recording.2023-03-13.at.8.47.32.am.mov

REGULAR = 2,
SQUARE = 3,
VERTICAL_NORMAL = 4,
VERTICAL_LARGER = 5
Copy link
Contributor

Choose a reason for hiding this comment

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

[Q] Could these be the aspect ratios if that is what they refer to?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would we gain/lose anything by having this as PlotAspectRatio?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First iteration used aspect ratios instead, but it made it more complicated to hold fractions instead of numbers. It makes it way easier to change the aspect ratio at the end of the chain (stylesheet) than doing so inside the enum here.

@sroy3
Copy link
Contributor Author

sroy3 commented Mar 13, 2023

Change LGTM.

One issue that I managed to create was y-axis label overflow (cc @julieg18):

image

You're right, I forgot that y title truncation is done using the plot width at the moment. Need to change it to use the height instead.

@sroy3 sroy3 enabled auto-merge (squash) March 14, 2023 14:47
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 1ab4679 and detected 8 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Duplication 6

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

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

View more on Code Climate.

@sroy3 sroy3 merged commit 6861c87 into main Mar 14, 2023
@sroy3 sroy3 deleted the resize-plots-height branch March 14, 2023 15:01
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.

3 participants