-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
size: number; | ||
color: string; | ||
}; | ||
adjustForStrokeWidth?: boolean; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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
progressOutline?: { | ||
size: number; | ||
color: string; | ||
}; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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!
There was a problem hiding this 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
@jakemhiller awesome thanks! Regarding the |
@vinnie-olsen no, that makes sense, lets go with what you have 👍 |
… RadialProgress component
📬Published Alpha Packages:@codecademy/[email protected] |
🚀 Styleguide deploy preview ready! |
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:
RadialProgress
component and see that there are newprogressOutline
andadjustForStrokeWidth
props available to configure.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.adjustForStrokeWidth
prop on and off. While it's off (false
), any stroke-width above10
will be cut off by the viewport of the SVG. This is the existing behavior (prior to these changes) and will also happen if thestrokeWidth
+progressOutline.size
is greater than10
when added together. However when theadjustForStrokeWidth
prop is toggled on (true
), it will adjust for stroke-widths greater than10
and will ensure the entire progress circle fits within the SVG viewport without being cut off.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 providedcolor
prop value but with "0.2" opacity.PR Links and Envs