From 1d5349fb835799a9c58e74d38413d977cd8eef23 Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Thu, 25 Apr 2019 09:57:28 +0100 Subject: [PATCH] feat: loading button state --- src/components/Button.js | 60 ++++++++++++++++++++++++++++++++++------ src/components/Label.js | 2 +- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/components/Button.js b/src/components/Button.js index 9525cc1b..9cc36b7f 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -1,8 +1,42 @@ +import React from 'react' import styled, { css } from 'styled-components' -const Button = styled.button.attrs({ +const SVG = styled.svg` + display: inline; + margin-right: 0.25rem; +` + +const Spinner = () => ( + + + + + +) + +const StyledButton = styled.button.attrs({ className: 'moltin-shopkit shopkit-button' })` + background: none; box-sizing: border-box; line-height: 1.15; -webkit-text-size-adjust: 100%; @@ -15,7 +49,7 @@ const Button = styled.button.attrs({ border: 1px solid transparent; color: ${props => props.theme.placeholder}; font-weight: 500; - padding: ${props => (props.noPadding ? 0 : '0.75rem 1rem')}; + padding: ${props => (props.noPadding ? 0 : '0 1rem')}; outline: none; opacity: ${props => (props.disabled ? 0.5 : 1)}; @@ -50,20 +84,30 @@ const Button = styled.button.attrs({ css` margin-top: 1.5rem; `}; - - ${({ large }) => - large && - css` - padding: 1rem; - `}; ` +function Button({ loading, children, ...rest }) { + return ( + {loading ? : children} + ) +} + export const PrimaryButton = styled(Button).attrs({ className: 'shopkit-primary-button shopkit-primary' })` background-color: ${props => props.theme.primary}; border-color: ${props => props.theme.white}; color: ${props => props.theme.white}; + height: 2.8rem; + display: inline-flex; + align-items: center; + justify-content: center; + + ${({ large }) => + large && + css` + height: 3.25rem; + `}; ` export const TextButton = styled(Button)` diff --git a/src/components/Label.js b/src/components/Label.js index 30b3d58e..c98b1a09 100644 --- a/src/components/Label.js +++ b/src/components/Label.js @@ -10,7 +10,7 @@ export default function Label({ }) { return ( - {children || label} {required && (required)} + {children || label} {required && *} ) }