diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
| commit | cd0b07b3adb36fb5ec098f9e511ab45d774fee7b (patch) | |
| tree | a203e5010219ccea1acc6bbd2c0a4bcfa0a78615 /frontend/components/ChaChing.js | |
| parent | 0a1648bf47490b312169c531aeb51ef4725e8d2e (diff) | |
Move to Prisma Backend
Diffstat (limited to 'frontend/components/ChaChing.js')
| -rw-r--r-- | frontend/components/ChaChing.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/frontend/components/ChaChing.js b/frontend/components/ChaChing.js new file mode 100644 index 0000000..5874c27 --- /dev/null +++ b/frontend/components/ChaChing.js @@ -0,0 +1,56 @@ +import TransitionGroup from 'react-transition-group/TransitionGroup'; +import Transition from 'react-transition-group/Transition'; +import styled from 'styled-components'; + +const CartCount = styled.div` + padding: 10px; + transition: all 0.5s; + display: inline-block; + background: white; + background: linear-gradient(to bottom, #eeeeee 0%, #eeeeee 100%); + transform: translateY(100%); + z-index: 1; + position: relative; + &.cart-entering { + background: green; + transform: translateY(100%); + } + &.cart-entered { + transform: translateY(0); + } + &.cart-exiting { + position: absolute; + z-index: 0; + left: 0; + transform: translateY(-100%); + } +`; + +const ChaChingStyles = styled.div` + position: relative; + display: inline-block; + overflow: hidden; +`; + +const ChaChing = ({ amount }) => ( + <ChaChingStyles> + <TransitionGroup> + <Transition + in + timeout={{ + enter: 0, + exit: 500, + }} + key={amount} + > + {status => ( + <CartCount className={`cart-${status}`} key={`count-${amount}`}> + {amount} + </CartCount> + )} + </Transition> + </TransitionGroup> + </ChaChingStyles> +); + +export default ChaChing; |
