aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/@next/components/link.tsx
blob: c1b8b33e9043100e2e1e6b1c882e829a791ad61c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import * as React from 'react';
import { Link as ReactRouterLink } from 'react-router-dom';
import styled from 'styled-components';

import { colors } from 'ts/style/colors';

interface LinkInterface {
    color?: string;
    children?: Node | string;
    isNoArrow?: boolean;
    hasIcon?: boolean | string;
    isInline?: boolean;
    href?: string;
    theme?: {
        textColor: string;
    };
}

const StyledLink = styled(ReactRouterLink)<LinkInterface>`
    display: ${props => props.isInline && 'inline-block'};
    color: ${props => props.color || props.theme.linkColor};
    padding: ${props => !props.isNoPadding && '18px 30px'};
    text-align: center;
    font-size: 18px;
    text-decoration: none;

    @media (max-width: 768px) {
        padding: ${props => !props.isNoPadding && '6% 10%'};
    }
`;

export const Link = (props: LinkInterface) => {
    const {
        children,
        href,
    } = props;

    return (
        <StyledLink to={href} {...props}>
            {children}
        </StyledLink>
    );
};

// Added this, & + & doesnt really work since we switch with element types...
export const LinkWrap = styled.div`
    a + a,
    a + button,
    button + a {
        margin-left: 20px;
    }
`;