diff options
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); |
