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

feat(RadialProgress): updated with option to render outline around progress indicator #2761

Merged
merged 11 commits into from
Aug 7, 2023

Conversation

vinnie-olsen
Copy link
Contributor

@vinnie-olsen vinnie-olsen commented Jul 28, 2023

Overview

Updated RadialProgress component with prop that adds an outline to the progress indicator and prop that adjusts SVG viewbox based on provided stroke-width

PR Checklist

Testing Instructions

Monorepo: See testing instructions on https://github.com/codecademy-engineering/mono/pull/2885

Storybook:

  • Go to the RadialProgress component and see that there are new progressOutline and adjustForStrokeWidth props available to configure.
  • Check that the component renders with or without these props and doesn't produce any errors in the console.
  • Test with a progressOutline, set the prop to an object of the shape {"size": 8, "color": "red"} and see that it renders the outline around the "progress" portion of the component.
  • Test toggling the adjustForStrokeWidth prop on and off. While it's off (false), any stroke-width above 10 will be cut off by the viewport of the SVG. This is the existing behavior (prior to these changes) and will also happen if the strokeWidth + progressOutline.size is greater than 10 when added together. However when the adjustForStrokeWidth prop is toggled on (true), it will adjust for stroke-widths greater than 10 and will ensure the entire progress circle fits within the SVG viewport without being cut off.
  • Test adding a baseColor prop with a custom color. When this is added, it should render the "non-progress" part of the circle in the provided custom color (in a solid/"1" opacity). When this prop is not present, it will work as it did prior to these changes and will render the "non-progress" part of the circle in the provided color prop value but with "0.2" opacity.
image

PR Links and Envs

Repository PR Link PR Env
Monolith Monolith PR
Portal Portal Link Portal Env

@vinnie-olsen vinnie-olsen marked this pull request as ready for review August 3, 2023 16:04
@vinnie-olsen vinnie-olsen requested review from a team, jakemhiller, dreamwasp, antoniablair, CharlieBliss and vonbarown and removed request for a team August 3, 2023 16:04
@vinnie-olsen vinnie-olsen requested review from a team, aresnik11, dreamwasp, antoniablair, CharlieBliss and vonbarown and removed request for a team August 4, 2023 17:29
size: number;
color: string;
};
adjustForStrokeWidth?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

i'm probably missing something, but i'm wondering why we'd want this to be false?

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 kind of went back and forth on that actually. I mainly ended up having it as a prop to help reduce the chance of regressions with any other implementations of this component and also to be able to easily toggle it off if it causes any issues. I did check the prod storybook though and this issue of the circle being cut off by the SVG viewport when the stroke-width is larger than 10 was present prior to any of the changes I made on this branch.

I'd be open to removing the prop and just having that logic always apply if you think that would be preferable though. What are your thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

yeah i think that logic can apply to all RadialProgress components, it shouldn't really be possible to go outside of those bounds in the first place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha yep I can make that change 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakemhiller I made that change

Comment on lines 15 to 18
progressOutline?: {
size: number;
color: string;
};
Copy link
Member

Choose a reason for hiding this comment

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

how do you feel about this being two separate properties, to match the other width/color properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So like separate progressOutlineSize and progressOutlineColor props instead of the progressOutline object with size and color properties?

Copy link
Member

Choose a reason for hiding this comment

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

yeah

Copy link
Member

Choose a reason for hiding this comment

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

i wonder if you could also set a reasonable default for the color? it seems like it would have to be changed in a lot of situations, so maybe not, but it seems odd if you can set the size and not see the outline

Copy link
Contributor Author

@vinnie-olsen vinnie-olsen Aug 4, 2023

Choose a reason for hiding this comment

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

Yeah agreed and that was the main reason that I set the progressOutline to be an object with both the size and color properties required. So basically if you use a progressOutline prop at all, those properties both need to be present. Alternatively, I suppose I could set the progressOutlineColor to be black by default. I think black is the default color for the "progress" part of the circle if you don't use a color prop on the RadialProgress component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakemhiller I made these changes. Lmk if that looks like what you had in mind. I also set the default progressOutlineColor to be black.

Copy link
Member

Choose a reason for hiding this comment

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

I haven't messed with the ColorMode stuff in gamut for a while, but after looking at it a bit i think what you want is theme.colors['background-current']. that should mean most folks won't need to change that prop, it will match whatever background as long as the background was set using gamut.

@@ -34,10 +38,45 @@ export const RadialProgress: React.FC<RadialProgressProps> = ({
value,
strokeLinecap = 'round',
strokeWidth = 10,
progressOutlineSize,
progressOutlineColor = theme.colors.black,
Copy link
Member

Choose a reason for hiding this comment

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

just b/c our previous conversation was resolved. i think this could be theme.colors['background-current'] so that it automatically matches the background 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha I'll change it over to theme.colors['background-current'] then - thanks!

Copy link
Member

@jakemhiller jakemhiller left a comment

Choose a reason for hiding this comment

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

after updating the outline color again I think you'll be good to go.

I was wondering whether progressOutlineSize could actually be a % based on the size of the progress circle, since i think design probably has a set size in mind, but i don't think that's a blocker

@vinnie-olsen
Copy link
Contributor Author

@jakemhiller awesome thanks!

Regarding the progressOutlineSize being a percentage, I'm not sure if it would work with the way this solution is currently setup since the stroke width of the "outline" circle is being computed using the strokeWidth prop together with the progressOutlineSize prop. For that reason, I think they would need to be the same relative units. It's possible that I'm misunderstanding though. Unless you have a strong opinion on making that change, I might just keep it as-is.

@jakemhiller
Copy link
Member

@vinnie-olsen no, that makes sense, lets go with what you have 👍

@codecademydev
Copy link
Collaborator

📬Published Alpha Packages:

@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]

@codecademydev
Copy link
Collaborator

🚀 Styleguide deploy preview ready!

https://64d1655bf945ab3eeae6f78f--gamut-preview.netlify.app

Deploy Logs

@vinnie-olsen vinnie-olsen added the Ship It :shipit: Automerge this PR when possible label Aug 7, 2023
@codecademydev codecademydev merged commit 442a6aa into main Aug 7, 2023
11 of 12 checks passed
@codecademydev codecademydev deleted the vo_en-2344_radial-progress-outline branch August 7, 2023 21:53
@codecademydev codecademydev removed the Ship It :shipit: Automerge this PR when possible label Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants