diff --git a/src/components/Breadcrumb/index.js b/src/components/Breadcrumb/index.js new file mode 100644 index 00000000..60a446f3 --- /dev/null +++ b/src/components/Breadcrumb/index.js @@ -0,0 +1,87 @@ +// @flow + +import React from 'react' +import styled from 'styled-components' + +import Box from 'components/base/Box' + +const BreadcrumbWrapper = styled(Box).attrs({ + horizontal: true, + align: 'center', + flow: 20, + relative: true, +})`` +const BreadcrumbStep = styled(({ start, active, end, ...props }) => ( + +)).attrs({ + color: p => (p.active ? 'blue' : 'mouse'), + align: 'center', + flow: 5, + grow: p => !p.start && !p.end, + ml: p => p.end && 20, + mr: p => p.start && 20, + relative: true, +})` + &:before, + &:after { + content: ' '; + display: ${p => (p.start ? 'none' : 'block')}; + height: 2px; + position: absolute; + left: -120px; + background: ${p => p.theme.colors.pearl}; + margin-top: 8px; + width: 200px; + } + + &:after { + background: ${p => p.theme.colors.blue}; + width: ${p => (p.active ? 200 : 0)}px; + transition: width ease-in-out 0.4s; + } +` +const BreadcrumbNumberWrapper = styled(Box).attrs({ + bg: 'white', + px: 3, + relative: true, +})` + z-index: 1; +` +const BreadcrumbNumber = styled(Box).attrs({ + color: p => (p.active ? 'white' : 'mouse'), + bg: p => (p.active ? 'blue' : 'pearl'), + align: 'center', + justify: 'center', +})` + border-radius: 50%; + box-shadow: ${p => `0 0 0 ${p.active ? 4 : 0}px ${p.theme.colors.cream}`}; + font-size: 9px; + height: 20px; + width: 20px; + transition: all ease-in-out 0.1s; +` + +const Breadcrumb = ({ items, currentStep }: Object) => ( + + {items.map((item, i) => { + const active = i < currentStep + const start = i === 0 + const end = i + 1 === items.length + return ( + + + {i + 1} + + {item.label} + + ) + })} + +) + +export default Breadcrumb diff --git a/src/components/Breadcrumb/stories.js b/src/components/Breadcrumb/stories.js new file mode 100644 index 00000000..78c92c48 --- /dev/null +++ b/src/components/Breadcrumb/stories.js @@ -0,0 +1,21 @@ +// @flow + +import React from 'react' +import { storiesOf } from '@storybook/react' +import { number } from '@storybook/addon-knobs' + +import Breadcrumb from 'components/Breadcrumb' + +const stories = storiesOf('Breadcrumb', module) + +stories.add('basic', () => ( + +)) diff --git a/src/components/modals/Send.js b/src/components/modals/Send.js index 36f77de3..43292995 100644 --- a/src/components/modals/Send.js +++ b/src/components/modals/Send.js @@ -2,7 +2,6 @@ import React, { Fragment, PureComponent } from 'react' import { translate } from 'react-i18next' -import styled from 'styled-components' import get from 'lodash/get' import type { T } from 'types/common' @@ -14,57 +13,11 @@ import Button from 'components/base/Button' import Input from 'components/base/Input' import Label from 'components/base/Label' import Modal, { ModalBody } from 'components/base/Modal' +import Breadcrumb from 'components/Breadcrumb' import RecipientAddress from 'components/RecipientAddress' import SelectAccount from 'components/SelectAccount' import Text from 'components/base/Text' -const BreadcrumbWrapper = styled(Box).attrs({ - horizontal: true, - align: 'center', - flow: 20, - relative: true, -})`` -const BreadcrumbStep = styled(({ start, active, end, ...props }) => ( - -)).attrs({ - color: p => (p.active ? 'blue' : 'mouse'), - align: 'center', - flow: 5, - grow: p => !p.start && !p.end, - ml: p => p.end && 20, - mr: p => p.start && 20, -})` - &:before { - content: ' '; - display: block; - height: 2px; - position: absolute; - left: 20px; - right: 20px; - background: ${p => p.theme.colors.pearl}; - margin-top: 8px; - } -` -const BreadcrumbNumberWrapper = styled(Box).attrs({ - bg: 'white', - px: 3, - relative: true, -})` - z-index: 1; -` -const BreadcrumbNumber = styled(Box).attrs({ - color: p => (p.active ? 'white' : 'mouse'), - bg: p => (p.active ? 'blue' : 'pearl'), - align: 'center', - justify: 'center', -})` - border-radius: 50%; - box-shadow: ${p => p.active && `0 0 0 4px ${p.theme.colors.cream}`}; - font-size: 9px; - height: 20px; - width: 20px; -` - const Steps = { '1': ({ t, ...props }: Object) => (
{ } } -const Breadcrumb = ({ items, currentStep }: Object) => ( - - {items.map((item, i) => { - const active = i < currentStep - const start = i === 0 - const end = i + 1 === items.length - return ( - - - {i + 1} - - {item.label} - - ) - })} - -) - export default translate()(Send)