|
@ -2,47 +2,34 @@ |
|
|
|
|
|
|
|
|
import React from 'react' |
|
|
import React from 'react' |
|
|
import noop from 'lodash/noop' |
|
|
import noop from 'lodash/noop' |
|
|
import styled, { keyframes } from 'styled-components' |
|
|
import styled from 'styled-components' |
|
|
|
|
|
|
|
|
import { Tabbable } from 'components/base/Box' |
|
|
import { Tabbable } from 'components/base/Box' |
|
|
import IconCheck from 'icons/Check' |
|
|
|
|
|
|
|
|
|
|
|
const bounce = keyframes` |
|
|
|
|
|
0% { |
|
|
|
|
|
transform: scale(1); |
|
|
|
|
|
} |
|
|
|
|
|
50% { |
|
|
|
|
|
transform: scale(1.5); |
|
|
|
|
|
} |
|
|
|
|
|
100% { |
|
|
|
|
|
transform: scale(1); |
|
|
|
|
|
} |
|
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
|
const Base = styled(Tabbable).attrs({ |
|
|
const Base = styled(Tabbable).attrs({ |
|
|
color: 'white', |
|
|
bg: p => (p.isChecked ? 'wallet' : 'fog'), |
|
|
alignItems: 'center', |
|
|
horizontal: true, |
|
|
justifyContent: 'center', |
|
|
align: 'center', |
|
|
})` |
|
|
})` |
|
|
cursor: pointer; |
|
|
backround: red; |
|
|
outline: none; |
|
|
width: 50px; |
|
|
border-radius: 3px; |
|
|
height: 24px; |
|
|
border: 1px solid transparent; |
|
|
border-radius: 16px; |
|
|
background-color: ${p => (p.isChecked ? p.theme.colors.wallet : p.theme.colors.white)}; |
|
|
transition: 250ms linear background-color; |
|
|
box-shadow: 0 0 0 ${p => (p.isChecked ? 4 : 1)}px |
|
|
|
|
|
${p => (p.isChecked ? p.theme.colors.lightGrey : p.theme.colors.graphite)}; |
|
|
|
|
|
font-size: 7px; |
|
|
|
|
|
height: 19px; |
|
|
|
|
|
width: 19px; |
|
|
|
|
|
transition: all ease-in 0.1s; |
|
|
|
|
|
|
|
|
|
|
|
&:focus { |
|
|
&:focus { |
|
|
border-color: ${p => p.theme.colors.fog}; |
|
|
box-shadow: rgba(0, 0, 0, 0.1) 0 2px 2px; |
|
|
|
|
|
outline: none; |
|
|
} |
|
|
} |
|
|
` |
|
|
` |
|
|
|
|
|
|
|
|
const IconWrapper = styled(IconCheck)` |
|
|
const Ball = styled.div` |
|
|
animation: ${bounce} ease-in-out 350ms; |
|
|
width: 22px; |
|
|
|
|
|
height: 22px; |
|
|
|
|
|
border-radius: 50%; |
|
|
|
|
|
background: white; |
|
|
|
|
|
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.15); |
|
|
|
|
|
transition: 250ms ease-in-out transform; |
|
|
|
|
|
transform: translate3d(${p => (p.isChecked ? '28px' : '0')}, 0, 0); |
|
|
` |
|
|
` |
|
|
|
|
|
|
|
|
type Props = { |
|
|
type Props = { |
|
@ -54,7 +41,7 @@ function CheckBox(props: Props) { |
|
|
const { isChecked, onChange, ...p } = props |
|
|
const { isChecked, onChange, ...p } = props |
|
|
return ( |
|
|
return ( |
|
|
<Base isChecked={isChecked} onClick={() => onChange && onChange(!isChecked)} {...p}> |
|
|
<Base isChecked={isChecked} onClick={() => onChange && onChange(!isChecked)} {...p}> |
|
|
{isChecked && <IconWrapper height={7} width={7} />} |
|
|
<Ball isChecked={isChecked} /> |
|
|
</Base> |
|
|
</Base> |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|