Loëck Vézien
7 years ago
committed by
GitHub
3 changed files with 101 additions and 84 deletions
@ -0,0 +1,81 @@ |
|||
// @flow
|
|||
|
|||
import React, { Fragment } from 'react' |
|||
import styled from 'styled-components' |
|||
|
|||
import Box from 'components/base/Box' |
|||
|
|||
const Wrapper = styled(Box).attrs({ |
|||
align: 'center', |
|||
justify: 'center', |
|||
color: p => (p.isActive ? 'blue' : 'mouse'), |
|||
})` |
|||
width: 40px; |
|||
flex-shrink: 0; |
|||
text-align: center; |
|||
font-size: 9px; |
|||
` |
|||
|
|||
const Number = styled(Box).attrs({ |
|||
align: 'center', |
|||
justify: 'center', |
|||
color: p => (p.isActive ? 'white' : 'mouse'), |
|||
bg: p => (p.isActive ? 'blue' : 'pearl'), |
|||
})` |
|||
width: 20px; |
|||
height: 20px; |
|||
border-radius: 50%; |
|||
font-size: 9px; |
|||
box-shadow: ${p => `0 0 0 ${p.isActive ? 4 : 0}px ${p.theme.colors.cream}`}; |
|||
transition: all ease-in-out 0.1s ${p => (p.isActive ? 0.4 : 0)}s; |
|||
` |
|||
|
|||
const Bar = styled.div` |
|||
height: 2px; |
|||
background: ${p => p.theme.colors.pearl}; |
|||
flex-grow: 1; |
|||
position: relative; |
|||
|
|||
&:after { |
|||
background: ${p => p.theme.colors.pearl}; |
|||
content: ''; |
|||
display: block; |
|||
left: 0; |
|||
right: 0; |
|||
top: 0; |
|||
bottom: 0; |
|||
position: absolute; |
|||
background: ${p => p.theme.colors.blue}; |
|||
transition: transform ease-in-out 0.4s; |
|||
transform-origin: center left; |
|||
transform: scaleX(${p => (p.isActive ? 1 : 0)}); |
|||
} |
|||
` |
|||
|
|||
const Label = styled(Box)` |
|||
position: absolute; |
|||
margin-top: 30px; |
|||
transition: color ease-in-out 0.1s ${p => (p.isActive ? 0.4 : 0)}s; |
|||
` |
|||
|
|||
type Props = { |
|||
number: number, |
|||
isActive: boolean, |
|||
isFirst: boolean, |
|||
children: any, |
|||
} |
|||
|
|||
function Step(props: Props) { |
|||
const { number, isActive, isFirst, children } = props |
|||
return ( |
|||
<Fragment> |
|||
{!isFirst && <Bar isActive={isActive} />} |
|||
<Wrapper isActive={isActive}> |
|||
<Number isActive={isActive}>{number}</Number> |
|||
<Label isActive={isActive}>{children}</Label> |
|||
</Wrapper> |
|||
</Fragment> |
|||
) |
|||
} |
|||
|
|||
export default Step |
Loading…
Reference in new issue