aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/@next/components/button.tsx
blob: 2f96759cefb659dc7f35f304bfcb0b0aff01f9ed (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
53
54
55
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import styled from 'styled-components';

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

interface ButtonInterface {
    children: Node | string;
    isTransparent?: boolean;
    hasIcon?: boolean | string;
    isInline?: boolean;
    href?: string;
    history?: {
        push: () => void;
    };
    onClick?: () => void;
}

export const Button = styled.button<ButtonInterface>`
    appearance: none;
    border: 1px solid transparent;
    display: ${props => props.isInline && 'inline-block'};
    background-color: ${props => !props.isTransparent ? colors.brandLight : 'transparent'};
    border-color: ${props => props.isTransparent && '#6a6a6a'};
    color: ${props => props.color || props.theme.textColor};
    text-align: center;
    padding: 14px 22px;
    font-size: 18px;
    text-decoration: none;
`;

export const Link = withRouter((props: ButtonInterface) => {
    const {
        history,
        href,
        children,
    } = props;
    const Component = StyledButton.withComponent('a');

    return (
        <Component onClick={history.push(href)}>
            {children}
        </Component>
    );
});

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