From 4e4ef61947ecb7d44f00cbd9b53ccd61eeae4817 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Fri, 5 Oct 2018 21:50:28 +0200 Subject: [PATCH] feat(ui): add Button component --- app/components/UI/Button.js | 83 +++++++++++++++++++ stories/components/button.stories.js | 56 +++++++++++++ test/unit/components/UI/Button.spec.js | 10 +++ .../UI/__snapshots__/Button.spec.js.snap | 59 +++++++++++++ 4 files changed, 208 insertions(+) create mode 100644 app/components/UI/Button.js create mode 100644 stories/components/button.stories.js create mode 100644 test/unit/components/UI/Button.spec.js create mode 100644 test/unit/components/UI/__snapshots__/Button.spec.js.snap diff --git a/app/components/UI/Button.js b/app/components/UI/Button.js new file mode 100644 index 00000000..510b4b7c --- /dev/null +++ b/app/components/UI/Button.js @@ -0,0 +1,83 @@ +import React from 'react' +import PropTypes from 'prop-types' +import styled from 'styled-components' +import { Button as BaseButton, Flex, Text } from 'rebass' +import Spinner from './Spinner' + +const Wrapper = styled(BaseButton)` + transition: all 0.25s; + outline: none; + border-radius: 5; + font-weight: normal; + line-height: '18px'; + &:focus { + box-shadow: 0 0 3px ${props => props.theme.lightningOrange}; + } + &:disabled { + opacity: 0.5; + } + &:hover:enabled { + cursor: pointer; + } +` +Wrapper.displayName = 'Button' + +/** + * @render react + * @name Button + * @example + * ) + .add('With Icon', () => ( +
+ {' '} + +
+ )) + .add('Processing', () => ( + + )) + .add('Disabled', () => ( + + )) + .add('Primary', () => ( + + )) + .add('Secondary', () => ( + + )) + .add('Small', () => ( + + )) + .add('Medium', () => ( + + )) + .add('Large', () => ( + + )) diff --git a/test/unit/components/UI/Button.spec.js b/test/unit/components/UI/Button.spec.js new file mode 100644 index 00000000..feac8b98 --- /dev/null +++ b/test/unit/components/UI/Button.spec.js @@ -0,0 +1,10 @@ +import React from 'react' +import Button from 'components/UI/Button' +import renderer from 'react-test-renderer' + +describe('component.UI.Button', () => { + it('should render correctly', () => { + const tree = renderer.create( +`;