-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
refactor(pie): remove recompose and convert to hooks #1143
Conversation
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.
Awesome work and thank you so much! A couple of questions and one change, but it looks great.
Also, go ahead and delete |
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.
Couple minor things and should be good!
packages/pie/src/Pie.js
Outdated
role, | ||
} = props | ||
|
||
const theme = usePartialTheme() |
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.
We can pass a theme
prop to the component, so we need to override the default theme with those values. You can see this in the custom tooltip
story. The background of the tooltip should be black and it is white.
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 fixed this. I also noticed that in props.js
that theme isn't a required or optional prop listed in the propTypes
object. I don't know if this was done intentionally, but I wanted to bring it up.
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.
It looks like it is present on PieLegends, might as well make it available for the main components as well.
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.
Hmm, where do the prop types for the pie specific theme reside? I looked in nivo/packages/core/theming/propTypes.js
(since that is where PieLegends gets the propTypes declaration from), but it doesn't have the tooltip
property that I see is being used inside of the stories. It looks like theme.tooltip
is only ever defined via prop types in PieTooltip.js
. I could of course do something like:
import { themePropType } from '@nivo/core'
export const PiePropTypes = {
// other prop types
theme: PropTypes.shape({ ...themePropType, tooltip: PropTypes.shape({}) })
}
However, I'm not sure if that encompasses all of the custom theming for the pie package.
Upon further inspection, it looks like in nivo/packages/core/themeing/defaultTheme.js
there is a tooltip
default prop defined, but it is not found in the propTypes file.
Maybe this is starting to get outside of the scope of this PR.
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.
Looks great, thanks for the work put in here @DevelopmentByDavid!
Addresses #884 in the pie package by removing recompose.
A few notes/questions:
enhance.js
file. It seems unnecessary since there are now hooks, but since I am unfamiliar with the project I left it there for now pending your advice.PieLayout.js
I combined two of the computed props. Color is now always recomputed along with arcs. I don't think this combination changes anything since they seemed interdependent before, but I thought I should bring this change to your attention.withPropsOnChange
were converted toReact.useMemo
Any other additions or changes I'd be happy to make, just let me know.
Thanks!