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

Refactor tooltip ListItem for flexibility in to/href prop names #42

Merged
merged 1 commit into from
Jun 28, 2019

Conversation

kylesuss
Copy link
Collaborator

@kylesuss kylesuss commented Jun 28, 2019

The tooltip/ListItem and tooltip/TooltipLinkList currently make a lot of assumptions about the prop name that contains the "href" for a link. This is fine for standard links which always use an href, but it complicates things when you also pass in a LinkWrapper. Gatsby links use the to prop whereas Next links use the href prop, so the code that we had:

href={!LinkWrapper ? href : undefined}
to={LinkWrapper ? href : undefined}

... is making too many assumptions about what every single LinkWrapper expects. I propose we leave those assumptions out and instead just pass the props down to the LinkWrapper so that this component can be more flexible. This means that whenever you use the ListItem, you have to be careful about what props you pass down, however that's the same concern you will have when you are mixing Next links and anchor tags anyway.

@kylesuss kylesuss requested a review from domyen June 28, 2019 17:21
</Item>
);
if (LinkWrapper) {
const StyledLinkWrapper = styled(({ active, loading, ...linkWrapperRest }) => (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This has come up a few times, but this extra work is needed to avoid passing down non-standard props to <a> tags.

@domyen domyen merged commit 4e4c1e9 into master Jun 28, 2019
@domyen domyen deleted the refactor-tooltip-list-item branch June 28, 2019 17:34
@kylesuss
Copy link
Collaborator Author

🚀 PR was released in v0.0.33 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants