From 12ec0c33eab23852e37cf4014c168ee5083367b8 Mon Sep 17 00:00:00 2001 From: Sara Vieira Date: Thu, 12 Oct 2017 19:55:05 +0100 Subject: [PATCH] fix(ui-tollkit): improve loading button styles fixes #754 --- packages/ui-toolkit/src/button/index.js | 9 ++++++--- packages/ui-toolkit/src/button/usage.md | 17 ++++++++++++----- packages/ui-toolkit/src/status-loader/index.js | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/ui-toolkit/src/button/index.js b/packages/ui-toolkit/src/button/index.js index c3419733..edb69a49 100644 --- a/packages/ui-toolkit/src/button/index.js +++ b/packages/ui-toolkit/src/button/index.js @@ -1,7 +1,7 @@ import React from 'react'; import remcalc from 'remcalc'; import PropTypes from 'prop-types'; -import is from 'styled-is'; +import is, { isOr } from 'styled-is'; import styled, { css } from 'styled-components'; import { A, Button as NButton } from 'normalized-styled-components'; import { Link } from 'react-router-dom'; @@ -124,7 +124,9 @@ const style = css` } `}; - ${is('disabled')` + ${isOr('disabled', 'loading')` + cursor: not-allowed; + pointer-events: none; color: ${props => props.theme.grey}; background-color: ${props => props.theme.disabled}; border-color: ${props => props.theme.grey}; @@ -200,7 +202,7 @@ const Button = props => { const View = Views.reduce((sel, view) => (sel ? sel : view()), null); const children = loading ? ( - + ) : ( props.children ); @@ -225,6 +227,7 @@ Button.propTypes = { secondary: PropTypes.bool, tertiary: PropTypes.bool, small: PropTypes.bool, + loading: PropTypes.bool, /** * When used, will give button an active state (Only for tertiary for now) */ diff --git a/packages/ui-toolkit/src/button/usage.md b/packages/ui-toolkit/src/button/usage.md index bfc82955..35d4ab04 100644 --- a/packages/ui-toolkit/src/button/usage.md +++ b/packages/ui-toolkit/src/button/usage.md @@ -1,5 +1,3 @@ -### with text - ```jsx @@ -8,7 +6,7 @@ ``` -### secondary +#### Button > Secondary ```jsx @@ -18,7 +16,7 @@ ``` -### tertiary +#### Button > Tertiary ```jsx @@ -30,7 +28,7 @@ ``` -### disabled +#### Button > Disabled ```jsx @@ -39,3 +37,12 @@ ``` + + +#### Button > Loading + +```jsx + + + +``` diff --git a/packages/ui-toolkit/src/status-loader/index.js b/packages/ui-toolkit/src/status-loader/index.js index 34358153..84c13eeb 100644 --- a/packages/ui-toolkit/src/status-loader/index.js +++ b/packages/ui-toolkit/src/status-loader/index.js @@ -41,9 +41,9 @@ const Msg = P.extend` margin-left: ${remcalc(6)}; `; -export default ({ msg, row, inline }) => ( +export default ({ msg, row, inline, small }) => ( - {msg || 'Loading...'} + {!small && {msg || 'Loading...'}} );