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

Fix LinkWrapper props to avoid collisions w React, Gatsby, etc links #10

Merged
merged 3 commits into from
Jun 12, 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
4 changes: 1 addition & 3 deletions src/components/Highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const HighlightBlock = styled.div`
}
`;

class Highlight extends React.Component {
export class Highlight extends React.Component {
componentDidMount() {
this.highlightCode();
}
Expand Down Expand Up @@ -62,5 +62,3 @@ class Highlight extends React.Component {
Highlight.propTypes = {
children: PropTypes.node.isRequired,
};

export default Highlight;
2 changes: 1 addition & 1 deletion src/components/Highlight.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import Highlight from './Highlight';
import { Highlight } from './Highlight';

const bash = `
<pre class="language-bash"><code class="language-bash"><span class="token comment"># Highlight bash:</span>
Expand Down
12 changes: 8 additions & 4 deletions src/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const LinkButton = styled.button`
${linkStyles};
`;

export function Link({ isButton, withArrow, containsIcon, LinkWrapper, children, ...props }) {
export function Link({ isButton, withArrow, containsIcon, LinkWrapper, children, ...rest }) {
const content = (
<Fragment>
<LinkInner withArrow={withArrow} containsIcon={containsIcon}>
Expand All @@ -147,12 +147,16 @@ export function Link({ isButton, withArrow, containsIcon, LinkWrapper, children,

if (LinkWrapper) {
const StyledLinkWrapper = LinkA.withComponent(LinkWrapper);
return <StyledLinkWrapper {...props}>{content}</StyledLinkWrapper>;
const { inverse, nochrome, secondary, tertiary, ...linkWrapperProps } = rest;

return <StyledLinkWrapper {...linkWrapperProps}>{content}</StyledLinkWrapper>;
}

if (isButton) {
return <LinkButton {...props}>{content}</LinkButton>;
return <LinkButton {...rest}>{content}</LinkButton>;
}
return <LinkA {...props}>{content}</LinkA>;

return <LinkA {...rest}>{content}</LinkA>;
}

Link.propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export * from './Avatar';
export * from './AvatarList';
export * from './Badge';
export * from './Button';
export { default as Highlight } from './Highlight';
export * from './Highlight';
export * from './Icon';
export * from './Link';
export * from './Subheading';
Expand Down