Skip to content

Commit

Permalink
Fix LinkWrapper props to avoid collisions w React, Gatsby, etc links (#…
Browse files Browse the repository at this point in the history
…10)

Fix LinkWrapper props to avoid collisions w React, Gatsby, etc links
  • Loading branch information
domyen authored Jun 12, 2019
2 parents edcfd81 + 0fb5605 commit 122c5c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
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

0 comments on commit 122c5c7

Please sign in to comment.