Last active
August 7, 2018 18:48
-
-
Save hpierre74/f53cbc7569cd9a8253f982f2059b1ffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import styled, { keyframes } from 'styled-components'; | |
import { requireAnimation } from 'YOUR_PATH'; | |
const AnimationWrapper = styled.div` | |
animation: ${({ duration }) => duration}s ${({ animation }) => animation}; | |
`; | |
const withAnim = Component => { | |
const withAnimHOC = props => ( | |
<AnimationWrapper | |
duration={props.duration} | |
animation={keyframes`${requireAnimation(props.animation)}`}> | |
<Component {...props} /> | |
</AnimationWrapper> | |
); | |
withAnimHOC.defaultProps = { | |
duration: '1.5', | |
}; | |
withAnimHOC.propTypes = { | |
animation: PropTypes.string.isRequired, | |
duration: PropTypes.string, | |
}; | |
return withAnimHOC; | |
}; | |
export default withAnim; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment