From ec099dd009b746cef015dec1290efb0fb72b3037 Mon Sep 17 00:00:00 2001 From: Ezekiel Aquino Date: Thu, 29 Nov 2018 14:33:27 +0100 Subject: Adds notes to button --- packages/website/ts/@next/components/button.tsx | 37 +++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'packages') diff --git a/packages/website/ts/@next/components/button.tsx b/packages/website/ts/@next/components/button.tsx index 55534b66a..b4280a9ed 100644 --- a/packages/website/ts/@next/components/button.tsx +++ b/packages/website/ts/@next/components/button.tsx @@ -3,13 +3,14 @@ import styled from 'styled-components'; import { colors } from 'ts/style/colors'; -interface Props { + +interface ButtonInterface { text: string; transparent?: boolean; inline?: boolean; } -const StyledButton = styled.button` +const StyledButton = styled.button` appearance: none; border: 0; background-color: ${colors.brandLight}; @@ -36,14 +37,40 @@ const Text = styled.span` line-height: 1.375rem; `; -export const Button: React.StatelessComponent = ({ ...props }) => ( + + +// A button that may exist as a button or a link +// a button only makes sense with an onClick handler +// a link with an href so we base the type of component we return +// based on those props + +export const Button: React.StatelessComponent = props => { + const { onClick, href } = props; + + // This button is as link + if (props.href) return StyledButton.withComponent('a'); + else return StyledButton; +}; + + +// usage +// ===> Text +// ====> + + + + +export const Button: React.StatelessComponent = ({ ...props }) => ( {props.text} ); -export const ButtonTransparent: React.StatelessComponent = ({ ...props }) => ( - ); -- cgit v1.2.3