From 8f74045cbbb613cd8e2dfed9717e5b7c09b80589 Mon Sep 17 00:00:00 2001 From: meriadec Date: Wed, 28 Feb 2018 15:44:33 +0100 Subject: [PATCH] Update button style --- src/components/base/Button/index.js | 21 ++++++++++--- src/components/base/Button/stories.js | 45 +++++++++++++++++++++++++-- src/styles/helpers.js | 10 ++++++ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/components/base/Button/index.js b/src/components/base/Button/index.js index e410280c..dab8cbc6 100644 --- a/src/components/base/Button/index.js +++ b/src/components/base/Button/index.js @@ -5,6 +5,8 @@ import styled from 'styled-components' import { space, fontSize, fontWeight, color } from 'styled-system' import noop from 'lodash/noop' +import { darken, lighten } from 'styles/helpers' + import Box from 'components/base/Box' import Icon from 'components/base/Icon' @@ -14,11 +16,19 @@ const Base = styled.button` ${fontSize}; ${fontWeight}; border-radius: 5px; - border: ${p => (p.primary ? '' : `1px solid ${p.theme.colors.fog}`)}; + border: ${p => + p.primary ? 'none' : `2px solid ${p.disabled ? 'transparent' : p.theme.colors.grey}`}; cursor: ${p => (p.disabled ? 'default' : 'pointer')}; height: 40px; - box-shadow: ${p => (p.withShadow ? 'rgba(0, 0, 0, 0.2) 0 3px 10px' : '')}; outline: none; + + &:hover { + background: ${p => (p.primary ? lighten(p.theme.colors.wallet, 0.05) : '')}; + } + + &:active { + background: ${p => (p.primary ? darken(p.theme.colors.wallet, 0.1) : '')}; + } ` type Props = { @@ -33,6 +43,7 @@ function getProps({ disabled, icon, primary }: Object) { const props = (predicate, props, defaults = {}) => (predicate ? props : defaults) return { + color: 'grey', ...props( icon, { @@ -49,7 +60,6 @@ function getProps({ disabled, icon, primary }: Object) { { color: 'white', bg: 'wallet', - withShadow: true, }, { bg: 'transparent', @@ -58,12 +68,13 @@ function getProps({ disabled, icon, primary }: Object) { ...props(disabled, { color: 'white', bg: 'fog', - withShadow: false, }), } } -const Button = ({ children, onClick, primary, icon, disabled, ...props }: Props) => { +const Button = (props: Props) => { + const { onClick, primary, icon, disabled } = props + let { children } = props children = icon ? ( diff --git a/src/components/base/Button/stories.js b/src/components/base/Button/stories.js index 76e65299..9c79523a 100644 --- a/src/components/base/Button/stories.js +++ b/src/components/base/Button/stories.js @@ -2,10 +2,51 @@ import React from 'react' import { storiesOf } from '@storybook/react' +import styled from 'styled-components' import Button from 'components/base/Button' const stories = storiesOf('Components/Button', module) -stories.add('basic', () => ) -stories.add('primary', () => ) +const Th = styled.th` + padding: 20px; +` + +const Td = styled.td` + padding: 20px; + min-width: 150px; +` + +stories.add('all', () => ( + + + + + + + + + + + + + + + + + + + +
+ normaldisabled
normal + + + +
primary + + + +
+)) diff --git a/src/styles/helpers.js b/src/styles/helpers.js index 3775c0c0..c1d8d463 100644 --- a/src/styles/helpers.js +++ b/src/styles/helpers.js @@ -11,6 +11,16 @@ export const rgba = (c: string, a: number) => .rgb() .toString() +export const darken = (c: string, a: number) => + Color(c) + .darken(a) + .toString() + +export const lighten = (c: string, a: number) => + Color(c) + .lighten(a) + .toString() + export const ff = (v: string) => { const [font, type = 'Regular'] = v.split('|') const { style, weight } = fontFamilies[font][type]