1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

fix incorrect map of anchor to Link

This commit is contained in:
Sérgio Ramos 2017-03-23 13:43:00 +00:00
parent 1fdae858f3
commit 70b640fddf
2 changed files with 6 additions and 18 deletions

View File

@ -33,7 +33,7 @@ const Projects = ({
{empty} {empty}
<Row> <Row>
<Column xs={12}> <Column xs={12}>
<Button to={`/${org.id}/new-project`} rr> <Button to={`/${org.id}/new-project`}>
<FormattedMessage id='create-new' /> <FormattedMessage id='create-new' />
</Button> </Button>
</Column> </Column>

View File

@ -1,7 +1,6 @@
import { colors, boxes } from '../../shared/constants'; import { colors, boxes } from '../../shared/constants';
import { Baseline, typography, paperEffect } from '../../shared/composers'; import { Baseline, typography, paperEffect } from '../../shared/composers';
import { remcalc } from '../../shared/functions'; import { remcalc } from '../../shared/functions';
import isString from 'lodash.isstring';
import match from '../../shared/match'; import match from '../../shared/match';
import React from 'react'; import React from 'react';
import styled, { css } from 'styled-components'; import styled, { css } from 'styled-components';
@ -140,7 +139,7 @@ const StyledButton = styled.button`
} }
`; `;
const StyledAnchor = styled(Link)` const StyledAnchor = styled.a`
display: inline-block; display: inline-block;
${style} ${style}
`; `;
@ -151,25 +150,15 @@ const StyledLink = styled(Link)`
`; `;
const Button = (props) => { const Button = (props) => {
// support FormattedMessage
if (isString(props)) {
return (
<StyledButton>
{props}
</StyledButton>
);
}
const { const {
href = '', href = '',
to = '', to = ''
rr = false
} = props; } = props;
const Views = [ const Views = [
() => !to && !href ? StyledButton : null, () => to ? StyledLink : null,
() => !rr ? StyledAnchor : null, () => href ? StyledAnchor : null,
() => StyledLink () => StyledButton
]; ];
const View = Views.reduce((sel, view) => sel ? sel : view(), null); const View = Views.reduce((sel, view) => sel ? sel : view(), null);
@ -184,7 +173,6 @@ const Button = (props) => {
Button.propTypes = { Button.propTypes = {
children: React.PropTypes.node, children: React.PropTypes.node,
href: React.PropTypes.string, href: React.PropTypes.string,
rr: React.PropTypes.bool,
to: React.PropTypes.string to: React.PropTypes.string
}; };