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

Only pass appropriate link props to Tooltip ListItem #24

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/components/StoryLinkWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { action } from '@storybook/addon-actions';

const fireClickAction = action('onLinkClick');

export function StoryLinkWrapper({ children, href, onClick, ...rest }) {
export function StoryLinkWrapper({ children, className, href, onClick, to }) {
const modifiedOnClick = event => {
event.preventDefault();
onClick();
fireClickAction(href);
fireClickAction(href || to);
};

return (
<a href={href} {...rest} onClick={modifiedOnClick}>
<a className={className} href={href || to} onClick={modifiedOnClick}>
{children}
</a>
);
Expand All @@ -23,10 +23,15 @@ export function StoryLinkWrapper({ children, href, onClick, ...rest }) {
StoryLinkWrapper.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
children: PropTypes.any.isRequired,
href: PropTypes.string.isRequired,
className: PropTypes.string,
href: PropTypes.string,
onClick: PropTypes.func,
to: PropTypes.string,
};

StoryLinkWrapper.defaultProps = {
className: '',
href: null,
onClick: () => {},
to: null,
};
3 changes: 2 additions & 1 deletion src/components/tooltip/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const ItemInner = styled.span`
}
`;

const Item = styled.a`
// eslint-disable-next-line jsx-a11y/anchor-has-content
const Item = styled(({ active, loading, ...rest }) => <a {...rest} />)`
font-size: ${typography.size.s1}px;
transition: all 150ms ease-out;
color: ${color.mediumdark};
Expand Down