aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/@next/components/button.tsx
blob: 2569c39c505197b80d5212151659238aced05e9a (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
import * as React from 'react';
import styled from 'styled-components';

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

interface ButtonInterface {
    children: Node | string;
    transparent?: any;
    hasIcon?: any;
    inline?: any;
    href?: string;
    onClick?: () => void;
}

export const Button: React.StatelessComponent<ButtonInterface> = props => {
    const { onClick } = props;
    const Component = onClick ? StyledButton : StyledButton.withComponent('a');
    return <Component {...props}>{props.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;
    }
`;

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