diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-02-15 16:59:58 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-02-15 16:59:58 -0500 |
| commit | 8f2c595eca30e2d7138c8e8d6685774a8f44e55d (patch) | |
| tree | 3408b9c8eb3b0ea43cb72e13e0bd6393ab5bac61 /frontend/components/ToggleCart.js | |
| parent | a09b01abf7c03e6b7e43f2175e5a34501808821b (diff) | |
omg
Diffstat (limited to 'frontend/components/ToggleCart.js')
| -rw-r--r-- | frontend/components/ToggleCart.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/frontend/components/ToggleCart.js b/frontend/components/ToggleCart.js new file mode 100644 index 0000000..c80baa6 --- /dev/null +++ b/frontend/components/ToggleCart.js @@ -0,0 +1,22 @@ +import { Component } from 'react'; +import { compose } from 'react-apollo'; +import { uiEnhancer, updateUIEnhancer } from '../enhancers/enhancers'; +import PropTypes from 'prop-types'; + +class ToggleCart extends Component { + static propTypes = { + render: PropTypes.func.isRequired, + toggleCart: PropTypes.func.isRequired, + ui: PropTypes.object.isRequired, + }; + toggle = e => { + // if this is a keyPress event, make sure it's the enter key + if (e.keyCode && e.keyCode !== 16) return; + this.props.toggleCart(!this.props.ui.uiData.isCartOpen); + }; + render() { + return this.props.render(this.toggle); + } +} + +export default compose(uiEnhancer, updateUIEnhancer)(ToggleCart); |
