From eec40080a06bf5dbc0661a5929e5cbb8d1b88911 Mon Sep 17 00:00:00 2001 From: Ezekiel Aquino Date: Tue, 4 Dec 2018 15:17:33 +0100 Subject: Refactors Button component --- packages/website/ts/@next/components/button.tsx | 48 ++++++++++++++++--------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'packages') diff --git a/packages/website/ts/@next/components/button.tsx b/packages/website/ts/@next/components/button.tsx index 92c2dac28..2f96759ce 100644 --- a/packages/website/ts/@next/components/button.tsx +++ b/packages/website/ts/@next/components/button.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import { withRouter } from 'react-router-dom'; import styled from 'styled-components'; import { colors } from 'ts/style/colors'; @@ -9,14 +10,39 @@ interface ButtonInterface { hasIcon?: boolean | string; isInline?: boolean; href?: string; + history?: { + push: () => void; + }; onClick?: () => void; } -export const Button: React.StatelessComponent = props => { - const { onClick } = props; - const Component = onClick ? StyledButton : StyledButton.withComponent('a'); - return {props.children}; -}; +export const Button = styled.button` + 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 ( + + {children} + + ); +}); // Added this, & + & doesnt really work since we switch with element types... export const ButtonWrap = styled.div` @@ -27,15 +53,3 @@ export const ButtonWrap = styled.div` margin-left: 10px; } `; - -const StyledButton = styled.button` - appearance: none; - border: 1px solid transparent; - display: ${props => props.isInline && 'inline-block'}; - background-color: ${props => !props.isTransparent && colors.brandLight}; - border-color: ${props => props.isTransparent && '#6a6a6a'}; - color: ${props => props.color || props.theme.textColor}; - text-align: center; - padding: 14px 22px; - text-decoration: none; -`; -- cgit