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 { addUserProfile } from '@lib/user.actions'; | |
export const createProfile = ({ profileName, profileId, avatarUrl }) => async (dispatch, getState) => { | |
await fetch('/api/profile', { method: 'POST', body: JSON.stringify({ profileId, profileName, avatarUrl }) }); | |
dispatch(addUserProfile(profileId)); | |
return dispatch({ type: 'CREATE_PROFILE', payload: { profileId, profileName, avatarUrl }); | |
}; |
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
export const createUser = ({ username, password }) => async (dispatch, getState) => { | |
await fetch('/api/user', { method: 'POST', body: JSON.stringify({ username, password }) }; | |
return dispatch({ type: 'CREATED_USER', payload: { username } }); | |
}; | |
export const addUserProfile = profileId => ({ type: 'ADDED_USER_PROFILE', payload: { profileId } }); |
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 withAnim from './withAnim.hoc.js'; | |
const AnyComponent = () => <p>I am a simple Component</p>; | |
const AnimatedComponent = withAnim(AnyComponent); | |
const AnyWrapper = () => ( | |
<div> | |
<AnimatedComponent animation='slideInDown' /> | |
</div> |
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, { Component } from "react"; | |
import PropTypes from "prop-types"; | |
import styled, { keyframes } from "styled-components"; | |
const AnimationWrapper = styled.div` | |
animation: ${({ duration }) => duration}s ${({ animation }) => animation}; | |
`; | |
const withAnim = ComponentToAnimate => { | |
class WithAnimHoc extends Component { |
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
<App duration='3' animation='bounceIn' /> |
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 withAnim from './withAnim.hoc'; | |
const App = () => (<div>I am animated</div>); | |
export default withAnim(App); |
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 => { |
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
// this function could be in the theme or anywhere you see fit | |
// eslint will complain about it, you might get errors if you | |
// use different webpacks bundles | |
export const requireAnimation = animation => | |
require(`react-animations/lib/${animation}`).default; | |
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 styled from 'styled-components'; | |
export const SlideInDownWrapper = styled.div` | |
${ ({ theme: { utils } }) => utils.slideInDown(1.5) }; | |
`; | |
export const RotateInWrapper = styled.div` | |
${ ({ theme: { utils } }) => utils.rotateIn(1.5) }; | |
`; |
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 styled from 'styled-components'; | |
const AnimatedComponent = styled.div` | |
${ ({ theme: { utils } }) => utils.slideInDown(1.5) }; | |
`; | |
const YourComponent = () => <AnimatedComponent>I am animated</AnimatedComponent>; | |
export default YourComponent; |
NewerOlder