diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-03-12 14:06:25 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-03-12 14:06:25 -0400 |
| commit | 46a0ba30ef54a7e36206481a4f5b2bf1f9702fca (patch) | |
| tree | a95fd534fc27761d8b26d0dffcdb5f300f7a61c7 /frontend/components/CartCount.js | |
| parent | f7bea2d1b7be2b70dceb25c9837f608b538e9cec (diff) | |
wip
Diffstat (limited to 'frontend/components/CartCount.js')
| -rw-r--r-- | frontend/components/CartCount.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/frontend/components/CartCount.js b/frontend/components/CartCount.js new file mode 100644 index 0000000..245b07b --- /dev/null +++ b/frontend/components/CartCount.js @@ -0,0 +1,52 @@ +import styled from 'styled-components'; +import { TransitionGroup, CSSTransition } from 'react-transition-group'; + +const Dot = styled.div` + background: ${props => props.theme.red}; + color: white; + border-radius: 50%; + padding: 5px; + margin-left: 1rem; + font-weight: 100; + font-feature-settings: 'tnum'; + font-variant-numeric: tabular-nums; +`; + +const AnimationStyles = styled.span` + position: relative; + .count { + display: block; + position: relative; + transition: all 0.4s; + backface-visibility: hidden; + } + .count-enter { + transform: rotateX(0.5turn); + } + + .count-enter-active { + transform: rotateX(0); + } + + .count-exit { + top: 0; + position: absolute; + transform: rotateX(0); + } + + .count-exit-active { + transform: rotateX(0.5turn); + } +`; + +const CartCount = ({ count }) => ( + <AnimationStyles> + <TransitionGroup> + <CSSTransition className="count" classNames="count" key={count} timeout={{ enter: 2000, exit: 2000 }}> + <Dot>{count}</Dot> + </CSSTransition> + </TransitionGroup> + </AnimationStyles> +); + +export default CartCount; |
