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

fix(web): day ahead price styling features v3 #7274

Merged
merged 23 commits into from
Oct 16, 2024

Conversation

silkeholmebonnen
Copy link
Contributor

@silkeholmebonnen silkeholmebonnen commented Oct 3, 2024

Issue

AVO-559

Description

This PR highlights the top/bottom 5 percentage as green / red instead of just one value. It also shows 0 as a circle (12x*12 px) instead of nothing.

This is a follow up PR to #7272, so lets get that merged first.

Preview

Before:
Screenshot 2024-10-09 at 11 39 32

After:
Screenshot 2024-10-09 at 11 39 38

image image

Double check

  • I have tested my parser changes locally with poetry run test_parser "zone_key"
  • I have run pnpx prettier@2 --write . and poetry run format in the top level directory to format my changes.

@Alportan
Copy link
Contributor

Alportan commented Oct 7, 2024

Quick feedback that @VIKTORVAV99 brought up 💡

Maybe we can ditch the At completely for a cleaner view. Looking at it again, it might not necessarily bring more value, so we can ditch it altogether and go for a cleaner (and more small device friendly) option. ✨ What do you think @silkeholmebonnen ? 🙌

@silkeholmebonnen
Copy link
Contributor Author

Quick feedback that @VIKTORVAV99 brought up 💡

Maybe we can ditch the At completely for a cleaner view. Looking at it again, it might not necessarily bring more value, so we can ditch it altogether and go for a cleaner (and more small device friendly) option. ✨ What do you think @silkeholmebonnen ? 🙌

Sounds good! I tried to play around with how we can avoid the space being so big when it is in languages that doesn't have AM/PM or similar, but I didn't find a good solution. Do you have an idea @VIKTORVAV99?
image

@VIKTORVAV99
Copy link
Member

Quick feedback that @VIKTORVAV99 brought up 💡

Maybe we can ditch the At completely for a cleaner view. Looking at it again, it might not necessarily bring more value, so we can ditch it altogether and go for a cleaner (and more small device friendly) option. ✨ What do you think @silkeholmebonnen ? 🙌

Sounds good! I tried to play around with how we can avoid the space being so big when it is in languages that doesn't have AM/PM or similar, but I didn't find a good solution. Do you have an idea @VIKTORVAV99?

image

I don't think the space is an issue but if we think it is I'd either pad it to center the time a bit more or give more space to the actual graph.

But like I said I don't think it's an issue.

@Alportan
Copy link
Contributor

Alportan commented Oct 8, 2024

Quick feedback that @VIKTORVAV99 brought up 💡

Maybe we can ditch the At completely for a cleaner view. Looking at it again, it might not necessarily bring more value, so we can ditch it altogether and go for a cleaner (and more small device friendly) option. ✨ What do you think @silkeholmebonnen ? 🙌

Sounds good! I tried to play around with how we can avoid the space being so big when it is in languages that doesn't have AM/PM or similar, but I didn't find a good solution. Do you have an idea @VIKTORVAV99?
image

I don't think the space is an issue but if we think it is I'd either pad it to center the time a bit more or give more space to the actual graph.

But like I said I don't think it's an issue.

Definitely not a blocker, but would be nice to have a more fluid layout when it comes to localising.

@silkeholmebonnen
Copy link
Contributor Author

Quick feedback that @VIKTORVAV99 brought up 💡

Maybe we can ditch the At completely for a cleaner view. Looking at it again, it might not necessarily bring more value, so we can ditch it altogether and go for a cleaner (and more small device friendly) option. ✨ What do you think @silkeholmebonnen ? 🙌

Sounds good! I tried to play around with how we can avoid the space being so big when it is in languages that doesn't have AM/PM or similar, but I didn't find a good solution. Do you have an idea @VIKTORVAV99?
image

I don't think the space is an issue but if we think it is I'd either pad it to center the time a bit more or give more space to the actual graph.
But like I said I don't think it's an issue.

Definitely not a blocker, but would be nice to have a more fluid layout when it comes to localising.

Maybe we should leave it for now and then look at the more fluid layout later if we think it would be worth it.

@silkeholmebonnen silkeholmebonnen marked this pull request as ready for review October 9, 2024 09:41
@silkeholmebonnen silkeholmebonnen requested review from VIKTORVAV99 and removed request for VIKTORVAV99 October 9, 2024 09:42
@silkeholmebonnen silkeholmebonnen marked this pull request as draft October 9, 2024 09:46
Copy link
Member

@VIKTORVAV99 VIKTORVAV99 left a comment

Choose a reason for hiding this comment

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

Some comments but looks like it's working!

Comment on lines 56 to 75
useEffect(() => {
const handleResize = () => {
const divWidth = priceBarContainerReference?.current?.getBoundingClientRect().width;
setPositiveWidth(calculateWidth(divWidth, negativePercentage, false));
setNegativeWidth(calculateWidth(divWidth, negativePercentage, true));
};

const observer = new ResizeObserver(handleResize);
const current = priceBarContainerReference.current;

if (current) {
observer.observe(current);
}

return () => {
if (current) {
observer.unobserve(current);
}
};
}, [priceBarContainerReference, negativePercentage, isCollapsed]);
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need a use effect?

It should only be used as a escape hatch if it can't fit in the normal rendering flow of react.

Wouldn't the useResizeObserver hook be a better option?

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 tried just using the useResizeObserver without the useEffect but I could not get it to work. If you have time and think it is important then it would be nice if you could try it. But you decide

Copy link
Member

Choose a reason for hiding this comment

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

I can take a quick look but otherwise I don't consider this a blocking thing.

web/src/features/charts/FuturePrice.tsx Outdated Show resolved Hide resolved
web/src/features/charts/FuturePrice.tsx Outdated Show resolved Hide resolved
web/src/features/charts/FuturePrice.tsx Outdated Show resolved Hide resolved
web/src/features/charts/futurePriceUtils.ts Outdated Show resolved Hide resolved
web/src/features/charts/futurePriceUtils.ts Outdated Show resolved Hide resolved
@silkeholmebonnen silkeholmebonnen marked this pull request as ready for review October 9, 2024 09:59
@VIKTORVAV99
Copy link
Member

/review

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Code Complexity
The FuturePrice component has significantly increased in complexity due to new state management and dynamic styling logic. Consider refactoring to simplify and improve maintainability.

Performance Concern
The use of ResizeObserver within the FuturePrice component could lead to performance issues if not properly debounced or throttled, especially on lower-end devices.

@silkeholmebonnen
Copy link
Contributor Author

@VIKTORVAV99, do you think I should try to refactor like GA-reviews says?

@VIKTORVAV99
Copy link
Member

@VIKTORVAV99, do you think I should try to refactor like GA-reviews says?

No I don't think we need that, I would open a backlog issue about looking into using the resizeObserver hook though. But I don't think it's blocking.

I'll give this a final review tomorrow but I don't anticipate any issues🙂

Copy link
Member

@VIKTORVAV99 VIKTORVAV99 left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

I have one minor comment though, and I think we should look into the resize observer again at some point but none of them are blocking!

data-test-id="negative-price"
>
{price < 0 && (
<div>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this div is needed?

@silkeholmebonnen
Copy link
Contributor Author

I just noticed this:
image

This was what happened when I tried using the useResizeObserver, and I thought it was only when I switched to useResizeOberser, but apparently it does it now as well... To recreate open the futureprice and adjust the width of the browser. I will look into fixing this before we merge this PR

@VIKTORVAV99
Copy link
Member

VIKTORVAV99 commented Oct 16, 2024

I just noticed this: image

This was what happened when I tried using the useResizeObserver, and I thought it was only when I switched to useResizeOberser, but apparently it does it now as well... To recreate open the futureprice and adjust the width of the browser. I will look into fixing this before we merge this PR

I didn't notice that when using it normally (including resizing), but if you want to take another look at it don't let me stop you!

@silkeholmebonnen
Copy link
Contributor Author

I think I found a much simpler way of calculating the width that fixes all the problems (not using a useEffect and the resizing problem) @VIKTORVAV99

web/src/features/charts/FuturePrice.tsx Outdated Show resolved Hide resolved
web/src/features/charts/FuturePrice.tsx Outdated Show resolved Hide resolved
@silkeholmebonnen
Copy link
Contributor Author

Do you want to give it a final review or do you think its good to go now?

@VIKTORVAV99
Copy link
Member

Do you want to give it a final review or do you think its good to go now?

I took a quick look at the last changes and I don't think it needs a new review, so just go ahead and merge it!

@silkeholmebonnen silkeholmebonnen merged commit 5b7e193 into master Oct 16, 2024
22 checks passed
@silkeholmebonnen silkeholmebonnen deleted the silkebonnen/avo-559-v3-day-ahead-price branch October 16, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants