├── .babelrc
├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── README.md
├── lerna.json
├── package.json
├── packages
├── README.md
├── ac-inferno
│ ├── .babelrc
│ ├── .flowconfig
│ ├── .gitignore
│ ├── README.md
│ ├── animations
│ │ └── index.js
│ ├── containers
│ │ ├── Delay.js
│ │ ├── Disappear.js
│ │ ├── HOC.js
│ │ └── merge.js
│ ├── flow-typed
│ │ └── npm
│ │ │ ├── inferno-component_vx.x.x.js
│ │ │ ├── inferno-create-element_vx.x.x.js
│ │ │ ├── inferno_vx.x.x.js
│ │ │ └── styled-components_v2.x.x.js
│ ├── index.js
│ ├── main.js
│ ├── package.json
│ ├── utils
│ │ ├── Render.js
│ │ ├── getElement.js
│ │ ├── index.js
│ │ └── state.js
│ ├── webpack.config.js
│ └── webpack
│ │ ├── config.js
│ │ └── webpack.config.js
├── animate-components
│ ├── .babelrc
│ ├── .eslintrc.js
│ ├── .flowconfig
│ ├── .gitignore
│ ├── README.md
│ ├── __tests__
│ │ ├── __snapshots__
│ │ │ ├── delay.test.js.snap
│ │ │ └── merge.test.js.snap
│ │ ├── delay.test.js
│ │ ├── derive.test.js
│ │ ├── hoc.test.js
│ │ └── merge.test.js
│ ├── animations
│ │ └── index.js
│ ├── containers
│ │ ├── Delay.js
│ │ ├── Disappear.js
│ │ ├── HOC.js
│ │ └── merge.js
│ ├── docs
│ │ ├── README.md
│ │ ├── api.md
│ │ ├── example.md
│ │ ├── performance.md
│ │ ├── tips.md
│ │ └── usage.md
│ ├── examples
│ │ ├── App.js
│ │ ├── Disappear.js
│ │ ├── comp.js
│ │ ├── componentProp.js
│ │ ├── delay.js
│ │ ├── domNesting.js
│ │ ├── forceInterpolate.js
│ │ ├── multistep.js
│ │ ├── renderElementType.js
│ │ └── simple.js
│ ├── flow-typed
│ │ └── npm
│ │ │ ├── animate-keyframes_vx.x.x.js
│ │ │ ├── element-utils_vx.x.x.js
│ │ │ ├── html-tags_vx.x.x.js
│ │ │ ├── prop-types_v15.x.x.js
│ │ │ └── styled-components_v2.x.x.js
│ ├── index.js
│ ├── main.js
│ ├── package.json
│ ├── utils
│ │ ├── keyValidators.js
│ │ └── state.js
│ └── webpack
│ │ ├── config.js
│ │ └── webpack.config.js
├── animate-keyframes
│ ├── .babelrc
│ ├── .flowconfig
│ ├── .gitignore
│ ├── README.md
│ ├── flow-typed
│ │ └── npm
│ │ │ └── styled-components_v2.x.x.js
│ ├── index.js
│ ├── package.json
│ └── src
│ │ ├── keyframes.js
│ │ └── main.js
└── element-utils
│ ├── .babelrc
│ ├── .flowconfig
│ ├── .gitignore
│ ├── README.md
│ ├── __tests__
│ └── mods.test.js
│ ├── package.json
│ └── src
│ ├── Render.js
│ ├── getElement.js
│ └── index.js
├── scripts
└── check.js
├── starter
├── App.js
├── comp.js
├── index.css
├── index.js
└── webpack.config.js
├── tasks.md
├── typings
└── animate-components.js
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "react", "babili"],
3 | "plugins": ["transform-object-rest-spread", "transform-class-properties"]
4 | }
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | /node_modules
3 | build
4 | coverage
5 | dist
6 | starter
7 |
8 | # misc
9 | .DS_Store
10 | .env
11 | npm-debug.log*
12 | lerna-debug.log
13 | yarn.lock
14 | yarn-error.log
15 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | cache:
4 | directories:
5 | - node_modules
6 | notifications:
7 | email: false
8 | node_js:
9 | - iojs
10 |
11 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing Guide
2 |
3 |
4 | It would be super exciting if you want to contribute to `animate-components`.
5 |
6 | ### Creating animation components
7 | To create an animation component, create two new files. For example - `newAnimation.js` & `styledNewAnimation.js` in `src` directory.
8 |
9 | Define the keyframes for the animation in `styledNewAnimation.js` using [styled-components](https://github.com/styled-components/styled-components).
10 |
11 | ```javascript
12 | // styledNewAnimation.js
13 |
14 | import { keyframes } from 'styled-components';
15 |
16 | const newAnimation = keyframes`
17 | from {
18 |
19 | }
20 |
21 | to {
22 |
23 | }
24 | `;
25 |
26 | export default newAnimation;
27 | ```
28 |
29 | The reason we require `styledNewAnimation.js` is to isolate the styles from the components. Makes the code readable and easy to test.
30 |
31 | Import the [high order component](https://medium.com/@franleplant/react-higher-order-components-in-depth-cf9032ee6c3e) present in the **animation** folder. You can find it [here](https://github.com/nitin42/animate-components/blob/master/src/containers/HOC.js).
32 |
33 | Export the component like this,
34 |
35 | ```javascript
36 | // newAnimation.js
37 |
38 | import { newAnimation } from './styledNewAnimation';
39 |
40 | import HOC from '../../containers/HOC'; // High Order Component
41 |
42 | export default HOC('NewAnimation', newAnimation); // Creates the component
43 | ```
44 |
45 | > Note - HOC takes two arguments, one is the name of your component and the other is the keyframe defined for the animation.
46 |
47 |
48 | If you want to create multiple animation components, create a single object and export it.
49 |
50 | ```javascript
51 | // newAnimation.js
52 |
53 | import {newAnimation, newAnimationTwo, newAnimationThree } from './styledNewAnimation';
54 |
55 | import HOC from '../../containers/HOC';
56 |
57 | const newAnimationObj = {
58 | NewAnimation: HOC('NewAnimation', newAnimation),
59 | NewAnimationTwo: HOC('NewAnimationTwo', newAnimationTwo),
60 | NewAnimationThree: HOC('NewAnimationThree', newAnimationThree)
61 | };
62 |
63 | export default newAnimationObj;
64 | ```
65 |
66 | ### Typechecking with Flow
67 | Add type annotations to your components.
68 |
69 | ```javascript
70 | // newAnimation.js
71 |
72 | import {newAnimation, newAnimationTwo, newAnimationThree } from './styledNewAnimation';
73 |
74 | import HOC from '../../containers/HOC';
75 |
76 | import type { Components } from '../../../types';
77 |
78 | const newAnimationObj: Components = {
79 | NewAnimation: HOC('NewAnimation', newAnimation),
80 | NewAnimationTwo: HOC('NewAnimationTwo', newAnimationTwo),
81 | NewAnimationThree: HOC('NewAnimationThree', newAnimationThree)
82 | };
83 |
84 | export default newAnimationObj;
85 | ```
86 |
87 | Run `yarn flow`
88 |
89 | ### Export animation component
90 |
91 | In [index.js](https://github.com/nitin42/animate-components/blob/master/src/index.js), import the object or the component created earlier (`newAnimation.js`), extract different components from the object if any and then finally export them.
92 |
93 | ```javascript
94 | import newAnimationObj from './newAnimation';
95 |
96 | const {...components} = newAnimationObj;
97 |
98 | export {...components};
99 |
100 | ```
101 |
102 | ### ESLint
103 | Run `yarn lint`.
104 |
105 | ### Build
106 | Run `yarn webpack:build`
107 |
108 | ### Running the animations
109 | There is a small [starter kit](https://github.com/nitin42/animate-components/tree/master/starter) kit for testing the animations.
110 |
111 | ```javascript
112 | // ./starter/App.js
113 |
114 | import React, { Component } from 'react';
115 |
116 | import { ExpanseDown } from '../index';
117 |
118 | export default class App extends Component {
119 | render () {
120 | return (
121 |
122 | Hello World
123 |
124 | );
125 | }
126 | }
127 | ```
128 | Start the server using `yarn start` and you're ready to go.
129 |
130 | That's it ! I'm excited to see your pull request.
131 |
132 | There's lot to be done. Thanks ❤️
133 |
134 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **Looking for maintainers. Please reach out to me if you're interested!**
2 |
3 | # Animate Components
4 |
5 | > ***Elemental components for doing animation in React***
6 |
7 | ## Packages
8 | This repository uses [Lerna](https://lernajs.io/) to organise the codebase.
9 |
10 | | Package | Version | Description |
11 | | ------------- |:-------------:| -----:|
12 | | [`animate-keyframes`](./packages/animate-keyframes) |  | Keyframes for animations |
13 | | [`animate-components`](./packages/animate-components) |  | Components for animations |
14 | | [`element-utils`](./packages/element-utils) |  | Utility functions for `animate-components` |
15 | | [`ac-inferno`](./packages/ac-inferno) |  | `animate-components` for InfernoJS |
16 |
17 | ## Docs
18 | View the docs [here](./packages)
19 |
20 | ## Support
21 |
22 | Animate Components also supports [InfernoJS](infernojs.org) (separate package so `inferno-compat` is not required) and [Preact](preactjs.com) (with `preact-compat`).
23 |
24 | Why a separate package for InfernoJS ? Read [here](https://github.com/nitin42/animate-components/tree/master/packages/ac-inferno#why-a-separate-package-for-infernojs-instead-of-using-animate-components-with-inferno-compat-).
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "lerna": "2.0.0-rc.5",
3 | "packages": [
4 | "packages/*"
5 | ],
6 | "version": "independent",
7 | "npmClient": "yarn"
8 | }
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "animate-components-packages",
3 | "version": "0.0.2",
4 | "description": "Contains packages for animate-components",
5 | "keywords": [
6 | "react",
7 | "keyframes",
8 | "animate",
9 | "high order component",
10 | "composed components",
11 | "animations",
12 | "styled",
13 | "renderer",
14 | "block",
15 | "renderer",
16 | "styled",
17 | "custom elements"
18 | ],
19 | "main": "index.js",
20 | "scripts": {
21 | "postinstall": "lerna bootstrap --concurrency=1",
22 | "start:react": "cd packages/animate-components && yarn start",
23 | "start:inferno": "cd packages/ac-inferno && yarn start",
24 | "lint": "cd packages/animate-components && yarn lint",
25 | "test": "cd packages/animate-components && yarn test",
26 | "build:react": "cd packages/animate-components && yarn webpack:build",
27 | "build:inferno": "cd packages/ac-inferno && yarn webpack",
28 | "server": "./node_modules/.bin/webpack-dev-server --config ./starter/webpack.config.js"
29 | },
30 | "jest": {
31 | "testEnvironment": "node"
32 | },
33 | "devDependencies": {
34 | "babel-loader": "^7.0.0",
35 | "babel-plugin-transform-class-properties": "^6.24.1",
36 | "babel-plugin-transform-object-rest-spread": "^6.23.0",
37 | "babel-preset-babili": "^0.1.3",
38 | "babel-preset-es2015": "^6.24.1",
39 | "babel-preset-react": "^6.24.1",
40 | "css-loader": "^0.28.4",
41 | "html-webpack-plugin": "^2.28.0",
42 | "html-webpack-template": "^6.0.1",
43 | "lerna": "2.0.0-rc.5",
44 | "style-loader": "^0.18.2",
45 | "webpack": "^2.6.1",
46 | "webpack-dev-server": "^2.4.5",
47 | "react": "^16.0.0",
48 | "react-dom": "^16.0.0"
49 | },
50 | "dependencies": {
51 | "animate-keyframes": "^0.1.3",
52 | "glamorous-native": "^1.1.0",
53 | "html-tags": "^2.0.0",
54 | "inferno": "^3.6.1",
55 | "inferno-component": "^3.6.1"
56 | },
57 | "peerDependencies": {
58 | "react": "^15.6.1",
59 | "react-dom": "^15.6.1",
60 | "react-primitives": "^0.4.3"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/packages/README.md:
--------------------------------------------------------------------------------
1 | ## Docs
2 |
3 | * [Docs](./animate-keyframes/) for `animate-keyframes`.
4 | * [Docs](./animate-components/docs) for `animate-components`.
5 | * [Docs](./ac-inferno) for `ac-inferno` (Animate Components for Inferno).
6 |
--------------------------------------------------------------------------------
/packages/ac-inferno/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["flow", "es2015"],
3 | "env": {
4 | "production": {
5 | "plugins": [
6 | "inferno",
7 | "transform-object-rest-spread",
8 | "transform-class-properties",
9 | "transform-flow-strip-types"
10 | ]
11 | },
12 | "development": {
13 | "plugins": [
14 | "inferno",
15 | "transform-object-rest-spread",
16 | "transform-class-properties"
17 | ]
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/ac-inferno/.flowconfig:
--------------------------------------------------------------------------------
1 | [include]
2 | ./containers
3 | ./utils
4 | ./animations
5 |
6 | [ignore]
7 | .*/node_modules/styled-components/.*
8 | .*/node_modules/
9 |
--------------------------------------------------------------------------------
/packages/ac-inferno/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/packages/ac-inferno/README.md:
--------------------------------------------------------------------------------
1 | # ac-inferno (Animate Components for Inferno)
2 | 
3 | 
4 | 
5 |
6 |
7 |
8 |
9 |
10 | ## Install
11 |
12 | **npm**
13 |
14 | ```
15 | npm install ac-inferno
16 | ```
17 |
18 | **yarn**
19 |
20 | ```
21 | yarn add ac-inferno
22 | ```
23 |
24 | The [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com):
25 |
26 | ```html
27 |
28 | ```
29 |
30 | #### Why a separate package for InfernoJS instead of using `animate-components` with `Inferno-compat` ?
31 |
32 | * Cost in performance.
33 | * Strange errors (specially with `Disappear` component).
34 | * Reduce build size with Inferno.
35 |
36 | ## Docs
37 | View the complete documentation [here](https://github.com/nitin42/animate-components/tree/master/packages/animate-components/docs) (API is similar for both React and Inferno).
38 |
39 | ## Animations
40 |
41 | Below is a list of all available animations (Components).
42 |
43 | ### Bounce
44 |
45 | * `Bounce`
46 | * `BounceUp`
47 | * `BounceRight`
48 | * `BounceLeft`
49 | * `BounceDown`
50 |
51 | ### Fade
52 |
53 | * `FadeIn`
54 | * `FadeInRightBig`
55 | * `FadeInRight`
56 | * `FadeInLeftBig`
57 | * `FadeInLeft`
58 | * `FadeInDown`
59 | * `FadeInDownBig`
60 | * `FadeInUp`
61 | * `FadeInUpBig`
62 |
63 | ### Flip
64 |
65 | * `Flip`
66 | * `FlipX`
67 | * `FlipY`
68 |
69 | ### LightSpeed
70 |
71 | * `LightOut`
72 | * `LightIn`
73 |
74 | ### Rotate
75 |
76 | * `RotateIn`
77 | * `RotateRight`
78 | * `RotateLeft`
79 | * `RotateUpRight`
80 | * `RotateUpLeft`
81 |
82 | ### Slide
83 |
84 | * `SlideUp`
85 | * `SlideDown`
86 | * `SlideLeft`
87 | * `SlideRight`
88 |
89 | ### Special
90 |
91 | * `Flash`
92 | * `RollOut`
93 | * `RollIn`
94 | * `Rubber`
95 | * `Swing`
96 | * `Zoom`
97 | * `Hinge`
98 | * `Pulse`
99 | * `ExpandUp`
100 | * `Entrance`
101 | * `Hatch`
102 | * `StarWars`
103 |
104 | ## 🚀 New
105 | ### Perspective
106 |
107 | * `PDown`
108 | * `PUp`
109 | * `PLeft`
110 | * `PRight`
111 |
112 | ### Bingo
113 |
114 | * `PuffOut`
115 | * `PuffIn`
116 | * `VanishOut`
117 | * `VanishIn`
118 |
119 | ### Expanse (in space)
120 |
121 | * `ExpanseUp`
122 | * `ExpanseDown`
123 | * `ExpanseLeft`
124 | * `ExpanseRight`
125 |
--------------------------------------------------------------------------------
/packages/ac-inferno/animations/index.js:
--------------------------------------------------------------------------------
1 | import {
2 | bounce,
3 | bounceDown,
4 | bounceLeft,
5 | bounceRight,
6 | bounceUp,
7 | fadeIn,
8 | left,
9 | down,
10 | downBig,
11 | leftBig,
12 | rightBig,
13 | right,
14 | up,
15 | upBig,
16 | flip,
17 | flipInX,
18 | flipInY,
19 | flipOutX,
20 | flipOutY,
21 | lightIn,
22 | lightOut,
23 | rotateIn,
24 | rotateLeft,
25 | rotateRight,
26 | rotateUpLeft,
27 | rotateUpRight,
28 | flash,
29 | rollOut,
30 | rollIn,
31 | rubber,
32 | swing,
33 | zoom,
34 | hinge,
35 | hingeDrop,
36 | pulse,
37 | expandUp,
38 | entrance,
39 | hatch,
40 | starWars,
41 | slideDown,
42 | slideLeft,
43 | slideRight,
44 | slideUp,
45 | perspectiveDown,
46 | perspectiveUp,
47 | perspectiveLeft,
48 | perspectiveRight,
49 | puffmein,
50 | puffmeout,
51 | vanishout,
52 | vanishin,
53 | expanseDown,
54 | expanseUp,
55 | expanseLeft,
56 | expanseRight,
57 | } from 'animate-keyframes';
58 | import hoc from '../containers/HOC';
59 |
60 | // Animate Components
61 | const bingoObj = {
62 | PuffOut: hoc('PuffOut', puffmeout),
63 | PuffIn: hoc('PuffIn', puffmein),
64 | VanishOut: hoc('VanishOut', vanishout),
65 | VanishIn: hoc('VanishIn', vanishin),
66 | };
67 |
68 | const bounceObj = {
69 | Bounce: hoc('Bounce', bounce),
70 | BounceDown: hoc('BounceDown', bounceDown),
71 | BounceUp: hoc('BounceUp', bounceUp),
72 | BounceLeft: hoc('BounceLeft', bounceLeft),
73 | BounceRight: hoc('BounceRight', bounceRight),
74 | };
75 |
76 | const expanseObj = {
77 | ExpanseUp: hoc('ExpanseUp', expanseUp),
78 | ExpanseDown: hoc('ExpanseDown', expanseDown),
79 | ExpanseLeft: hoc('ExpanseLeft', expanseLeft),
80 | ExpanseRight: hoc('ExpanseRight', expanseRight),
81 | };
82 |
83 | const fadeObj = {
84 | FadeIn: hoc('FadeIn', fadeIn),
85 | FadeInDown: hoc('FadeInDown', down),
86 | FadeInDownBig: hoc('FadeInDownBig', downBig),
87 | FadeInUp: hoc('FadeInUp', up),
88 | FadeInUpBig: hoc('FadeInUpBig', upBig),
89 | FadeInLeft: hoc('FadeInLeft', left),
90 | FadeInLeftBig: hoc('FadeInLeftBig', leftBig),
91 | FadeInRight: hoc('FadeInRight', right),
92 | FadeInRightBig: hoc('FadeInRightBig', rightBig),
93 | };
94 |
95 | const lightObj = {
96 | LightIn: hoc('LightIn', lightIn),
97 | LightOut: hoc('LightOut', lightOut),
98 | };
99 |
100 | const PObj = {
101 | PDown: hoc('PDown', perspectiveDown),
102 | PUp: hoc('PUp', perspectiveUp),
103 | PRight: hoc('PRight', perspectiveRight),
104 | PLeft: hoc('PLeft', perspectiveLeft),
105 | };
106 |
107 | const rotateObj = {
108 | RotateIn: hoc('RotateIn', rotateIn),
109 | RotateLeft: hoc('RotateLeft', rotateLeft),
110 | RotateRight: hoc('RotateRight', rotateRight),
111 | RotateUpLeft: hoc('RotateUpLeft', rotateUpLeft),
112 | RotateUpRight: hoc('RotateUpRight', rotateUpRight),
113 | };
114 |
115 | const slideObj = {
116 | SlideUp: hoc('SlideUp', slideUp),
117 | SlideDown: hoc('SlideDown', slideDown),
118 | SlideRight: hoc('SlideRight', slideRight),
119 | SlideLeft: hoc('SlideLeft', slideLeft),
120 | };
121 |
122 | const specialObj = {
123 | Flash: hoc('Flash', flash),
124 | RollOut: hoc('RollOut', rollOut),
125 | RollIn: hoc('RollIn', rollIn),
126 | Rubber: hoc('Rubber', rubber),
127 | Swing: hoc('Swing', swing),
128 | Zoom: hoc('Zoom', zoom),
129 | Hinge: hoc('Hinge', hinge),
130 | HingeDrop: hoc('HingeDrop', hingeDrop),
131 | Pulse: hoc('Pulse', pulse),
132 | ExpandUp: hoc('ExpandUp', expandUp),
133 | Entrance: hoc('Entrance', entrance),
134 | Hatch: hoc('Hatch', hatch),
135 | StarWars: hoc('StarWars', starWars),
136 | };
137 |
138 | const flipObj = {
139 | Flip: hoc('Flip', flip),
140 | FlipX: hoc('FlipX', flipX),
141 | FlipY: hoc('FlipY', flipY),
142 | };
143 |
144 | export {
145 | flipObj,
146 | specialObj,
147 | slideObj,
148 | rotateObj,
149 | PObj,
150 | lightObj,
151 | fadeObj,
152 | expanseObj,
153 | bounceObj,
154 | bingoObj,
155 | };
156 |
--------------------------------------------------------------------------------
/packages/ac-inferno/containers/Delay.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import Inferno from 'inferno';
4 | import Component from 'inferno-component';
5 |
6 | type DefaultProps = {
7 | timeout: number,
8 | children?: Element // Workaround 😕
9 | }
10 |
11 | type Props = {
12 | timeout: number,
13 | children?: Element
14 | }
15 |
16 | type State = {
17 | show: boolean
18 | }
19 |
20 | export default class Delay extends Component {
21 | timer = null;
22 |
23 | static displayName = 'Delay';
24 |
25 | static defaultProps = {
26 | timeout: 4, // Minimum timeout is 4ms so no difference when compared with timeout zero
27 | };
28 |
29 | state = {
30 | show: false,
31 | };
32 |
33 | componentWillMount = () => {
34 | this.timer = null;
35 | };
36 |
37 | componentDidMount = () => {
38 | const { timeout } = this.props;
39 | this.timer = setTimeout(this.setShowValue, timeout);
40 | };
41 |
42 | componentWillUnmount = () => {
43 | clearTimeout(this.timer);
44 | };
45 |
46 | setShowValue = () => {
47 | this.setState({
48 | show: true,
49 | });
50 | };
51 |
52 | render() {
53 | const { children } = this.props;
54 | const { show } = this.state;
55 | const performAnimation = show ? children :
;
56 |
57 | return performAnimation;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/packages/ac-inferno/containers/Disappear.js:
--------------------------------------------------------------------------------
1 | import Inferno from 'inferno';
2 | import Component from 'inferno-component';
3 | import createElement from 'inferno-create-element';
4 | import { fadeIn } from 'animate-keyframes';
5 | import { getElementType, avoidNest } from '../utils/index';
6 |
7 | export default class Disappear extends Component {
8 | static defaultProps = {
9 | name: fadeIn,
10 | duration: '2s',
11 | as: 'div',
12 | timingFunction: 'ease'
13 | };
14 |
15 | componentWillMount = () => {
16 | this.timeouts = null;
17 | };
18 |
19 | componentDidMount = () => {
20 | this.performAndDisapper(this.props);
21 | };
22 |
23 | componentWillUnmount = () => {
24 | clearTimeout(this.timeouts)
25 | };
26 |
27 | performAndDisapper = (props) => {
28 | const element = document.getElementById('animation-root');
29 | element.style = `animation: ${props.name} ${props.duration} ${props.timingFunction}`; // start on initial render
30 | element.addEventListener('animationend', () => {
31 | element.style =
32 | 'visibility: \'hidden\'; opacity: 0; transition: visibility 0s 2s, opacity 2s linear;';
33 | this.timeouts = setTimeout(() => {
34 | element.remove(); // Gives a warning for InfernoJS (works well for ReactJS)
35 | }, 2000); // Sync with fadeOut
36 | });
37 | };
38 |
39 | render() {
40 | const { name, duration, children, as, timingFunction, component, ...rest } = this.props;
41 | const ElementType = getElementType(Disappear, this.props);
42 | const NormalizedComponent = avoidNest(ElementType, this.props, 'Disappear');
43 | const Wrapper = this.props.component;
44 |
45 | return (
46 |
47 | { Wrapper ? createElement(Wrapper, children) : children }
48 |
49 | );
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/ac-inferno/containers/HOC.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import Inferno from 'inferno';
4 | import Component from 'inferno-component';
5 | import { Render, derive } from '../utils/index';
6 |
7 | type DefaultProps = {
8 | duration: string,
9 | timingFunction: string,
10 | delay: string,
11 | direction: string,
12 | iterations: string,
13 | backfaceVisible: string,
14 | fillMode: string,
15 | playState: string,
16 | as: string,
17 | component?: Function,
18 | children?: Element,
19 | forceInterpolate?: Object,
20 | style?: Object
21 | }
22 |
23 | type Props = {
24 | duration: string,
25 | timingFunction: string,
26 | delay: string,
27 | direction: string,
28 | iterations: string,
29 | backfaceVisible: string,
30 | fillMode: string,
31 | playState: string,
32 | as: string,
33 | component?: Function,
34 | children?: Element,
35 | forceInterpolate?: Object,
36 | style?: Object
37 | }
38 |
39 | type State = {
40 | styles: Object
41 | }
42 |
43 | function hoc(ComposedComponent: string, AnimationName: string): Function {
44 | class _Animation extends Component {
45 | static displayName = `${ComposedComponent}`;
46 |
47 | static defaultProps = {
48 | duration: '1s',
49 | timingFunction: 'ease',
50 | delay: '0s',
51 | direction: 'normal',
52 | iterations: '1',
53 | backfaceVisible: 'visible',
54 | fillMode: 'none',
55 | playState: 'running',
56 | as: 'div'
57 | };
58 |
59 | state = {
60 | styles: {}
61 | };
62 |
63 | componentDidMount = () => {
64 | this.setAnimation(this.props);
65 | };
66 |
67 | componentWillReceiveProps = (nextProps: Props) => {
68 | // Interpolation of new animation properties
69 | const deriveInterpolationFromNextProps = derive(nextProps, AnimationName);
70 |
71 | // Old interpolation string
72 | const deriveInterpolationFromPrevProps = derive(
73 | this.props,
74 | AnimationName
75 | );
76 |
77 | if (
78 | deriveInterpolationFromNextProps !== deriveInterpolationFromPrevProps
79 | ) {
80 | this.setState({
81 | styles: Object.assign(
82 | {
83 | animation: `${deriveInterpolationFromNextProps}`,
84 | backfaceVisibility: `${nextProps.backfaceVisible}`
85 | },
86 | this.props.style || {}
87 | )
88 | });
89 | }
90 | };
91 |
92 | setAnimation = (props: Props) => {
93 | // Keyframes Interpolation and Force Interpolation
94 | const deriveInterpolation = derive(props, AnimationName);
95 |
96 | this.setState({
97 | styles: Object.assign(
98 | {
99 | animation: `${deriveInterpolation}`,
100 | backfaceVisibility: `${props.backfaceVisible}`
101 | },
102 | this.props.style || {}
103 | )
104 | });
105 | };
106 |
107 | render (): ?React$Element {
108 | const {
109 | children,
110 | duration,
111 | timingFunction,
112 | delay,
113 | direction,
114 | iterations,
115 | backfaceVisible,
116 | fillMode,
117 | playState,
118 | forceInterpolate,
119 | as,
120 | style,
121 | component,
122 | ...rest
123 | } = this.props;
124 |
125 | return Render(ComposedComponent, this.props, this.state, rest, ComposedComponent);
126 | }
127 | }
128 |
129 | return _Animation;
130 | }
131 |
132 | export default hoc;
133 |
--------------------------------------------------------------------------------
/packages/ac-inferno/containers/merge.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import Inferno from 'inferno';
4 | import Component from 'inferno-component';
5 | import { Render } from '../utils/index';
6 |
7 | type DefaultProps = {
8 | one: Object,
9 | two: Object,
10 | as: string,
11 | style?: Object,
12 | component?: Function,
13 | children?: Element
14 | }
15 |
16 | type Props = {
17 | one: Object,
18 | two: Object,
19 | as: string,
20 | style?: Object,
21 | component?: Function,
22 | children?: Element
23 | }
24 |
25 | type State = {
26 | styles: Object
27 | }
28 |
29 | // Single prop update
30 | function setAttr(prop: Object): string {
31 | return `${prop.name || ''} ${prop.duration || '1s'} ${prop.timingFunction || 'ease'}`;
32 | }
33 |
34 | // As a callback for state update
35 | function update(state: State, props: Props): Object {
36 | const { one, two } = props;
37 | const properties = `${setAttr(one)}, ${setAttr(two)}`;
38 |
39 | return {
40 | styles: Object.assign(
41 | {
42 | animation: `${properties}`,
43 | backfaceVisibility: 'visible'
44 | },
45 | props.style || {}
46 | )
47 | };
48 | }
49 |
50 | export default class Merge extends Component {
51 | static displayName = 'Merge';
52 |
53 | static defaultProps = {
54 | one: {},
55 | two: {},
56 | as: 'div'
57 | };
58 |
59 | state = {
60 | styles: {}
61 | };
62 |
63 | componentDidMount = () => {
64 | this.setState(update);
65 | };
66 |
67 | componentWillReceiveProps = (nextProps: Props) => {
68 | const newUpdate = update(this.state, nextProps);
69 | const prevUpdate = update(this.state, this.props);
70 |
71 | // Update with setState callback
72 | if (newUpdate !== prevUpdate) {
73 | this.setState(newUpdate);
74 | }
75 | };
76 |
77 | render() {
78 | const { children, one, two, as, style, component, ...rest } = this.props;
79 | return Render(Merge, this.props, this.state, rest, 'Merge');
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/packages/ac-inferno/flow-typed/npm/inferno-component_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 8871b2ac916d23f447463080f9c23ec8
2 | // flow-typed version: <>/inferno-component_v3.6.1/flow_v0.48.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'inferno-component'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'inferno-component' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'inferno-component/dist/index.es' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'inferno-component/dist/index' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'inferno-component/dist/inferno-component' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'inferno-component/dist/inferno-component.min' {
38 | declare module.exports: any;
39 | }
40 |
41 | // Filename aliases
42 | declare module 'inferno-component/dist/index.es.js' {
43 | declare module.exports: $Exports<'inferno-component/dist/index.es'>;
44 | }
45 | declare module 'inferno-component/dist/index.js' {
46 | declare module.exports: $Exports<'inferno-component/dist/index'>;
47 | }
48 | declare module 'inferno-component/dist/inferno-component.js' {
49 | declare module.exports: $Exports<'inferno-component/dist/inferno-component'>;
50 | }
51 | declare module 'inferno-component/dist/inferno-component.min.js' {
52 | declare module.exports: $Exports<'inferno-component/dist/inferno-component.min'>;
53 | }
54 | declare module 'inferno-component/index' {
55 | declare module.exports: $Exports<'inferno-component'>;
56 | }
57 | declare module 'inferno-component/index.js' {
58 | declare module.exports: $Exports<'inferno-component'>;
59 | }
60 |
--------------------------------------------------------------------------------
/packages/ac-inferno/flow-typed/npm/inferno-create-element_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: b5de221ce060f4a67100a3b0b0038461
2 | // flow-typed version: <>/inferno-create-element_v3.6.1/flow_v0.48.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'inferno-create-element'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'inferno-create-element' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'inferno-create-element/dist/index.es' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'inferno-create-element/dist/index' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'inferno-create-element/dist/inferno-create-element' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'inferno-create-element/dist/inferno-create-element.min' {
38 | declare module.exports: any;
39 | }
40 |
41 | // Filename aliases
42 | declare module 'inferno-create-element/dist/index.es.js' {
43 | declare module.exports: $Exports<'inferno-create-element/dist/index.es'>;
44 | }
45 | declare module 'inferno-create-element/dist/index.js' {
46 | declare module.exports: $Exports<'inferno-create-element/dist/index'>;
47 | }
48 | declare module 'inferno-create-element/dist/inferno-create-element.js' {
49 | declare module.exports: $Exports<'inferno-create-element/dist/inferno-create-element'>;
50 | }
51 | declare module 'inferno-create-element/dist/inferno-create-element.min.js' {
52 | declare module.exports: $Exports<'inferno-create-element/dist/inferno-create-element.min'>;
53 | }
54 | declare module 'inferno-create-element/index' {
55 | declare module.exports: $Exports<'inferno-create-element'>;
56 | }
57 | declare module 'inferno-create-element/index.js' {
58 | declare module.exports: $Exports<'inferno-create-element'>;
59 | }
60 |
--------------------------------------------------------------------------------
/packages/ac-inferno/flow-typed/npm/inferno_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: d9bf1b48ae55ebff489f0023cb5f10c6
2 | // flow-typed version: <>/inferno_v3.6.1/flow_v0.48.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'inferno'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'inferno' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'inferno/dist/index.es' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'inferno/dist/index' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'inferno/dist/inferno' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'inferno/dist/inferno.min' {
38 | declare module.exports: any;
39 | }
40 |
41 | // Filename aliases
42 | declare module 'inferno/dist/index.es.js' {
43 | declare module.exports: $Exports<'inferno/dist/index.es'>;
44 | }
45 | declare module 'inferno/dist/index.js' {
46 | declare module.exports: $Exports<'inferno/dist/index'>;
47 | }
48 | declare module 'inferno/dist/inferno.js' {
49 | declare module.exports: $Exports<'inferno/dist/inferno'>;
50 | }
51 | declare module 'inferno/dist/inferno.min.js' {
52 | declare module.exports: $Exports<'inferno/dist/inferno.min'>;
53 | }
54 | declare module 'inferno/index' {
55 | declare module.exports: $Exports<'inferno'>;
56 | }
57 | declare module 'inferno/index.js' {
58 | declare module.exports: $Exports<'inferno'>;
59 | }
60 |
--------------------------------------------------------------------------------
/packages/ac-inferno/flow-typed/npm/styled-components_v2.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 3a2f61dde69e3311cdc6d0f14863a9ef
2 | // flow-typed version: b2ad6292df/styled-components_v2.x.x/flow_>=v0.25.x
3 |
4 | // @flow
5 |
6 | type $npm$styledComponents$Interpolation = ((executionContext: Object) => string) | string | number;
7 | type $npm$styledComponents$NameGenerator = (hash: number) => string
8 |
9 | type $npm$styledComponents$StyledComponent = (
10 | strings: Array,
11 | ...interpolations: Array<$npm$styledComponents$Interpolation>
12 | ) => ReactClass<*>;
13 |
14 |
15 | type $npm$styledComponents$Theme = {[key: string]: mixed};
16 | type $npm$styledComponents$ThemeProviderProps = {
17 | theme: $npm$styledComponents$Theme | ((outerTheme: $npm$styledComponents$Theme) => void)
18 | };
19 | type $npm$styledComponents$Component =
20 | | ReactClass<*>
21 | | (props: *) => React$Element<*>;
22 |
23 | class Npm$StyledComponents$ThemeProvider extends React$Component {
24 | props: $npm$styledComponents$ThemeProviderProps;
25 | }
26 |
27 | type $npm$styledComponents$StyleSheetManagerProps = {
28 | sheet: mixed
29 | }
30 |
31 | class Npm$StyledComponents$StyleSheetManager extends React$Component {
32 | props: $npm$styledComponents$StyleSheetManagerProps;
33 | }
34 |
35 | class Npm$StyledComponents$ServerStyleSheet {
36 | instance: StyleSheet
37 | collectStyles: (children: any) => React$Element<*>
38 | getStyleTags: () => string
39 | getStyleElement: () => React$Element<*>
40 | }
41 |
42 | declare module 'styled-components' {
43 | declare type Interpolation = $npm$styledComponents$Interpolation;
44 | declare type NameGenerator = $npm$styledComponents$NameGenerator;
45 |
46 | declare type StyledComponent = $npm$styledComponents$StyledComponent;
47 |
48 | declare type Theme = $npm$styledComponents$Theme;
49 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps;
50 | declare type Component = $npm$styledComponents$Component;
51 |
52 | declare module.exports: {
53 | injectGlobal: (strings: Array, ...interpolations: Array) => void,
54 | css: (strings: Array, ...interpolations: Array) => Array,
55 | keyframes: (strings: Array, ...interpolations: Array) => string,
56 | withTheme: (component: Component) => React$Component<*, ThemeProviderProps, *>,
57 | ServerStyleSheet: typeof Npm$StyledComponents$ServerStyleSheet,
58 | StyleSheetManager: typeof Npm$StyledComponents$StyleSheetManager,
59 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider,
60 | (baseComponent: Component): StyledComponent,
61 | a: StyledComponent,
62 | abbr: StyledComponent,
63 | address: StyledComponent,
64 | area: StyledComponent,
65 | article: StyledComponent,
66 | aside: StyledComponent,
67 | audio: StyledComponent,
68 | b: StyledComponent,
69 | base: StyledComponent,
70 | bdi: StyledComponent,
71 | bdo: StyledComponent,
72 | big: StyledComponent,
73 | blockquote: StyledComponent,
74 | body: StyledComponent,
75 | br: StyledComponent,
76 | button: StyledComponent,
77 | canvas: StyledComponent,
78 | caption: StyledComponent,
79 | cite: StyledComponent,
80 | code: StyledComponent,
81 | col: StyledComponent,
82 | colgroup: StyledComponent,
83 | data: StyledComponent,
84 | datalist: StyledComponent,
85 | dd: StyledComponent,
86 | del: StyledComponent,
87 | details: StyledComponent,
88 | dfn: StyledComponent,
89 | dialog: StyledComponent,
90 | div: StyledComponent,
91 | dl: StyledComponent,
92 | dt: StyledComponent,
93 | em: StyledComponent,
94 | embed: StyledComponent,
95 | fieldset: StyledComponent,
96 | figcaption: StyledComponent,
97 | figure: StyledComponent,
98 | footer: StyledComponent,
99 | form: StyledComponent,
100 | h1: StyledComponent,
101 | h2: StyledComponent,
102 | h3: StyledComponent,
103 | h4: StyledComponent,
104 | h5: StyledComponent,
105 | h6: StyledComponent,
106 | head: StyledComponent,
107 | header: StyledComponent,
108 | hgroup: StyledComponent,
109 | hr: StyledComponent,
110 | html: StyledComponent,
111 | i: StyledComponent,
112 | iframe: StyledComponent,
113 | img: StyledComponent,
114 | input: StyledComponent,
115 | ins: StyledComponent,
116 | kbd: StyledComponent,
117 | keygen: StyledComponent,
118 | label: StyledComponent,
119 | legend: StyledComponent,
120 | li: StyledComponent,
121 | link: StyledComponent,
122 | main: StyledComponent,
123 | map: StyledComponent,
124 | mark: StyledComponent,
125 | menu: StyledComponent,
126 | menuitem: StyledComponent,
127 | meta: StyledComponent,
128 | meter: StyledComponent,
129 | nav: StyledComponent,
130 | noscript: StyledComponent,
131 | object: StyledComponent,
132 | ol: StyledComponent,
133 | optgroup: StyledComponent,
134 | option: StyledComponent,
135 | output: StyledComponent,
136 | p: StyledComponent,
137 | param: StyledComponent,
138 | picture: StyledComponent,
139 | pre: StyledComponent,
140 | progress: StyledComponent,
141 | q: StyledComponent,
142 | rp: StyledComponent,
143 | rt: StyledComponent,
144 | ruby: StyledComponent,
145 | s: StyledComponent,
146 | samp: StyledComponent,
147 | script: StyledComponent,
148 | section: StyledComponent,
149 | select: StyledComponent,
150 | small: StyledComponent,
151 | source: StyledComponent,
152 | span: StyledComponent,
153 | strong: StyledComponent,
154 | style: StyledComponent,
155 | sub: StyledComponent,
156 | summary: StyledComponent,
157 | sup: StyledComponent,
158 | table: StyledComponent,
159 | tbody: StyledComponent,
160 | td: StyledComponent,
161 | textarea: StyledComponent,
162 | tfoot: StyledComponent,
163 | th: StyledComponent,
164 | thead: StyledComponent,
165 | time: StyledComponent,
166 | title: StyledComponent,
167 | tr: StyledComponent,
168 | track: StyledComponent,
169 | u: StyledComponent,
170 | ul: StyledComponent,
171 | var: StyledComponent,
172 | video: StyledComponent,
173 | wbr: StyledComponent,
174 |
175 | // SVG
176 | circle: StyledComponent,
177 | clipPath: StyledComponent,
178 | defs: StyledComponent,
179 | ellipse: StyledComponent,
180 | g: StyledComponent,
181 | image: StyledComponent,
182 | line: StyledComponent,
183 | linearGradient: StyledComponent,
184 | mask: StyledComponent,
185 | path: StyledComponent,
186 | pattern: StyledComponent,
187 | polygon: StyledComponent,
188 | polyline: StyledComponent,
189 | radialGradient: StyledComponent,
190 | rect: StyledComponent,
191 | stop: StyledComponent,
192 | svg: StyledComponent,
193 | text: StyledComponent,
194 | tspan: StyledComponent,
195 | };
196 | }
197 |
198 | declare module 'styled-components/native' {
199 | declare type Interpolation = $npm$styledComponents$Interpolation;
200 | declare type NameGenerator = $npm$styledComponents$NameGenerator;
201 |
202 | declare type StyledComponent = $npm$styledComponents$StyledComponent;
203 |
204 | declare type Theme = $npm$styledComponents$Theme;
205 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps;
206 | declare type Component = $npm$styledComponents$Component;
207 |
208 | declare module.exports: {
209 | css: (strings: Array, ...interpolations: Array) => Array,
210 | withTheme: (component: Component) => React$Component<*, ThemeProviderProps, *>,
211 | keyframes: (strings: Array, ...interpolations: Array) => string,
212 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider,
213 |
214 | (baseComponent: Component): StyledComponent,
215 |
216 | ActivityIndicator: StyledComponent,
217 | ActivityIndicatorIOS: StyledComponent,
218 | ART: StyledComponent,
219 | Button: StyledComponent,
220 | DatePickerIOS: StyledComponent,
221 | DrawerLayoutAndroid: StyledComponent,
222 | FlatList: StyledComponent,
223 | Image: StyledComponent,
224 | ImageEditor: StyledComponent,
225 | ImageStore: StyledComponent,
226 | KeyboardAvoidingView: StyledComponent,
227 | ListView: StyledComponent,
228 | MapView: StyledComponent,
229 | Modal: StyledComponent,
230 | Navigator: StyledComponent,
231 | NavigatorIOS: StyledComponent,
232 | Picker: StyledComponent,
233 | PickerIOS: StyledComponent,
234 | ProgressBarAndroid: StyledComponent,
235 | ProgressViewIOS: StyledComponent,
236 | RecyclerViewBackedScrollView: StyledComponent,
237 | RefreshControl: StyledComponent,
238 | ScrollView: StyledComponent,
239 | SectionList: StyledComponent,
240 | SegmentedControlIOS: StyledComponent,
241 | Slider: StyledComponent,
242 | SliderIOS: StyledComponent,
243 | SnapshotViewIOS: StyledComponent,
244 | StatusBar: StyledComponent,
245 | SwipeableListView: StyledComponent,
246 | Switch: StyledComponent,
247 | SwitchAndroid: StyledComponent,
248 | SwitchIOS: StyledComponent,
249 | TabBarIOS: StyledComponent,
250 | Text: StyledComponent,
251 | TextInput: StyledComponent,
252 | ToastAndroid: StyledComponent,
253 | ToolbarAndroid: StyledComponent,
254 | Touchable: StyledComponent,
255 | TouchableHighlight: StyledComponent,
256 | TouchableNativeFeedback: StyledComponent,
257 | TouchableOpacity: StyledComponent,
258 | TouchableWithoutFeedback: StyledComponent,
259 | View: StyledComponent,
260 | ViewPagerAndroid: StyledComponent,
261 | VirtualizedList: StyledComponent,
262 | WebView: StyledComponent,
263 | };
264 | }
265 |
--------------------------------------------------------------------------------
/packages/ac-inferno/index.js:
--------------------------------------------------------------------------------
1 | import {
2 | flipObj,
3 | specialObj,
4 | slideObj,
5 | rotateObj,
6 | PObj,
7 | lightObj,
8 | fadeObj,
9 | expanseObj,
10 | bounceObj,
11 | bingoObj,
12 | } from './animations/index';
13 | import Merge from './containers/merge';
14 | import Delay from './containers/Delay';
15 | import Disappear from './containers/Disappear';
16 |
17 | const { Bounce, BounceUp, BounceRight, BounceLeft, BounceDown } = bounceObj;
18 | const {
19 | FadeIn,
20 | FadeInUp,
21 | FadeInRight,
22 | FadeInLeft,
23 | FadeInDown,
24 | FadeInUpBig,
25 | FadeInRightBig,
26 | FadeInLeftBig,
27 | } = fadeObj;
28 | const { Flip, FlipX, FlipY } = flipObj;
29 | const { LightOut, LightIn } = lightObj;
30 | const {
31 | RotateIn,
32 | RotateRight,
33 | RotateLeft,
34 | RotateUpRight,
35 | RotateUpLeft,
36 | } = rotateObj;
37 | const {
38 | Flash,
39 | RollOut,
40 | RollIn,
41 | Rubber,
42 | Swing,
43 | Zoom,
44 | Hinge,
45 | Pulse,
46 | ExpandUp,
47 | Entrance,
48 | Hatch,
49 | StarWars,
50 | } = specialObj;
51 | const { SlideUp, SlideRight, SlideLeft, SlideDown } = slideObj;
52 | const { PDown, PUp, PRight, PLeft } = PObj;
53 | const { PuffOut, PuffIn, VanishOut, VanishIn } = bingoObj;
54 | const { ExpanseUp, ExpanseRight, ExpanseDown, ExpanseLeft } = expanseObj;
55 |
56 | /** Animation components */
57 | export {
58 | Bounce,
59 | BounceUp,
60 | BounceRight,
61 | BounceLeft,
62 | BounceDown,
63 | FadeIn,
64 | FadeInUp,
65 | FadeInRight,
66 | FadeInLeft,
67 | FadeInDown,
68 | FadeInUpBig,
69 | FadeInLeftBig,
70 | FadeInRightBig,
71 | Flip,
72 | FlipX,
73 | FlipY,
74 | LightOut,
75 | LightIn,
76 | RotateIn,
77 | RotateRight,
78 | RotateLeft,
79 | RotateUpRight,
80 | RotateUpLeft,
81 | Flash,
82 | RollOut,
83 | RollIn,
84 | Rubber,
85 | Swing,
86 | Zoom,
87 | Hinge,
88 | Pulse,
89 | SlideUp,
90 | SlideDown,
91 | SlideLeft,
92 | SlideRight,
93 | StarWars,
94 | ExpandUp,
95 | Entrance,
96 | Hatch,
97 | PDown,
98 | PUp,
99 | PRight,
100 | PLeft,
101 | PuffIn,
102 | PuffOut,
103 | VanishIn,
104 | VanishOut,
105 | ExpanseLeft,
106 | ExpanseRight,
107 | ExpanseDown,
108 | ExpanseUp,
109 | Merge,
110 | Delay,
111 | Disappear,
112 | };
113 |
--------------------------------------------------------------------------------
/packages/ac-inferno/main.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./dist/ac-inferno.min.js');
2 |
--------------------------------------------------------------------------------
/packages/ac-inferno/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ac-inferno",
3 | "version": "1.0.6",
4 | "description": "Elemental components for doing animation",
5 | "keywords": [
6 | "react",
7 | "keyframes",
8 | "animate",
9 | "high order component",
10 | "composed components",
11 | "animations",
12 | "styled",
13 | "merge",
14 | "delay",
15 | "element type"
16 | ],
17 | "main": "main.js",
18 | "author": "Nitin Tulswani",
19 | "license": "MIT",
20 | "files": [
21 | "dist",
22 | "main.js"
23 | ],
24 | "homepage": "https://github.com/nitin42/animate-components",
25 | "scripts": {
26 | "prepublishOnly": "yarn flow && yarn webpack",
27 | "start": "./node_modules/.bin/webpack-dev-server --watch --config ./webpack.config.js",
28 | "flow": "./node_modules/.bin/flow",
29 | "webpack": "NODE_ENV=production ./node_modules/.bin/webpack --config ./webpack/webpack.config.js --display-max-modules 0 --display-optimization-bailout"
30 | },
31 | "dependencies": {
32 | "animate-keyframes": "^0.1.5"
33 | },
34 | "peerDependencies": {
35 | "inferno": "^3.6.1",
36 | "inferno-compat": "^3.6.1",
37 | "inferno-component": "^3.6.1",
38 | "inferno-create-element": "^3.6.1"
39 | },
40 | "devDependencies": {
41 | "babel-loader": "^7.1.0",
42 | "babel-plugin-inferno": "^3.2.0",
43 | "babel-plugin-transform-class-properties": "^6.24.1",
44 | "babel-plugin-transform-flow-strip-types": "^6.22.0",
45 | "babel-plugin-transform-object-rest-spread": "^6.23.0",
46 | "babel-preset-es2015": "^6.24.1",
47 | "babel-preset-flow": "^6.23.0",
48 | "babili-webpack-plugin": "^0.1.1",
49 | "clean-webpack-plugin": "^0.1.16",
50 | "compression-webpack-plugin": "^0.4.0",
51 | "flow-bin": "^0.48.0",
52 | "flow-typed": "^2.1.2",
53 | "remove-flow-types-loader": "^1.0.0",
54 | "webpack": "^3.0.0",
55 | "webpack-dev-server": "^2.5.0"
56 | },
57 | "repository": {
58 | "type": "git",
59 | "url": "https://github.com/nitin42/animate-components",
60 | "bugs": {
61 | "url": "https://github.com/nitin42/animate-components/issues"
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/packages/ac-inferno/utils/Render.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import Inferno from 'inferno';
4 | import createElement from 'inferno-create-element';
5 | import { avoidNest, getElementType } from './getElement';
6 |
7 | const Render = (
8 | ComposedComponent: any,
9 | props: Object,
10 | state: Object,
11 | rest: any,
12 | DisplayName: any
13 | ): ?React$Element => {
14 | const ElementType = getElementType(ComposedComponent, props);
15 | const { styles } = state;
16 | const Wrapper = props.component;
17 | const NormalizedComponent =
18 | avoidNest(ElementType, props, DisplayName) || "div";
19 |
20 | return (
21 |
22 | {Wrapper ? createElement(Wrapper, props.children) : props.children}
23 |
24 | );
25 | };
26 |
27 | export default Render;
28 |
--------------------------------------------------------------------------------
/packages/ac-inferno/utils/getElement.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | // Component name passed as string in HOC and React class in merge
4 | const avoidNest = (
5 | elementAs: string,
6 | props: Object,
7 | DisplayName: any
8 | ): string => {
9 | let elementType = elementAs;
10 | if (!props.children) return elementType;
11 |
12 | if (elementType === "div") return elementType; // Wrap with div (default)
13 |
14 | const { type } = props.children;
15 | if (type === elementType) {
16 | elementType = "div"; // Wrap with div and don't mutate the children element type.
17 | console.warn(
18 | `'${DisplayName}' component rendered with an element type 'div' (DOM nesting validated). You provided an element type '${props.as}' to the prop 'as' which was similar to the children type '${type}'. More info - https://goo.gl/wsXFiF`
19 | );
20 | return elementType;
21 | }
22 |
23 | return elementType;
24 | };
25 |
26 | const getElementType = (Component: any, props: Object): string => {
27 | const { defaultProps = {} } = Component;
28 | if (props.as && props.as !== defaultProps.as) return props.as;
29 |
30 | return defaultProps.as || "div";
31 | };
32 |
33 | export { avoidNest, getElementType };
34 |
--------------------------------------------------------------------------------
/packages/ac-inferno/utils/index.js:
--------------------------------------------------------------------------------
1 | import { avoidNest, getElementType } from './getElement';
2 | import Render from './Render';
3 | import derive from './state';
4 |
5 | export {
6 | avoidNest,
7 | getElementType,
8 | Render,
9 | derive
10 | }
11 |
--------------------------------------------------------------------------------
/packages/ac-inferno/utils/state.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | // Utilities for changing the component state based on a particular prop.
4 | const derive = (props: Object, AnimationName: string): string => {
5 | const {
6 | duration,
7 | timingFunction,
8 | delay,
9 | direction,
10 | iterations,
11 | fillMode,
12 | playState,
13 | forceInterpolate,
14 | } = props;
15 |
16 | if (forceInterpolate) {
17 | return `${AnimationName} ${duration} steps(${forceInterpolate.steps}, ${forceInterpolate.direction}) ${delay} ${iterations} ${fillMode} ${playState}`;
18 | }
19 |
20 | return `${AnimationName} ${duration} ${timingFunction} ${delay} ${iterations} ${direction} ${fillMode} ${playState}`;
21 | };
22 |
23 | export default derive;
24 |
--------------------------------------------------------------------------------
/packages/ac-inferno/webpack.config.js:
--------------------------------------------------------------------------------
1 | const webpack = require('webpack');
2 | const { join, resolve } = require('path');
3 | const HtmlWebpackPlugin = require('html-webpack-plugin');
4 |
5 | const VENDOR = ['inferno', 'inferno-component', 'inferno-compat', 'inferno-create-element'];
6 |
7 | module.exports = {
8 | entry: {
9 | main: [
10 | 'webpack-dev-server/client?http://0.0.0.0:8080',
11 | 'webpack/hot/only-dev-server',
12 | join(__dirname, 'starter/start.js')
13 | ],
14 | vendor: VENDOR
15 | },
16 | output: {
17 | filename: '[name].js',
18 | path: resolve(__dirname, 'build'),
19 | publicPath: '/'
20 | },
21 | devServer: {
22 | publicPath: '/',
23 | noInfo: true,
24 | historyApiFallback: true
25 | },
26 | stats: {
27 | chunks: true,
28 | chunkModules: true,
29 | colors: true,
30 | errors: true,
31 | errorDetails: true,
32 | timings: true,
33 | version: true,
34 | warnings: true
35 | },
36 | devtool: 'eval',
37 | module: {
38 | rules: [
39 | {
40 | test: /\.js$/,
41 | exclude: [/node_modules/, /__tests__/, /docs/, /coverage/],
42 | use: ['babel-loader']
43 | }
44 | ]
45 | },
46 | plugins: [
47 | new webpack.HotModuleReplacementPlugin(),
48 | new webpack.NamedModulesPlugin(),
49 | new HtmlWebpackPlugin({
50 | template: require('html-webpack-template'),
51 | appMountId: 'app'
52 | }),
53 | new webpack.optimize.UglifyJsPlugin(),
54 | new webpack.optimize.CommonsChunkPlugin({
55 | name: 'vendor'
56 | })
57 | ]
58 | };
59 |
--------------------------------------------------------------------------------
/packages/ac-inferno/webpack/config.js:
--------------------------------------------------------------------------------
1 | const webpack = require('webpack');
2 | const { join, resolve } = require('path');
3 | const CompressionPlugin = require('compression-webpack-plugin');
4 | const BabiliPlugin = require('babili-webpack-plugin');
5 | const CleanWebpackPlugin = require('clean-webpack-plugin');
6 |
7 | const pkg = require('../package.json');
8 |
9 | const common = {
10 | exclude: [/node_modules/, /__tests__/, /coverage/, /dist/, /examples/]
11 | };
12 |
13 | const jsLoader = () => {
14 | return {
15 | test: /\.js$/,
16 | exclude: common.exclude,
17 | use: ['babel-loader']
18 | };
19 | };
20 |
21 | const flowType = () => {
22 | return {
23 | test: /\.js$/,
24 | exclude: common.exclude,
25 | enforce: 'pre',
26 | loader: 'remove-flow-types-loader'
27 | };
28 | };
29 |
30 | let output = () => {
31 | return {
32 | filename: '[name].min.js',
33 | path: resolve(__dirname, '../dist'),
34 | libraryTarget: 'umd',
35 | library: 'acInferno',
36 | publicPath: '/',
37 | pathinfo: true
38 | };
39 | };
40 |
41 | const plugins = () => {
42 | return [
43 | new webpack.LoaderOptionsPlugin({
44 | minimize: true,
45 | debug: false,
46 | options: {
47 | context: __dirname
48 | }
49 | }),
50 | new webpack.optimize.ModuleConcatenationPlugin(),
51 | // Better results
52 | new BabiliPlugin(),
53 | new webpack.DefinePlugin({
54 | 'process.env': {
55 | NODE_ENV: JSON.stringify('production')
56 | }
57 | }),
58 | // new webpack.optimize.UglifyJsPlugin(),
59 | new CompressionPlugin({
60 | asset: '[path].gz[query]',
61 | algorithm: 'gzip',
62 | test: /\.js$|\.css$|\.html$/,
63 | threshold: 10240,
64 | minRatio: 0.8
65 | }),
66 | new CleanWebpackPlugin([resolve(__dirname, 'dist')])
67 | ];
68 | };
69 |
70 | const externals = () => {
71 | return {
72 | inferno: 'inferno',
73 | 'inferno-compat': 'inferno-compat',
74 | 'inferno-component': 'inferno-component',
75 | 'inferno-create-element': 'inferno-create-element',
76 | 'animate-keyframes': 'animate-keyframes'
77 | };
78 | };
79 |
80 | const resolver = () => {
81 | return {
82 | react: 'inferno-compat',
83 | 'react-dom': 'inferno-compat',
84 | inferno: 'inferno-compat', // Usage with babel-plugin-inferno
85 | 'styled-components': 'inferno-compat'
86 | };
87 | };
88 |
89 | const entry = () => {
90 | return {
91 | [pkg.name]: join(__dirname, '../index.js')
92 | };
93 | };
94 |
95 | module.exports = {
96 | jsLoader,
97 | output,
98 | plugins,
99 | externals,
100 | entry,
101 | resolver,
102 | flowType,
103 | };
104 |
--------------------------------------------------------------------------------
/packages/ac-inferno/webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | const {
2 | jsLoader,
3 | output,
4 | plugins,
5 | externals,
6 | entry,
7 | resolver,
8 | flowType,
9 | } = require('./config');
10 |
11 | const { join, resolve } = require('path');
12 |
13 | // All configurations in ./config.js
14 | module.exports = {
15 | entry: entry(),
16 | output: output(),
17 | devtool: 'cheap-module-source-map',
18 | cache: true,
19 | module: {
20 | rules: [jsLoader(), flowType()]
21 | },
22 | target: 'web',
23 | resolve: {
24 | modules: [
25 | resolve(__dirname),
26 | join(__dirname, 'node_modules')
27 | ],
28 | alias: resolver()
29 | },
30 | externals: externals(),
31 | plugins: plugins()
32 | };
33 |
--------------------------------------------------------------------------------
/packages/animate-components/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["flow","es2015", "react", "stage-0"],
3 | "env": {
4 | "production": {
5 | "plugins": [
6 | "transform-class-properties",
7 | "transform-object-rest-spread",
8 | "transform-react-remove-prop-types",
9 | "transform-flow-strip-types"
10 | ]
11 | },
12 | "development": {
13 | "plugins": [
14 | "transform-class-properties",
15 | "transform-object-rest-spread"
16 | ]
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/packages/animate-components/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "extends": "airbnb",
3 | "plugins": [
4 | "react",
5 | "jsx-a11y",
6 | "import"
7 | ],
8 | "rules": {
9 | "import/no-named-as-default": 0,
10 | "import/no-named-as-default-member": 0,
11 | "react/jsx-filename-extension": 0,
12 | "react/prop-types": 0,
13 | "consistent-return": 0,
14 | }
15 | };
16 |
--------------------------------------------------------------------------------
/packages/animate-components/.flowconfig:
--------------------------------------------------------------------------------
1 | [include]
2 | ./containers
3 | ./utils
4 |
5 | [ignore]
6 | .*/node_modules/styled-components/.*
7 | .*/node_modules/prop-types/.*
8 | .*/node_modules/html-tags/.*
9 | .*/node_modules/
10 |
--------------------------------------------------------------------------------
/packages/animate-components/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | /node_modules
3 | build
4 | coverage
5 | dist
6 |
7 | # misc
8 | .DS_Store
9 | .env
10 | npm-debug.log*
11 | lerna-debug.log
12 | yarn.lock
13 | yarn-error.log
14 |
--------------------------------------------------------------------------------
/packages/animate-components/README.md:
--------------------------------------------------------------------------------
1 | # Animate Components
2 | 
3 | 
4 | 
5 | 
6 |
7 |
8 |
9 |
10 |
11 | > ***Elemental components for doing animations in React***
12 |
13 | ## Install
14 |
15 | **npm**
16 |
17 | ```
18 | npm install animate-components
19 | ```
20 |
21 | **yarn**
22 |
23 | ```
24 | yarn add animate-components
25 | ```
26 |
27 | The [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com):
28 |
29 | ```html
30 |
31 | ```
32 |
33 | ## Features
34 |
35 | * Component based
36 | * Supports all the animation properties
37 | * Merge two animations to create one
38 | * Isolated keyframes (use with styled-components, aphrodite and glamor) provided by [`animate-keyframes`](https://github.com/nitin42/animate-components/tree/master/packages/animate-keyframes)
39 | * Ratifies DOM nesting
40 | * Element type rendering of components using `as` prop
41 | * Add all the html attributes supported by React along with component props.
42 |
43 | ## Why ?
44 |
45 | * Ease of doing animations (purely component based).
46 | * Simplified and minimal API.
47 | * Best source for someone who is new to React.
48 | * Supports element type rendering of an animation component (interesting tweak).
49 | * Provides isolated keyframes so that you don't have to hardcode all the curves and directly use them with css-in-js solutions like [glamor](https://github.com/threepointone/glamor), [styled-components](https://github.com/styled-components/styled-components), [Aphrodite](https://github.com/Khan/aphrodite) etc.
50 |
51 | ## Tasks
52 |
53 | [Tasklist](https://github.com/nitin42/animate-components/blob/master/tasks.md)
54 |
55 | ## Docs
56 | View the complete documentation [here](./docs).
57 |
58 | ## Animations
59 |
60 | Below is a list of all available animations (Components).
61 |
62 | ### Bounce
63 |
64 | * `Bounce`
65 | * `BounceUp`
66 | * `BounceRight`
67 | * `BounceLeft`
68 | * `BounceDown`
69 |
70 | ### Fade
71 |
72 | * `FadeIn`
73 | * `FadeInRightBig`
74 | * `FadeInRight`
75 | * `FadeInLeftBig`
76 | * `FadeInLeft`
77 | * `FadeInDown`
78 | * `FadeInDownBig`
79 | * `FadeInUp`
80 | * `FadeInUpBig`
81 |
82 | ### Flip
83 |
84 | * `Flip`
85 | * `FlipInX`
86 | * `FlipInY`
87 | * `FlipOutX`
88 | * `FlipOutY`
89 |
90 | ### LightSpeed
91 |
92 | * `LightOut`
93 | * `LightIn`
94 |
95 | ### Rotate
96 |
97 | * `RotateIn`
98 | * `RotateRight`
99 | * `RotateLeft`
100 | * `RotateUpRight`
101 | * `RotateUpLeft`
102 |
103 | ### Slide
104 |
105 | * `SlideUp`
106 | * `SlideDown`
107 | * `SlideLeft`
108 | * `SlideRight`
109 |
110 | ### Special
111 |
112 | * `Flash`
113 | * `RollOut`
114 | * `RollIn`
115 | * `Rubber`
116 | * `Swing`
117 | * `Zoom`
118 | * `Hinge`
119 | * `HingeDrop`
120 | * `Pulse`
121 | * `ExpandUp`
122 | * `Entrance`
123 | * `Hatch`
124 | * `StarWars`
125 |
126 | ## 🚀 New
127 | ### Perspective
128 |
129 | * `PDown`
130 | * `PUp`
131 | * `PLeft`
132 | * `PRight`
133 |
134 | ### Bingo
135 |
136 | * `PuffOut`
137 | * `PuffIn`
138 | * `VanishOut`
139 | * `VanishIn`
140 |
141 | ### Expanse (in space)
142 |
143 | * `ExpanseUp`
144 | * `ExpanseDown`
145 | * `ExpanseLeft`
146 | * `ExpanseRight`
147 |
148 | ## Other animation libraries (css)
149 |
150 | * [Animate.css](https://daneden.github.io/animate.css/)
151 | * [CSShake](http://elrumordelaluz.github.io/csshake/#1)
152 | * [Magic](https://minimamente.com/example/magic_animations/)
153 |
--------------------------------------------------------------------------------
/packages/animate-components/__tests__/__snapshots__/delay.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Delay component sets the timeout for an animation component 1`] = `
`;
4 |
--------------------------------------------------------------------------------
/packages/animate-components/__tests__/__snapshots__/merge.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Merge Component animates the children and render the div (default) element 1`] = `[Function]`;
4 |
5 | exports[`Merge Component animates the children and render the h1 element 1`] = `[Function]`;
6 |
--------------------------------------------------------------------------------
/packages/animate-components/__tests__/delay.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import renderer from "react-test-renderer";
3 | import { keyframes } from "styled-components";
4 |
5 | import Delay from '../containers/Delay';
6 | import hoc from "../containers/HOC";
7 |
8 | const sample = keyframes`
9 | 0% {
10 | opacity: 0;
11 | }
12 |
13 | 100% {
14 | opacity: 1;
15 | }
16 | `;
17 |
18 | const Sample = hoc("Sample", sample);
19 |
20 | describe('Delay component', () => {
21 | it('should be a function', () => {
22 | expect(typeof Delay).toBe('function');
23 | });
24 |
25 | it('sets the timeout for an animation component', () => {
26 | const tree = renderer.create(
27 |
28 |
29 | Hello World!
30 |
31 |
32 | ).toJSON();
33 |
34 | expect(tree).toMatchSnapshot();
35 | });
36 | });
37 |
--------------------------------------------------------------------------------
/packages/animate-components/__tests__/derive.test.js:
--------------------------------------------------------------------------------
1 | import derive from "../utils/state";
2 |
3 | describe("Merge style updates into state", () => {
4 | it("should be a function", () => {
5 | expect(typeof derive).toBe("function");
6 | });
7 |
8 | it("should return interpolated string if forceInterpolate prop not passed", () => {
9 | const props = {
10 | duration: "2s",
11 | timingFunction: "ease",
12 | delay: "0s",
13 | direction: "normal",
14 | iterations: "3",
15 | backfaceVisible: "visible",
16 | fillMode: "none",
17 | playState: "running"
18 | };
19 |
20 | const AnimationName = "Swing";
21 |
22 | expect(derive(props, AnimationName)).toBe(
23 | "Swing 2s ease 0s 3 normal none running"
24 | );
25 | });
26 |
27 | it("should return interpolated string with forceInterpolate prop", () => {
28 | const props = {
29 | duration: "2s",
30 | timingFunction: "ease",
31 | delay: "0s",
32 | direction: "normal",
33 | iterations: "3",
34 | backfaceVisible: "visible",
35 | fillMode: "none",
36 | playState: "running",
37 | forceInterpolate: {
38 | steps: "4",
39 | direction: "start"
40 | }
41 | };
42 |
43 | const AnimationName = "Zoom";
44 |
45 | expect(derive(props, AnimationName)).toBe(
46 | "Zoom 2s steps(4, start) 0s 3 none running"
47 | );
48 | });
49 | });
50 |
--------------------------------------------------------------------------------
/packages/animate-components/__tests__/hoc.test.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import renderer from "react-test-renderer";
4 | import { keyframes } from "styled-components";
5 | import "jest-styled-components";
6 | import { shallow } from "enzyme";
7 | import * as ANIMATION_COMPONENTS from "../animations/index";
8 |
9 | import hoc from "../containers/HOC";
10 | import { FadeIn } from "../dist/animate-components.min.js";
11 |
12 | const sample = keyframes`
13 | 0% {
14 | opacity: 0;
15 | }
16 |
17 | 100% {
18 | opacity: 1;
19 | }
20 | `;
21 |
22 | const Sample = hoc("Sample", sample);
23 |
24 | const sampleComponent = (
25 |
26 | Hello World!
27 |
28 | );
29 |
30 | let App = () => {
31 | return Sign of Times
;
32 | };
33 |
34 | describe("Animation Components", () => {
35 | it("there should be 52 animation components (currently)", () => {
36 | expect(Object.keys(ANIMATION_COMPONENTS)).toHaveLength(10);
37 | });
38 |
39 | it("should export all the 10 animation objects", () => {
40 | expect(Object.keys(ANIMATION_COMPONENTS)).toEqual([
41 | "flipObj",
42 | "specialObj",
43 | "slideObj",
44 | "rotateObj",
45 | "PObj",
46 | "lightObj",
47 | "fadeObj",
48 | "expanseObj",
49 | "bounceObj",
50 | "bingoObj"
51 | ]);
52 | });
53 | });
54 |
55 | describe("High Order Component", () => {
56 | it("should be a function", () => {
57 | expect(typeof hoc).toBe("function");
58 | });
59 |
60 | it("should return a class component", () => {
61 | expect(typeof FadeIn).toBe("function");
62 | });
63 |
64 | describe("class component ", () => {
65 | it("should render the children", () => {
66 | const component = shallow(
67 |
68 | Hello
69 |
70 | );
71 | expect(component.text()).toEqual("Hello");
72 | expect(component.find("h1").parent().is("div")).toEqual(true);
73 | expect(component.find("h1").parent().length).toBe(1);
74 | });
75 |
76 | it("should render children with the supported props", () => {
77 | const component = shallow(
78 |
79 | Hello
80 |
81 | );
82 | expect(component.instance().props).toEqual({
83 | as: "h1",
84 | backfaceVisible: "visible",
85 | children: Hello ,
86 | delay: "0s",
87 | direction: "reverse",
88 | duration: "3s",
89 | fillMode: "none",
90 | iterations: "infinite",
91 | playState: "running",
92 | timingFunction: "ease"
93 | });
94 | });
95 |
96 | it("should render via component prop", () => {
97 | const component = shallow(
98 |
99 | );
100 | expect(component.type()).toEqual("div");
101 | const output = component.instance().props.component;
102 | expect(React.createElement(output)).toEqual( );
103 | });
104 | });
105 |
106 | it("calls componentDidMount lifecycle method", () => {
107 | const wrapper = shallow(sampleComponent);
108 | wrapper.instance().componentDidMount();
109 | // Also calls store() method when component mounts.
110 | });
111 |
112 | it("updates the styles when the component mounts", () => {
113 | const wrapper = shallow(sampleComponent);
114 | wrapper.instance().componentDidMount();
115 |
116 | expect(wrapper.state("styles")).toEqual({
117 | animation: "UNeSH 2s ease 0s 1 normal none running",
118 | backfaceVisibility: "visible"
119 | });
120 | });
121 | });
122 |
--------------------------------------------------------------------------------
/packages/animate-components/__tests__/merge.test.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import renderer from "react-test-renderer";
3 | import "jest-styled-components";
4 | import { shallow } from "enzyme";
5 |
6 | import Merge from "../containers/merge";
7 |
8 | let App = () => {
9 | return (
10 |
11 |
Hello Clay Jansen!
12 |
13 | );
14 | }
15 |
16 | const renderh1 = (
17 |
18 | Hello
19 |
20 | );
21 |
22 | const defaultRender = (
23 |
24 | Hello
25 |
26 | );
27 |
28 | describe('Merge Component', () => {
29 | it("animates the children and render the h1 element", () => {
30 | const tree = renderer.create(renderh1).toJSON;
31 |
32 | expect(tree).toMatchSnapshot();
33 | });
34 |
35 | it("animates the children and render the div (default) element", () => {
36 | const tree = renderer.create(defaultRender).toJSON;
37 |
38 | expect(tree).toMatchSnapshot();
39 | });
40 |
41 | // it("matches the keyframes created by styled-components and default props", () => {
42 | // const tree = renderer.create(defaultRender).toJSON();
43 | //
44 | // expect(tree).toMatchStyledComponentsSnapshot();
45 | // });
46 | //
47 | // it('renders the Component passed through the component prop', () => {
48 | // const tree = renderer.create(
49 | //
50 | // ).toJSON();
51 | //
52 | // expect(tree).toMatchSnapshot();
53 | // })
54 |
55 | it("calls componentDidMount lifecycle method", () => {
56 | const wrapper = shallow(defaultRender);
57 | wrapper.instance().componentDidMount();
58 | // Also calls store() method when component mounts.
59 | });
60 |
61 | it("updates the styles when the component mounts", () => {
62 | const wrapper = shallow(renderh1);
63 | wrapper.instance().componentDidMount();
64 |
65 | // Implicitly calls the returnAnimation()
66 | expect(wrapper.state("styles")).toEqual({
67 | animation: "fadeIn 1s ease, slideUp 1s ease",
68 | backfaceVisibility: "visible"
69 | });
70 | });
71 | })
72 |
--------------------------------------------------------------------------------
/packages/animate-components/animations/index.js:
--------------------------------------------------------------------------------
1 | import {
2 | bounce,
3 | bounceDown,
4 | bounceLeft,
5 | bounceRight,
6 | bounceUp,
7 | fadeIn,
8 | left,
9 | down,
10 | downBig,
11 | leftBig,
12 | rightBig,
13 | right,
14 | up,
15 | upBig,
16 | flip,
17 | flipInX,
18 | flipInY,
19 | flipOutX,
20 | flipOutY,
21 | lightIn,
22 | lightOut,
23 | rotateIn,
24 | rotateLeft,
25 | rotateRight,
26 | rotateUpLeft,
27 | rotateUpRight,
28 | flash,
29 | rollOut,
30 | rollIn,
31 | rubber,
32 | swing,
33 | zoom,
34 | hinge,
35 | hingeDrop,
36 | pulse,
37 | expandUp,
38 | entrance,
39 | hatch,
40 | starWars,
41 | slideDown,
42 | slideLeft,
43 | slideRight,
44 | slideUp,
45 | perspectiveDown,
46 | perspectiveUp,
47 | perspectiveLeft,
48 | perspectiveRight,
49 | puffmein,
50 | puffmeout,
51 | vanishout,
52 | vanishin,
53 | expanseDown,
54 | expanseUp,
55 | expanseLeft,
56 | expanseRight,
57 | } from 'animate-keyframes';
58 | import hoc from '../containers/HOC';
59 |
60 | // Animate Components
61 | const bingoObj = {
62 | PuffOut: hoc('PuffOut', puffmeout),
63 | PuffIn: hoc('PuffIn', puffmein),
64 | VanishOut: hoc('VanishOut', vanishout),
65 | VanishIn: hoc('VanishIn', vanishin),
66 | };
67 |
68 | const bounceObj = {
69 | Bounce: hoc('Bounce', bounce),
70 | BounceDown: hoc('BounceDown', bounceDown),
71 | BounceUp: hoc('BounceUp', bounceUp),
72 | BounceLeft: hoc('BounceLeft', bounceLeft),
73 | BounceRight: hoc('BounceRight', bounceRight),
74 | };
75 |
76 | const expanseObj = {
77 | ExpanseUp: hoc('ExpanseUp', expanseUp),
78 | ExpanseDown: hoc('ExpanseDown', expanseDown),
79 | ExpanseLeft: hoc('ExpanseLeft', expanseLeft),
80 | ExpanseRight: hoc('ExpanseRight', expanseRight),
81 | };
82 |
83 | const fadeObj = {
84 | FadeIn: hoc('FadeIn', fadeIn),
85 | FadeInDown: hoc('FadeInDown', down),
86 | FadeInDownBig: hoc('FadeInDownBig', downBig),
87 | FadeInUp: hoc('FadeInUp', up),
88 | FadeInUpBig: hoc('FadeInUpBig', upBig),
89 | FadeInLeft: hoc('FadeInLeft', left),
90 | FadeInLeftBig: hoc('FadeInLeftBig', leftBig),
91 | FadeInRight: hoc('FadeInRight', right),
92 | FadeInRightBig: hoc('FadeInRightBig', rightBig),
93 | };
94 |
95 | const lightObj = {
96 | LightIn: hoc('LightIn', lightIn),
97 | LightOut: hoc('LightOut', lightOut),
98 | };
99 |
100 | const PObj = {
101 | PDown: hoc('PDown', perspectiveDown),
102 | PUp: hoc('PUp', perspectiveUp),
103 | PRight: hoc('PRight', perspectiveRight),
104 | PLeft: hoc('PLeft', perspectiveLeft),
105 | };
106 |
107 | const rotateObj = {
108 | RotateIn: hoc('RotateIn', rotateIn),
109 | RotateLeft: hoc('RotateLeft', rotateLeft),
110 | RotateRight: hoc('RotateRight', rotateRight),
111 | RotateUpLeft: hoc('RotateUpLeft', rotateUpLeft),
112 | RotateUpRight: hoc('RotateUpRight', rotateUpRight),
113 | };
114 |
115 | const slideObj = {
116 | SlideUp: hoc('SlideUp', slideUp),
117 | SlideDown: hoc('SlideDown', slideDown),
118 | SlideRight: hoc('SlideRight', slideRight),
119 | SlideLeft: hoc('SlideLeft', slideLeft),
120 | };
121 |
122 | const specialObj = {
123 | Flash: hoc('Flash', flash),
124 | RollOut: hoc('RollOut', rollOut),
125 | RollIn: hoc('RollIn', rollIn),
126 | Rubber: hoc('Rubber', rubber),
127 | Swing: hoc('Swing', swing),
128 | Zoom: hoc('Zoom', zoom),
129 | Hinge: hoc('Hinge', hinge),
130 | HingeDrop: hoc('HingeDrop', hingeDrop),
131 | Pulse: hoc('Pulse', pulse),
132 | ExpandUp: hoc('ExpandUp', expandUp),
133 | Entrance: hoc('Entrance', entrance),
134 | Hatch: hoc('Hatch', hatch),
135 | StarWars: hoc('StarWars', starWars),
136 | };
137 |
138 | const flipObj = {
139 | Flip: hoc('Flip', flip),
140 | FlipInX: hoc('FlipInX', flipInX),
141 | FlipInY: hoc('FlipInY', flipInY),
142 | FlipOutX: hoc('FlipOutX', flipOutX),
143 | FlipOutY: hoc('FlipOutY', flipOutY),
144 | };
145 |
146 | export {
147 | flipObj,
148 | specialObj,
149 | slideObj,
150 | rotateObj,
151 | PObj,
152 | lightObj,
153 | fadeObj,
154 | expanseObj,
155 | bounceObj,
156 | bingoObj,
157 | };
158 |
--------------------------------------------------------------------------------
/packages/animate-components/containers/Delay.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import React, { PureComponent } from 'react';
4 | import type { Element } from 'react';
5 | import PropTypes from 'prop-types';
6 |
7 | type DefaultProps = {
8 | timeout: number,
9 | children?: Element // Workaround 😕
10 | }
11 |
12 | type Props = {
13 | timeout: number,
14 | children?: Element
15 | }
16 |
17 | type State = {
18 | show: boolean
19 | }
20 |
21 | export default class Delay extends PureComponent {
22 | // avoids warning for super() in some cases
23 | constructor(props: Object) {
24 | super(props);
25 | };
26 |
27 | timer = null;
28 |
29 | static displayName = 'Delay';
30 |
31 | static defaultProps = {
32 | timeout: 4, // Minimum timeout is 4ms so no difference when compared with timeout zero
33 | };
34 |
35 | static propTypes = {
36 | timeout: PropTypes.number,
37 | };
38 |
39 | state = {
40 | show: false,
41 | };
42 |
43 | componentWillMount = () => {
44 | this.timer = null;
45 | };
46 |
47 | componentDidMount = () => {
48 | const { timeout } = this.props;
49 | this.timer = setTimeout(this.setShowValue, timeout);
50 | };
51 |
52 | componentWillUnmount = () => {
53 | clearTimeout(this.timer);
54 | };
55 |
56 | setShowValue = (): void => {
57 | this.setState({
58 | show: true,
59 | });
60 | };
61 |
62 | render(): ?React$Element {
63 | const { children } = this.props;
64 | const { show } = this.state;
65 | const performAnimation = show ? children :
;
66 |
67 | return performAnimation;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/packages/animate-components/containers/Disappear.js:
--------------------------------------------------------------------------------
1 | import React, { PureComponent } from 'react';
2 | import PropTypes from 'prop-types';
3 | import { fadeIn } from 'animate-keyframes';
4 | import { getElementType, avoidNest } from 'element-utils';
5 |
6 | export default class Disappear extends PureComponent {
7 | constructor(props: Object) {
8 | super(props);
9 | };
10 |
11 | static defaultProps = {
12 | name: fadeIn,
13 | duration: '2s',
14 | as: 'div',
15 | timingFunction: 'ease'
16 | };
17 |
18 | static propTypes = {
19 | name: PropTypes.string,
20 | duration: PropTypes.string,
21 | as: PropTypes.string,
22 | timingFunction: PropTypes.string,
23 | component: PropTypes.func
24 | };
25 |
26 | componentWillMount = () => {
27 | this.timeouts = null;
28 | };
29 |
30 | componentDidMount = () => {
31 | this.performAndDisapper(this.props);
32 | };
33 |
34 | componentWillUnmount = () => {
35 | clearTimeout(this.timeouts);
36 | };
37 |
38 | performAndDisapper = (props) => {
39 | const element = document.getElementById('animation-root');
40 | element.style = `animation: ${props.name} ${props.duration} ${props.timingFunction}`; // start on initial render
41 | element.addEventListener('animationend', () => {
42 | element.style =
43 | 'visibility: \'hidden\'; opacity: 0; transition: visibility 0s 2s, opacity 2s linear;';
44 | this.timeouts = setTimeout(() => {
45 | element.remove();
46 | }, 2000); // Sync with fadeOut
47 | });
48 | };
49 |
50 | render() {
51 | const { name, duration, children, as, timingFunction, component, ...rest } = this.props;
52 | const ElementType = getElementType(Disappear, this.props);
53 | const NormalizedComponent = avoidNest(ElementType, this.props, 'Disappear');
54 | const Wrapper = this.props.component;
55 |
56 | return (
57 |
58 | { Wrapper ? React.createElement(Wrapper, children) : children }
59 |
60 | );
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/packages/animate-components/containers/HOC.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import React, { PureComponent } from 'react';
4 | import type { Element } from 'react';
5 | import PropTypes from 'prop-types';
6 | import checkTag from 'html-tags';
7 | import { Render } from 'element-utils';
8 | import derive from '../utils/state';
9 | import { direction, interpolateValidators } from '../utils/keyValidators';
10 |
11 | type DefaultProps = {
12 | duration: string,
13 | timingFunction: string,
14 | delay: string,
15 | direction: string,
16 | iterations: string,
17 | backfaceVisible: string,
18 | fillMode: string,
19 | playState: string,
20 | as: string,
21 | component?: Function,
22 | children?: Element,
23 | forceInterpolate?: Object,
24 | style?: Object
25 | }
26 |
27 | type Props = {
28 | duration: string,
29 | timingFunction: string,
30 | delay: string,
31 | direction: string,
32 | iterations: string,
33 | backfaceVisible: string,
34 | fillMode: string,
35 | playState: string,
36 | as: string,
37 | component?: Function,
38 | children?: Element,
39 | forceInterpolate?: Object,
40 | style?: Object
41 | }
42 |
43 | type State = {
44 | styles: Object
45 | }
46 |
47 | function setPropTypes(ComposedComponent: string) {
48 | return {
49 | direction: PropTypes.oneOf([
50 | 'normal',
51 | 'reverse',
52 | 'alternate',
53 | 'alternate-reverse',
54 | 'initial',
55 | 'inherit'
56 | ]),
57 | fillMode: PropTypes.oneOf(['none', 'forwards', 'backwards', 'both']),
58 | playState: PropTypes.oneOf(['paused', 'running']),
59 | timingFunction: PropTypes.oneOf([
60 | 'linear',
61 | 'ease',
62 | 'ease-in',
63 | 'ease-out',
64 | 'ease-in-out',
65 | 'step-start',
66 | 'step-end'
67 | ]),
68 | backfaceVisible: PropTypes.oneOf(['visible', 'hidden']),
69 | /* eslint-disable object-shorthand */
70 | /* eslint-disable func-names */
71 | as: function(props, propName) {
72 | const prop = props[propName];
73 | const err = `Warning: '${prop}' passed to '${ComposedComponent}' component is not a valid html tag.`;
74 | /* eslint-disable no-console */
75 | return checkTag.includes(prop) ? null : console.error(err);
76 | },
77 | forceInterpolate: PropTypes.objectOf((propValue, key) => {
78 | direction(key, propValue);
79 | interpolateValidators(key);
80 | }),
81 | component: PropTypes.func
82 | };
83 | }
84 |
85 | function hoc(ComposedComponent: string, AnimationName: string): Function {
86 | class _Animation extends PureComponent {
87 | constructor(props: Object) {
88 | super(props);
89 | };
90 |
91 | static displayName = `${ComposedComponent}`;
92 |
93 | static defaultProps = {
94 | duration: '1s',
95 | timingFunction: 'ease',
96 | delay: '0s',
97 | direction: 'normal',
98 | iterations: '1',
99 | backfaceVisible: 'visible',
100 | fillMode: 'none',
101 | playState: 'running',
102 | as: 'div'
103 | };
104 |
105 | state = {
106 | styles: {}
107 | };
108 |
109 | componentDidMount = () => {
110 | this.setAnimation(this.props);
111 | };
112 |
113 | componentWillReceiveProps = (nextProps: Props) => {
114 | // Interpolation of new animation properties
115 | const deriveInterpolationFromNextProps = derive(nextProps, AnimationName);
116 |
117 | // Old interpolation string
118 | const deriveInterpolationFromPrevProps = derive(
119 | this.props,
120 | AnimationName
121 | );
122 |
123 | if (
124 | deriveInterpolationFromNextProps !== deriveInterpolationFromPrevProps
125 | ) {
126 | this.setState({
127 | styles: Object.assign(
128 | {
129 | animation: `${deriveInterpolationFromNextProps}`,
130 | backfaceVisibility: `${nextProps.backfaceVisible}`
131 | },
132 | this.props.style || {}
133 | )
134 | });
135 | }
136 | };
137 |
138 | setAnimation = (props: Props) => {
139 | // Keyframes Interpolation and Force Interpolation
140 | const deriveInterpolation = derive(props, AnimationName);
141 |
142 | this.setState({
143 | styles: Object.assign(
144 | {
145 | animation: `${deriveInterpolation}`,
146 | backfaceVisibility: `${props.backfaceVisible}`
147 | },
148 | this.props.style || {}
149 | )
150 | });
151 | };
152 |
153 | render(): ?React$Element {
154 | const {
155 | children,
156 | duration,
157 | timingFunction,
158 | delay,
159 | direction,
160 | iterations,
161 | backfaceVisible,
162 | fillMode,
163 | playState,
164 | forceInterpolate,
165 | as,
166 | style,
167 | component,
168 | ...rest
169 | } = this.props;
170 |
171 | return Render(ComposedComponent, this.props, this.state, rest, ComposedComponent);
172 | }
173 | }
174 |
175 | _Animation.propTypes = setPropTypes(ComposedComponent);
176 |
177 | return _Animation;
178 | }
179 |
180 | export default hoc;
181 |
--------------------------------------------------------------------------------
/packages/animate-components/containers/merge.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import React, { PureComponent } from 'react';
4 | import type { Element } from 'react';
5 | import PropTypes from 'prop-types';
6 | import checkTag from 'html-tags';
7 | import { Render } from 'element-utils';
8 | import {
9 | names,
10 | duration,
11 | timingFunction,
12 | propValidators
13 | } from '../utils/keyValidators';
14 |
15 | type DefaultProps = {
16 | one: Object,
17 | two: Object,
18 | as: string,
19 | style?: Object,
20 | component?: Function,
21 | children?: Element
22 | }
23 |
24 | type Props = {
25 | one: Object,
26 | two: Object,
27 | as: string,
28 | style?: Object,
29 | component?: Function,
30 | children?: Element
31 | }
32 |
33 | type State = {
34 | styles: Object
35 | }
36 |
37 | // Single prop update
38 | function setAttr(prop: Object): string {
39 | return `${prop.name || ''} ${prop.duration || '1s'} ${prop.timingFunction || 'ease'}`;
40 | }
41 |
42 | // As a callback for state update
43 | function update(state: State, props: Props): Object {
44 | const { one, two } = props;
45 | const properties = `${setAttr(one)}, ${setAttr(two)}`;
46 |
47 | return {
48 | styles: Object.assign(
49 | {
50 | animation: `${properties}`,
51 | backfaceVisibility: 'visible'
52 | },
53 | props.style || {}
54 | )
55 | };
56 | }
57 |
58 | export default class Merge extends PureComponent {
59 | constructor(props: Object) {
60 | super(props);
61 | };
62 |
63 | static displayName = 'Merge';
64 |
65 | static defaultProps = {
66 | one: {},
67 | two: {},
68 | as: 'div'
69 | };
70 |
71 | state = {
72 | styles: {}
73 | };
74 |
75 | componentDidMount = () => {
76 | this.setState(update);
77 | };
78 |
79 | componentWillReceiveProps = (nextProps: Props) => {
80 | const newUpdate = update(this.state, nextProps);
81 | const prevUpdate = update(this.state, this.props);
82 |
83 | // Update with setState callback
84 | if (newUpdate !== prevUpdate) {
85 | this.setState(newUpdate);
86 | }
87 | };
88 |
89 | render(): ?React$Element {
90 | const { children, one, two, as, style, component, ...rest } = this.props;
91 | return Render(Merge, this.props, this.state, rest, 'Merge');
92 | }
93 | }
94 |
95 | const validators = {
96 | /* eslint-disable react/no-unused-prop-types */
97 | props: PropTypes.objectOf((propValue, key) => {
98 | names(key, propValue);
99 | duration(key, propValue);
100 | timingFunction(key, propValue);
101 | propValidators(key);
102 | })
103 | };
104 |
105 | Merge.propTypes = {
106 | one: validators.props,
107 | two: validators.props,
108 | /* eslint-disable object-shorthand */
109 | /* eslint-disable func-names */
110 | /* eslint-disable react/no-unused-prop-types */
111 | as: function(props, propName) {
112 | const prop = props[propName];
113 | const err = `Warning: '${prop}' passed to 'Merge' component is not a valid html tag.`;
114 | /* eslint-disable no-console */
115 | return checkTag.includes(prop) ? null : console.error(err);
116 | },
117 | component: PropTypes.func
118 | };
119 |
--------------------------------------------------------------------------------
/packages/animate-components/docs/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | # Documentation
9 |
10 | This is the `animate-components` documentation.
11 |
12 | ## Table of Contents
13 |
14 | * [Usage](./usage.md)
15 | * [API reference](./api.md)
16 | * [Performance](./performance.md)
17 | * [Examples](./example.md)
18 | * [Tips](./tips.md)
19 | * [Contributing](../CONTRIBUTING.md)
20 |
--------------------------------------------------------------------------------
/packages/animate-components/docs/api.md:
--------------------------------------------------------------------------------
1 | # API Reference
2 |
3 | #### Props for animation component (eg - ` `)
4 |
5 | | Props | Type | Default |
6 | | ------------- |:-------------:| -----:|
7 | | **duration** | string | 1s |
8 | | **timingFunction** | string | ease |
9 | | **delay** | string | 0s |
10 | | **direction** | string | normal |
11 | | **iterations** | string | 1 |
12 | | **backfaceVisible** | string | visible |
13 | | **fillMode** | string | none |
14 | | **playState** | string | running |
15 | | **forceInterpolate** | object | { } |
16 | | **as** | string | div |
17 | | **component** | function | - |
18 |
19 |
20 | #### Props for ` ` component
21 |
22 | | Props | Type | Default |
23 | | ------------- |:-------------:| -----:|
24 | | **one** | object | { name: " ", duration: "2s", timingFunction: "ease-in" } |
25 | | **two** | object | { name: " ", duration: "3s", timingFunction: "ease-out" } |
26 | | **as** | string | div |
27 | | **component** | function | - |
28 |
29 | #### Props for ` ` component
30 | | Props | Type | Default |
31 | | ------------- |:-------------:| -----:|
32 | | **timeout** | number | 4ms |
33 |
34 | #### Props for ` ` component
35 | | Props | Type | Default |
36 | | ------------- |:-------------:| -----:|
37 | | **name** | string | `fadeIn` |
38 | | **duration** | string | "2s" |
39 | | **as** | string | "div" |
40 | | **timingFunction** | string | "ease" |
41 | | **component** | function | - |
42 |
43 | ## An element type to render as (string)
44 |
45 | An element type to render as. Eg -
46 |
47 | ```javascript
48 |
49 | Hello World
50 |
51 | ```
52 |
53 | outputs
54 |
55 | ```html
56 |
57 | Hello World
58 |
59 | ```
60 |
61 | ## DOM Nesting
62 |
63 | Animate Components ratifies the DOM nesting of the same elements by comparing the prop `as` and the child type. For eg -
64 |
65 | ```javascript
66 |
67 | Hello World!
68 |
69 | ```
70 |
71 | Here the element type for the children and the one passed to prop `as` is **'h1'**. Thereby prop value for `as` will change back to `div`(useful in some cases).
72 |
73 | ## Force interpolation of animations
74 | Pass **steps(steps, start|end)** using `forceInterpolate` prop. For example -
75 |
76 | ```javascript
77 |
78 | Hello World!
79 |
80 | ```
81 |
--------------------------------------------------------------------------------
/packages/animate-components/docs/example.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | * [Basic](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/simple.js)
4 |
5 | * [DOM Nesting](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/domNesting.js)
6 |
7 | * [forceInterpolate prop](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/forceInterpolate.js)
8 |
9 | * [Merge animations](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/multistep.js)
10 |
11 | * [Render as an element type](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/renderElementType.js)
12 |
13 | * [HTML attribute support](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/App.js)
14 |
15 | * [Render component](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/componentProp.js)
16 |
17 | * [Delay rendering](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/delay.js)
18 |
19 | * [Disappear Component](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/Disappear.js)
20 |
21 | > Note - All the above examples are also valid for InfernoJS. There is no change in API for InfernoJS.
22 |
--------------------------------------------------------------------------------
/packages/animate-components/docs/performance.md:
--------------------------------------------------------------------------------
1 | # Performance
2 |
3 | Animating most of the properties is a performance concern. But Animate Components uses some combinations that can be animated safely like -
4 |
5 | * **translate()**
6 |
7 | * **scale()**
8 |
9 | * **rotate()**
10 |
11 | * **opacity**
12 |
13 |
14 | Read more about css animations and its performance [here](https://css-tricks.com/almanac/properties/a/animation/)
15 |
--------------------------------------------------------------------------------
/packages/animate-components/docs/tips.md:
--------------------------------------------------------------------------------
1 | # Some tips
2 |
3 | ### Negative Animation Delay
4 |
5 | Say you want to animate some elements but you don't want all the elements to start at the exact same position. Use negative delay for those elements.
6 |
7 | `animation-delay: -2s`
8 |
9 | ### Use `component` prop
10 |
11 | Use `component` prop when you want to render a component and apply animations on it.
12 |
13 | ```javascript
14 | // Without component prop
15 |
16 |
19 |
20 | ```
21 |
22 | ```javascript
23 | // With component prop
24 |
25 | ```
26 |
27 | Both `Merge` and an animation component support `component` prop. Shorthand right ?
28 |
29 | ### Merge two animations
30 |
31 | Perform multiple animations.
32 |
33 | ```html
34 |
59 | Hello
60 |
61 | ```
62 |
63 | ### Using html attributes along with the component props
64 |
65 | ```javascript
66 |
74 | Click here to redirect
75 |
76 |
77 | ```
78 |
79 | ### Delay both component rendering and animations
80 |
81 | [Example](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/delay.js)
82 |
--------------------------------------------------------------------------------
/packages/animate-components/docs/usage.md:
--------------------------------------------------------------------------------
1 | # Usage
2 | Let's take an example -
3 |
4 | ```javascript
5 | import React, { Component } from 'react';
6 |
7 | import { Entrance } from 'animate-components';
8 |
9 | class App extends Component {
10 | render () {
11 | return (
12 |
13 | Hello World
14 |
15 | )
16 | }
17 | }
18 |
19 | ```
20 |
21 | An animation component can takes these props:
22 |
23 | ### duration
24 | It defines seconds or milliseconds an animation takes to complete one cycle.
25 |
26 | ```javascript
27 |
28 |
29 |
30 | ```
31 | ### delay
32 | Specifies a delay for the start of an animation.
33 |
34 | ```javascript
35 |
36 |
37 |
38 | ```
39 | ### timingFunction
40 | Specifies the speed curve of the animation.
41 |
42 | ```javascript
43 |
44 |
45 |
46 | ```
47 | ### direction
48 | This prop lets an animation run in reverse direction or alternate cycles.
49 |
50 | ```javascript
51 |
52 |
53 |
54 | ```
55 | ### iterations
56 | Specifies the number of times an animation should run.
57 |
58 | ```javascript
59 |
60 |
61 |
62 | ```
63 | ### backfaceVisible
64 | This prop defines whether an element should be visible when not facing the screen or not.
65 |
66 | ```javascript
67 |
68 |
69 |
70 | ```
71 | ### fillMode
72 | Specifies a style for the element when the animation is not playing.
73 |
74 | ```javascript
75 |
76 |
77 |
78 | ```
79 | ### playState
80 | Specifies whether the animation is running or paused.
81 |
82 | ```javascript
83 |
84 |
85 |
86 | ```
87 | ### as
88 | An element type to render as using the prop `as`.
89 |
90 | ```javascript
91 |
92 |
93 | Hello World
94 |
95 | ```
96 |
97 | outputs
98 |
99 | ```html
100 |
101 | Hello World
102 |
103 | ```
104 |
105 | ### component
106 | A React component to render and apply animation on.
107 |
108 | ```javascript
109 | // App.js
110 |
111 | let App = () => {
112 | return (
113 |
114 | Clay
115 |
116 | );
117 | }
118 | ```
119 |
120 | ```javascript
121 | // Main component
122 |
123 | import React, { Component } from 'react';
124 | import { FadeIn } from 'animate-components';
125 |
126 | import App from './App';
127 |
128 | class Main extends Component {
129 | render () {
130 | return (
131 |
132 | );
133 | }
134 | }
135 | ```
136 |
137 | ## Merge Component
138 | Perform multiple animations.
139 |
140 | ```javascript
141 | import { Merge } from 'animate-components';
142 | import { fadeIn, slideUp } from 'animate-keyframes';
143 |
144 |
149 | Hello World
150 |
151 | ```
152 |
153 | ## Disappear Component
154 | Performs an animation and unmounts after the last-step (@keyframe).
155 | ```javascript
156 | import { Disappear } from 'animate-components';
157 | import { fadeIn } from 'animate-keyframes';
158 |
159 |
160 | Hello World
161 |
162 | ```
163 | > Note - You can also pass all the [html attributes](https://facebook.github.io/react/docs/dom-elements.html#all-supported-html-attributes) supported by React to both the Merge and Disappear component along with the above props. Check [this](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/App.js) example.
164 |
165 |
166 | ## Delay Component
167 | Delay both the rendering and animations. Detailed info [here](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/examples/delay.js).
168 |
169 |
170 | ## Usage with styled-components
171 | ```javascript
172 |
173 | import { fadeIn } from 'animate-keyframes';
174 |
175 | import styled from 'styled-components';
176 |
177 | const Heading = styled.h1`
178 | display: inline-block;
179 | animation: ${fadeIn} 2s ease-in;
180 | padding: 2rem 3rem;
181 | font-size: 1.2rem;
182 | `;
183 |
184 | ```
185 |
186 | Or if you are using ` ` component,
187 |
188 | ```javascript
189 | import { Merge } from 'animate-components';
190 |
191 | const animationOne = keyframes`
192 | ...some rules
193 | `;
194 |
195 | const animationTwo = keyframes`
196 | ...some rules
197 | `;
198 |
199 |
204 | Hello World
205 |
206 |
207 | ```
208 |
209 | ## Usage with Aphrodite
210 | ```javascript
211 | import { fadeIn } from 'animate-keyframes';
212 |
213 | import { StyleSheet, css } from 'aphrodite';
214 |
215 | const styles = StyleSheet.create({
216 | Fade: {
217 | animationName: fadeIn,
218 | animationDuration: '1s'
219 | }
220 | });
221 | ```
222 |
223 | ## Usage with glamor
224 | ```javascript
225 | import { fadeIn } from 'animate-keyframes';
226 |
227 | import { css } from 'glamor';
228 |
229 | let rule = css({
230 | display: 'inline-block',
231 | animation: `${fadeIn} 2s ease-in`,
232 | padding: '2rem 3rem',
233 | font-size: '1.2rem'
234 | });
235 | ```
236 |
237 | ## Usage with InfernoJS
238 |
239 | Use Animate Components in [InfernoJS](infernojs.org) with [`ac-inferno`](https://github.com/nitin42/animate-components/tree/master/packages/ac-inferno).
240 |
241 | ## Custom components 💃
242 | If you want to create your own animation components rather than using the built-in ones, `animate-components` also exports a high order function that lets you create your own components with ease (believe me!).
243 |
244 | Example -
245 |
246 | ```javascript
247 | import { hoc } from 'animate-components';
248 |
249 | // Keyframes with styled-components
250 | const rotate360 = keyframes`
251 | from {
252 | transform: rotate(0deg);
253 | }
254 |
255 | to {
256 | transform: rotate(360deg);
257 | }
258 | `;
259 |
260 | // Let's create an animation component
261 | const Rotate = hoc('Rotate', rotate360);
262 |
263 | let App = () => {
264 | return (
265 |
266 | I am rotating!
267 |
268 | );
269 | }
270 | ```
271 |
272 | > Note - `hoc` takes two arguments, Component name and keyframes.
273 |
274 | Now you have all the power!!
275 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/App.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | import { FadeIn } from 'animate-components';
4 |
5 | // import './some_css.css';
6 |
7 | class App extends Component {
8 | render () {
9 | return (
10 |
11 | Click here to redirect
12 |
13 | );
14 | }
15 | }
16 |
17 | export default App;
18 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/Disappear.js:
--------------------------------------------------------------------------------
1 | import { Disappear } from 'animate-components';
2 | import { fadeIn } from 'animate-keyframes';
3 |
4 | export default class App extends Component {
5 | render () {
6 | return (
7 |
8 | I will disappear after 2s!
9 |
10 | );
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/comp.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | let Comp = () => {
4 | return (
5 |
8 | );
9 | }
10 |
11 | export default Comp;
12 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/componentProp.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 |
3 | import { LightOut } from "../index";
4 | import Comp from "./comp";
5 | import "./index.css";
6 |
7 | class App extends Component {
8 | render() {
9 | return (
10 |
11 |
Using `component` prop
12 |
17 |
18 | );
19 | }
20 | }
21 |
22 | export default App;
23 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/delay.js:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | - Delay rendering and animations
4 |
5 | Use ` ` when you want to delay both the animation and component rendering. When using
6 | prop `delay="3s"`, animations are delayed but the component is already rendered. This looks weird in some
7 | cases. ` ` component will keep both in sync !
8 |
9 | - Event queuing model
10 |
11 | ` ` being asynchronous, takes the children component (animation component or any other component)
12 | which would be queued up for execution after the timeout has expired.
13 |
14 | */
15 |
16 |
17 | import React, { Component } from "react";
18 | import { FadeIn, Delay } from "animate-components";
19 |
20 | import Comp from './comp';
21 |
22 | class App extends Component {
23 | render() {
24 | return (
25 |
26 |
27 |
28 |
29 |
30 | );
31 | }
32 | }
33 |
34 | export default App;
35 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/domNesting.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { FadeIn } from "animate-components";
4 |
5 | // The FadeIn component will ratify the DOM nesting if the child element tag is similar to the one passed to prop `as`
6 | let App = () => {
7 | return (
8 |
9 |
10 | Hello world!
11 |
12 |
13 | );
14 | };
15 |
16 | export default App;
17 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/forceInterpolate.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { FadeIn } from "animate-components";
4 |
5 | let App = () => {
6 | return (
7 |
8 |
13 | Hello world!
14 |
15 |
16 | );
17 | };
18 |
19 | export default App;
20 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/multistep.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { fadeIn, slideUp } from "animate-keyframes";
4 | import { Merge } from "animate-components";
5 |
6 | let App = () => {
7 | return (
8 |
9 |
13 | Hello world!
14 |
15 |
16 | );
17 | };
18 |
19 | export default App;
20 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/renderElementType.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { Merge, FadeIn } from "animate-components";
4 | import { fadeIn, slideUp } from "animate-keyframes";
5 |
6 | let App = () => {
7 | return (
8 |
9 |
14 | Hello world!
15 |
16 |
17 |
18 | I love Katherine Langford.
19 |
20 |
21 | );
22 | };
23 |
24 | export default App;
25 |
--------------------------------------------------------------------------------
/packages/animate-components/examples/simple.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { FadeIn } from "animate-components";
4 |
5 | let App = () => {
6 | return (
7 |
8 |
9 | Hello world!
10 |
11 |
12 | );
13 | };
14 |
15 | export default App;
16 |
--------------------------------------------------------------------------------
/packages/animate-components/flow-typed/npm/animate-keyframes_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: aa736f2ae1a32740fa1fb8708808e079
2 | // flow-typed version: <>/animate-keyframes_v0.1.0/flow_v0.48.0
3 |
4 | // @flow
5 |
6 | type Keyframe$Rule = string;
7 |
8 | declare module "animate-keyframes" {
9 | declare module.exports: {
10 | bounce: Keyframe$Rule,
11 | bounceDown: Keyframe$Rule,
12 | bounceLeft: Keyframe$Rule,
13 | bounceRight: Keyframe$Rule,
14 | bounceUp: Keyframe$Rule,
15 | fadeIn: Keyframe$Rule,
16 | left: Keyframe$Rule,
17 | down: Keyframe$Rule,
18 | downBig: Keyframe$Rule,
19 | leftBig: Keyframe$Rule,
20 | rightBig: Keyframe$Rule,
21 | right: Keyframe$Rule,
22 | up: Keyframe$Rule,
23 | upBig: Keyframe$Rule,
24 | flip: Keyframe$Rule,
25 | flipX: Keyframe$Rule,
26 | flipY: Keyframe$Rule,
27 | lightIn: Keyframe$Rule,
28 | lightOut: Keyframe$Rule,
29 | rotateIn: Keyframe$Rule,
30 | rotateLeft: Keyframe$Rule,
31 | rotateRight: Keyframe$Rule,
32 | rotateUpLeft: Keyframe$Rule,
33 | rotateUpRight: Keyframe$Rule,
34 | flash: Keyframe$Rule,
35 | rollOut: Keyframe$Rule,
36 | rollIn: Keyframe$Rule,
37 | rubber: Keyframe$Rule,
38 | swing: Keyframe$Rule,
39 | zoom: Keyframe$Rule,
40 | hinge: Keyframe$Rule,
41 | pulse: Keyframe$Rule,
42 | expandUp: Keyframe$Rule,
43 | entrance: Keyframe$Rule,
44 | hatch: Keyframe$Rule,
45 | starWars: Keyframe$Rule,
46 | slideDown: Keyframe$Rule,
47 | slideLeft: Keyframe$Rule,
48 | slideRight: Keyframe$Rule,
49 | slideUp: Keyframe$Rule,
50 | perspectiveDown: Keyframe$Rule,
51 | perspectiveUp: Keyframe$Rule,
52 | perspectiveLeft: Keyframe$Rule,
53 | perspectiveRight: Keyframe$Rule,
54 | puffmein: Keyframe$Rule,
55 | puffmeout: Keyframe$Rule,
56 | vanishout: Keyframe$Rule,
57 | vanishin: Keyframe$Rule,
58 | expanseDown: Keyframe$Rule,
59 | expanseUp: Keyframe$Rule,
60 | expanseLeft: Keyframe$Rule,
61 | expanseRight: Keyframe$Rule
62 | };
63 | }
64 |
--------------------------------------------------------------------------------
/packages/animate-components/flow-typed/npm/element-utils_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 6da0827bce8b391f2c7e8794b1393125
2 | // flow-typed version: <>/element-utils_v0.0.3/flow_v0.48.0
3 |
4 | type Avoid$Nesting = (
5 | elementAs: string,
6 | props: Object,
7 | DisplayName: any
8 | ) => string;
9 |
10 | type Get$Element$Type = (Component: any, props: Object) => string;
11 |
12 | type Render$Function = (
13 | ComposedComponent: any,
14 | props: Object,
15 | state: Object,
16 | rest: any,
17 | DisplayName: any
18 | ) => ?React$Element;
19 |
20 | declare module "element-utils" {
21 | declare module.exports: {
22 | avoidNest: Avoid$Nesting,
23 | getElement: Get$Element$Type,
24 | Render: Render$Function
25 | };
26 | }
27 |
--------------------------------------------------------------------------------
/packages/animate-components/flow-typed/npm/html-tags_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 014496a465c441a5227052e5d219a3fe
2 | // flow-typed version: <>/html-tags_v2.0.0/flow_v0.48.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'html-tags'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'html-tags' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 |
26 |
27 | // Filename aliases
28 | declare module 'html-tags/index' {
29 | declare module.exports: $Exports<'html-tags'>;
30 | }
31 | declare module 'html-tags/index.js' {
32 | declare module.exports: $Exports<'html-tags'>;
33 | }
34 |
--------------------------------------------------------------------------------
/packages/animate-components/flow-typed/npm/prop-types_v15.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 3eaa1f24c7397b78a7481992d2cddcb2
2 | // flow-typed version: a1a20d4928/prop-types_v15.x.x/flow_>=v0.41.x
3 |
4 | type $npm$propTypes$ReactPropsCheckType = (
5 | props: any,
6 | propName: string,
7 | componentName: string,
8 | href?: string) => ?Error;
9 |
10 | declare module 'prop-types' {
11 | declare var array: React$PropType$Primitive>;
12 | declare var bool: React$PropType$Primitive;
13 | declare var func: React$PropType$Primitive;
14 | declare var number: React$PropType$Primitive;
15 | declare var object: React$PropType$Primitive;
16 | declare var string: React$PropType$Primitive;
17 | declare var any: React$PropType$Primitive;
18 | declare var arrayOf: React$PropType$ArrayOf;
19 | declare var element: React$PropType$Primitive; /* TODO */
20 | declare var instanceOf: React$PropType$InstanceOf;
21 | declare var node: React$PropType$Primitive; /* TODO */
22 | declare var objectOf: React$PropType$ObjectOf;
23 | declare var oneOf: React$PropType$OneOf;
24 | declare var oneOfType: React$PropType$OneOfType;
25 | declare var shape: React$PropType$Shape;
26 |
27 | declare function checkPropTypes(
28 | propTypes: $Subtype<{[_: $Keys]: $npm$propTypes$ReactPropsCheckType}>,
29 | values: V,
30 | location: string,
31 | componentName: string,
32 | getStack: ?(() => ?string)
33 | ) : void;
34 | }
35 |
--------------------------------------------------------------------------------
/packages/animate-components/flow-typed/npm/styled-components_v2.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 3a2f61dde69e3311cdc6d0f14863a9ef
2 | // flow-typed version: b2ad6292df/styled-components_v2.x.x/flow_>=v0.25.x
3 |
4 | // @flow
5 |
6 | type $npm$styledComponents$Interpolation = ((executionContext: Object) => string) | string | number;
7 | type $npm$styledComponents$NameGenerator = (hash: number) => string
8 |
9 | type $npm$styledComponents$StyledComponent = (
10 | strings: Array,
11 | ...interpolations: Array<$npm$styledComponents$Interpolation>
12 | ) => ReactClass<*>;
13 |
14 |
15 | type $npm$styledComponents$Theme = {[key: string]: mixed};
16 | type $npm$styledComponents$ThemeProviderProps = {
17 | theme: $npm$styledComponents$Theme | ((outerTheme: $npm$styledComponents$Theme) => void)
18 | };
19 | type $npm$styledComponents$Component =
20 | | ReactClass<*>
21 | | (props: *) => React$Element<*>;
22 |
23 | class Npm$StyledComponents$ThemeProvider extends React$Component {
24 | props: $npm$styledComponents$ThemeProviderProps;
25 | }
26 |
27 | type $npm$styledComponents$StyleSheetManagerProps = {
28 | sheet: mixed
29 | }
30 |
31 | class Npm$StyledComponents$StyleSheetManager extends React$Component {
32 | props: $npm$styledComponents$StyleSheetManagerProps;
33 | }
34 |
35 | class Npm$StyledComponents$ServerStyleSheet {
36 | instance: StyleSheet
37 | collectStyles: (children: any) => React$Element<*>
38 | getStyleTags: () => string
39 | getStyleElement: () => React$Element<*>
40 | }
41 |
42 | declare module 'styled-components' {
43 | declare type Interpolation = $npm$styledComponents$Interpolation;
44 | declare type NameGenerator = $npm$styledComponents$NameGenerator;
45 |
46 | declare type StyledComponent = $npm$styledComponents$StyledComponent;
47 |
48 | declare type Theme = $npm$styledComponents$Theme;
49 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps;
50 | declare type Component = $npm$styledComponents$Component;
51 |
52 | declare module.exports: {
53 | injectGlobal: (strings: Array, ...interpolations: Array) => void,
54 | css: (strings: Array, ...interpolations: Array) => Array,
55 | keyframes: (strings: Array, ...interpolations: Array) => string,
56 | withTheme: (component: Component) => React$Component<*, ThemeProviderProps, *>,
57 | ServerStyleSheet: typeof Npm$StyledComponents$ServerStyleSheet,
58 | StyleSheetManager: typeof Npm$StyledComponents$StyleSheetManager,
59 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider,
60 | (baseComponent: Component): StyledComponent,
61 | a: StyledComponent,
62 | abbr: StyledComponent,
63 | address: StyledComponent,
64 | area: StyledComponent,
65 | article: StyledComponent,
66 | aside: StyledComponent,
67 | audio: StyledComponent,
68 | b: StyledComponent,
69 | base: StyledComponent,
70 | bdi: StyledComponent,
71 | bdo: StyledComponent,
72 | big: StyledComponent,
73 | blockquote: StyledComponent,
74 | body: StyledComponent,
75 | br: StyledComponent,
76 | button: StyledComponent,
77 | canvas: StyledComponent,
78 | caption: StyledComponent,
79 | cite: StyledComponent,
80 | code: StyledComponent,
81 | col: StyledComponent,
82 | colgroup: StyledComponent,
83 | data: StyledComponent,
84 | datalist: StyledComponent,
85 | dd: StyledComponent,
86 | del: StyledComponent,
87 | details: StyledComponent,
88 | dfn: StyledComponent,
89 | dialog: StyledComponent,
90 | div: StyledComponent,
91 | dl: StyledComponent,
92 | dt: StyledComponent,
93 | em: StyledComponent,
94 | embed: StyledComponent,
95 | fieldset: StyledComponent,
96 | figcaption: StyledComponent,
97 | figure: StyledComponent,
98 | footer: StyledComponent,
99 | form: StyledComponent,
100 | h1: StyledComponent,
101 | h2: StyledComponent,
102 | h3: StyledComponent,
103 | h4: StyledComponent,
104 | h5: StyledComponent,
105 | h6: StyledComponent,
106 | head: StyledComponent,
107 | header: StyledComponent,
108 | hgroup: StyledComponent,
109 | hr: StyledComponent,
110 | html: StyledComponent,
111 | i: StyledComponent,
112 | iframe: StyledComponent,
113 | img: StyledComponent,
114 | input: StyledComponent,
115 | ins: StyledComponent,
116 | kbd: StyledComponent,
117 | keygen: StyledComponent,
118 | label: StyledComponent,
119 | legend: StyledComponent,
120 | li: StyledComponent,
121 | link: StyledComponent,
122 | main: StyledComponent,
123 | map: StyledComponent,
124 | mark: StyledComponent,
125 | menu: StyledComponent,
126 | menuitem: StyledComponent,
127 | meta: StyledComponent,
128 | meter: StyledComponent,
129 | nav: StyledComponent,
130 | noscript: StyledComponent,
131 | object: StyledComponent,
132 | ol: StyledComponent,
133 | optgroup: StyledComponent,
134 | option: StyledComponent,
135 | output: StyledComponent,
136 | p: StyledComponent,
137 | param: StyledComponent,
138 | picture: StyledComponent,
139 | pre: StyledComponent,
140 | progress: StyledComponent,
141 | q: StyledComponent,
142 | rp: StyledComponent,
143 | rt: StyledComponent,
144 | ruby: StyledComponent,
145 | s: StyledComponent,
146 | samp: StyledComponent,
147 | script: StyledComponent,
148 | section: StyledComponent,
149 | select: StyledComponent,
150 | small: StyledComponent,
151 | source: StyledComponent,
152 | span: StyledComponent,
153 | strong: StyledComponent,
154 | style: StyledComponent,
155 | sub: StyledComponent,
156 | summary: StyledComponent,
157 | sup: StyledComponent,
158 | table: StyledComponent,
159 | tbody: StyledComponent,
160 | td: StyledComponent,
161 | textarea: StyledComponent,
162 | tfoot: StyledComponent,
163 | th: StyledComponent,
164 | thead: StyledComponent,
165 | time: StyledComponent,
166 | title: StyledComponent,
167 | tr: StyledComponent,
168 | track: StyledComponent,
169 | u: StyledComponent,
170 | ul: StyledComponent,
171 | var: StyledComponent,
172 | video: StyledComponent,
173 | wbr: StyledComponent,
174 |
175 | // SVG
176 | circle: StyledComponent,
177 | clipPath: StyledComponent,
178 | defs: StyledComponent,
179 | ellipse: StyledComponent,
180 | g: StyledComponent,
181 | image: StyledComponent,
182 | line: StyledComponent,
183 | linearGradient: StyledComponent,
184 | mask: StyledComponent,
185 | path: StyledComponent,
186 | pattern: StyledComponent,
187 | polygon: StyledComponent,
188 | polyline: StyledComponent,
189 | radialGradient: StyledComponent,
190 | rect: StyledComponent,
191 | stop: StyledComponent,
192 | svg: StyledComponent,
193 | text: StyledComponent,
194 | tspan: StyledComponent,
195 | };
196 | }
197 |
198 | declare module 'styled-components/native' {
199 | declare type Interpolation = $npm$styledComponents$Interpolation;
200 | declare type NameGenerator = $npm$styledComponents$NameGenerator;
201 |
202 | declare type StyledComponent = $npm$styledComponents$StyledComponent;
203 |
204 | declare type Theme = $npm$styledComponents$Theme;
205 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps;
206 | declare type Component = $npm$styledComponents$Component;
207 |
208 | declare module.exports: {
209 | css: (strings: Array, ...interpolations: Array) => Array,
210 | withTheme: (component: Component) => React$Component<*, ThemeProviderProps, *>,
211 | keyframes: (strings: Array, ...interpolations: Array) => string,
212 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider,
213 |
214 | (baseComponent: Component): StyledComponent,
215 |
216 | ActivityIndicator: StyledComponent,
217 | ActivityIndicatorIOS: StyledComponent,
218 | ART: StyledComponent,
219 | Button: StyledComponent,
220 | DatePickerIOS: StyledComponent,
221 | DrawerLayoutAndroid: StyledComponent,
222 | FlatList: StyledComponent,
223 | Image: StyledComponent,
224 | ImageEditor: StyledComponent,
225 | ImageStore: StyledComponent,
226 | KeyboardAvoidingView: StyledComponent,
227 | ListView: StyledComponent,
228 | MapView: StyledComponent,
229 | Modal: StyledComponent,
230 | Navigator: StyledComponent,
231 | NavigatorIOS: StyledComponent,
232 | Picker: StyledComponent,
233 | PickerIOS: StyledComponent,
234 | ProgressBarAndroid: StyledComponent,
235 | ProgressViewIOS: StyledComponent,
236 | RecyclerViewBackedScrollView: StyledComponent,
237 | RefreshControl: StyledComponent,
238 | ScrollView: StyledComponent,
239 | SectionList: StyledComponent,
240 | SegmentedControlIOS: StyledComponent,
241 | Slider: StyledComponent,
242 | SliderIOS: StyledComponent,
243 | SnapshotViewIOS: StyledComponent,
244 | StatusBar: StyledComponent,
245 | SwipeableListView: StyledComponent,
246 | Switch: StyledComponent,
247 | SwitchAndroid: StyledComponent,
248 | SwitchIOS: StyledComponent,
249 | TabBarIOS: StyledComponent,
250 | Text: StyledComponent,
251 | TextInput: StyledComponent,
252 | ToastAndroid: StyledComponent,
253 | ToolbarAndroid: StyledComponent,
254 | Touchable: StyledComponent,
255 | TouchableHighlight: StyledComponent,
256 | TouchableNativeFeedback: StyledComponent,
257 | TouchableOpacity: StyledComponent,
258 | TouchableWithoutFeedback: StyledComponent,
259 | View: StyledComponent,
260 | ViewPagerAndroid: StyledComponent,
261 | VirtualizedList: StyledComponent,
262 | WebView: StyledComponent,
263 | };
264 | }
265 |
--------------------------------------------------------------------------------
/packages/animate-components/index.js:
--------------------------------------------------------------------------------
1 | import {
2 | flipObj,
3 | specialObj,
4 | slideObj,
5 | rotateObj,
6 | PObj,
7 | lightObj,
8 | fadeObj,
9 | expanseObj,
10 | bounceObj,
11 | bingoObj,
12 | } from './animations/index';
13 | import Merge from './containers/merge';
14 | import Delay from './containers/Delay';
15 | import Disappear from './containers/Disappear';
16 | import hoc from './containers/HOC';
17 |
18 | const { Bounce, BounceUp, BounceRight, BounceLeft, BounceDown } = bounceObj;
19 | const {
20 | FadeIn,
21 | FadeInUp,
22 | FadeInRight,
23 | FadeInLeft,
24 | FadeInDown,
25 | FadeInUpBig,
26 | FadeInRightBig,
27 | FadeInLeftBig,
28 | } = fadeObj;
29 | const { Flip, FlipInX, FlipInY, FlipOutX, FlipOutY } = flipObj;
30 | const { LightOut, LightIn } = lightObj;
31 | const {
32 | RotateIn,
33 | RotateRight,
34 | RotateLeft,
35 | RotateUpRight,
36 | RotateUpLeft,
37 | } = rotateObj;
38 | const {
39 | Flash,
40 | RollOut,
41 | RollIn,
42 | Rubber,
43 | Swing,
44 | Zoom,
45 | Hinge,
46 | Pulse,
47 | ExpandUp,
48 | Entrance,
49 | Hatch,
50 | StarWars,
51 | } = specialObj;
52 | const { SlideUp, SlideRight, SlideLeft, SlideDown } = slideObj;
53 | const { PDown, PUp, PRight, PLeft } = PObj;
54 | const { PuffOut, PuffIn, VanishOut, VanishIn } = bingoObj;
55 | const { ExpanseUp, ExpanseRight, ExpanseDown, ExpanseLeft } = expanseObj;
56 |
57 | /** Animation components */
58 | export {
59 | Bounce,
60 | BounceUp,
61 | BounceRight,
62 | BounceLeft,
63 | BounceDown,
64 | FadeIn,
65 | FadeInUp,
66 | FadeInRight,
67 | FadeInLeft,
68 | FadeInDown,
69 | FadeInUpBig,
70 | FadeInLeftBig,
71 | FadeInRightBig,
72 | Flip,
73 | FlipInX,
74 | FlipInY,
75 | FlipOutX,
76 | FlipOutY,
77 | LightOut,
78 | LightIn,
79 | RotateIn,
80 | RotateRight,
81 | RotateLeft,
82 | RotateUpRight,
83 | RotateUpLeft,
84 | Flash,
85 | RollOut,
86 | RollIn,
87 | Rubber,
88 | Swing,
89 | Zoom,
90 | Hinge,
91 | Pulse,
92 | SlideUp,
93 | SlideDown,
94 | SlideLeft,
95 | SlideRight,
96 | StarWars,
97 | ExpandUp,
98 | Entrance,
99 | Hatch,
100 | PDown,
101 | PUp,
102 | PRight,
103 | PLeft,
104 | PuffIn,
105 | PuffOut,
106 | VanishIn,
107 | VanishOut,
108 | ExpanseLeft,
109 | ExpanseRight,
110 | ExpanseDown,
111 | ExpanseUp,
112 | Merge,
113 | Delay,
114 | Disappear,
115 | hoc,
116 | };
117 |
--------------------------------------------------------------------------------
/packages/animate-components/main.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./dist/animate-components.min.js');
2 |
--------------------------------------------------------------------------------
/packages/animate-components/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "animate-components",
3 | "version": "1.4.6",
4 | "description": "Elemental components for animations in React",
5 | "keywords": [
6 | "react",
7 | "keyframes",
8 | "animate",
9 | "high order component",
10 | "composed components",
11 | "animations",
12 | "styled",
13 | "merge",
14 | "delay",
15 | "element type"
16 | ],
17 | "main": "main.js",
18 | "scripts": {
19 | "prebuild": "rm -rf build",
20 | "prepublishOnly": "yarn test && yarn flow && yarn webpack:build",
21 | "test": "./node_modules/.bin/jest",
22 | "test:watch": "./node_modules/.bin/jest --watch",
23 | "test:coverage": "./node_modules/.bin/jest --coverage",
24 | "builder": "node ../../scripts/check.js",
25 | "lint": "./node_modules/.bin/eslint ./containers ./mods ./utils",
26 | "start": "../../node_modules/.bin/webpack-dev-server --watch --open --config ../../starter/webpack.config.js",
27 | "flow": "./node_modules/.bin/flow",
28 | "webpack:build": "NODE_ENV=production ./node_modules/.bin/webpack --config ./webpack/webpack.config.js --display-max-modules 0 --display-optimization-bailout"
29 | },
30 | "files": [
31 | "dist",
32 | "main.js"
33 | ],
34 | "author": "Nitin Tulswani ",
35 | "license": "MIT",
36 | "dependencies": {
37 | "animate-keyframes": "^0.1.6",
38 | "element-utils": "^0.1.2",
39 | "html-tags": "^1.1.1",
40 | "prop-types": "^15.5.8"
41 | },
42 | "peerDependencies": {
43 | "react": "^16.0.0",
44 | "react-dom": "^16.0.0"
45 | },
46 | "jest": {
47 | "testEnvironment": "node"
48 | },
49 | "homepage": "https://github.com/nitin42/animate-components",
50 | "devDependencies": {
51 | "aphrodite": "^1.2.1",
52 | "babel-cli": "^6.24.1",
53 | "babel-eslint": "^7.2.3",
54 | "babel-jest": "^19.0.0",
55 | "babel-loader": "^6.4.1",
56 | "babel-plugin-transform-class-properties": "^6.23.0",
57 | "babel-plugin-transform-es2015-modules-umd": "^6.24.1",
58 | "babel-plugin-transform-flow-strip-types": "^6.22.0",
59 | "babel-plugin-transform-object-rest-spread": "^6.23.0",
60 | "babel-plugin-transform-react-remove-prop-types": "^0.4.6",
61 | "babel-preset-es2015": "^6.24.1",
62 | "babel-preset-flow": "^6.23.0",
63 | "babel-preset-react": "^6.24.1",
64 | "babel-preset-stage-0": "^6.24.1",
65 | "babili": "^0.0.12",
66 | "babili-webpack-plugin": "^0.1.1",
67 | "clean-webpack-plugin": "^0.1.16",
68 | "compression-webpack-plugin": "^0.4.0",
69 | "css-loader": "^0.28.0",
70 | "enzyme": "^2.8.0",
71 | "eslint": "^3.19.0",
72 | "eslint-config-airbnb": "^15.0.1",
73 | "eslint-plugin-flowtype": "^2.33.0",
74 | "eslint-plugin-import": "^2.2.0",
75 | "eslint-plugin-jsx-a11y": "^5.0.3",
76 | "eslint-plugin-react": "^7.0.1",
77 | "extract-text-webpack-plugin": "^2.1.0",
78 | "flow-bin": "^0.48.0",
79 | "html-webpack-plugin": "^2.28.0",
80 | "html-webpack-template": "^6.0.1",
81 | "jest": "^20.0.4",
82 | "jest-styled-components": "^2.0.0",
83 | "lerna": "^2.0.0-rc.5",
84 | "react-test-renderer": "^15.6.1",
85 | "style-loader": "^0.16.1",
86 | "styled-components": "^2.1.0",
87 | "webpack": "^3.0.0"
88 | },
89 | "repository": {
90 | "type": "git",
91 | "url": "https://github.com/nitin42/animate-components",
92 | "bugs": {
93 | "url": "https://github.com/nitin42/animate-components/issues"
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/packages/animate-components/utils/keyValidators.js:
--------------------------------------------------------------------------------
1 | const names = (key, propValue) => {
2 | if (key === 'name' && typeof propValue[key] !== 'string') {
3 | /* eslint-disable no-console */
4 | console.error(
5 | 'Warning: Failed propType. Prop value for animation name should be a string.',
6 | );
7 | }
8 | };
9 |
10 | const duration = (key, propValue) => {
11 | if (key === 'duration' && typeof propValue[key] !== 'string') {
12 | /* eslint-disable no-console */
13 | console.error(
14 | 'Warning: Failed propType. Prop value for animation duration should be a string. For eg - \'2s\'',
15 | );
16 | }
17 | };
18 |
19 | const timingFunction = (key, propValue) => {
20 | if (key === 'timingFunction' && typeof propValue[key] === 'string') {
21 | const arr = [
22 | 'linear',
23 | 'ease',
24 | 'ease-in',
25 | 'ease-out',
26 | 'ease-in-out',
27 | 'step-start',
28 | 'step-end',
29 | ];
30 |
31 | const err = `
32 | Warning: Invalid timing Function '${propValue[key]}' passed to the Merge component. The prop
33 | value for 'timingFunction' should be one of ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out',
34 | 'step-start', 'step-end']. Note steps(#, start|end) is supported via forceInterpolate prop. Refer to the docs for more info.
35 | `;
36 |
37 | /* eslint-disable no-console */
38 | return arr.includes(propValue[key]) ? null : console.error(err);
39 | } else if (key === 'timingFunction' && typeof propValue[key] !== 'string') {
40 | console.error(
41 | 'Warning: Failed propType. Prop value for tf should be a string. For eg - \'ease-out\'',
42 | );
43 | }
44 | };
45 |
46 | const direction = (key, propValue) => {
47 | if (key === 'direction' && typeof propValue[key] !== 'string') {
48 | /* eslint-disable no-console */
49 | console.error(
50 | 'Warning: Failed propType. Prop value for \'direction\' should be a string.',
51 | );
52 | }
53 | };
54 |
55 | const interpolateValidators = (key) => {
56 | const keys = ['steps', 'direction'];
57 | const err = `Warning: Unknown prop '${key}' passed to the Merge component.`;
58 |
59 | /* eslint-disable no-console */
60 | return keys.includes(key) ? null : console.error(err);
61 | };
62 |
63 | const propValidators = (key) => {
64 | const keys = ['name', 'duration', 'timingFunction'];
65 | const err = `Warning: Unknown prop '${key}' passed to the Merge component. Prop should be one of [${keys}]`;
66 |
67 | /* eslint-disable no-console */
68 | return keys.includes(key) ? null : console.error(err);
69 | };
70 |
71 | export {
72 | names,
73 | duration,
74 | timingFunction,
75 | propValidators,
76 | direction,
77 | interpolateValidators,
78 | };
79 |
--------------------------------------------------------------------------------
/packages/animate-components/utils/state.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | // Utilities for changing the component state based on a particular prop.
4 | const derive = (props: Object, AnimationName: string): string => {
5 | const {
6 | duration,
7 | timingFunction,
8 | delay,
9 | direction,
10 | iterations,
11 | fillMode,
12 | playState,
13 | forceInterpolate,
14 | } = props;
15 |
16 | if (forceInterpolate) {
17 | return `${AnimationName} ${duration} steps(${forceInterpolate.steps}, ${forceInterpolate.direction}) ${delay} ${iterations} ${fillMode} ${playState}`;
18 | }
19 |
20 | return `${AnimationName} ${duration} ${timingFunction} ${delay} ${iterations} ${direction} ${fillMode} ${playState}`;
21 | };
22 |
23 | export default derive;
24 |
--------------------------------------------------------------------------------
/packages/animate-components/webpack/config.js:
--------------------------------------------------------------------------------
1 | const webpack = require('webpack');
2 | const { join, resolve } = require('path');
3 | const CompressionPlugin = require('compression-webpack-plugin');
4 | const BabiliPlugin = require('babili-webpack-plugin');
5 | const CleanWebpackPlugin = require('clean-webpack-plugin');
6 |
7 | const pkg = require('../package.json');
8 |
9 | const common = {
10 | exclude: [
11 | /node_modules/,
12 | /__tests__/,
13 | /docs/,
14 | /coverage/,
15 | /dist/,
16 | /examples/,
17 | /scripts/,
18 | /starter/,
19 | ]
20 | };
21 |
22 | const jsLoader = () => {
23 | return {
24 | test: /\.js$/,
25 | exclude: common.exclude,
26 | use: ['babel-loader']
27 | };
28 | };
29 |
30 | const styleLoader = () => {
31 | return {
32 | test: /\.css$/,
33 | exclude: common.exclude,
34 | use: ['style-loader', 'css-loader']
35 | };
36 | };
37 |
38 | let output = () => {
39 | return {
40 | filename: '[name].min.js',
41 | path: resolve(__dirname, '../dist'),
42 | libraryTarget: 'umd',
43 | library: 'animateComponents',
44 | publicPath: '/',
45 | pathinfo: true
46 | };
47 | };
48 |
49 | const plugins = () => {
50 | return [
51 | new webpack.LoaderOptionsPlugin({
52 | minimize: true,
53 | debug: false,
54 | options: {
55 | context: __dirname
56 | }
57 | }),
58 | new webpack.optimize.ModuleConcatenationPlugin(),
59 | // Better results
60 | new BabiliPlugin(),
61 | new webpack.DefinePlugin({
62 | 'process.env': {
63 | NODE_ENV: JSON.stringify('production')
64 | }
65 | }),
66 | // new webpack.optimize.UglifyJsPlugin(),
67 | new CompressionPlugin({
68 | asset: '[path].gz[query]',
69 | algorithm: 'gzip',
70 | test: /\.js$|\.css$|\.html$/,
71 | threshold: 10240,
72 | minRatio: 0.8
73 | }),
74 | new CleanWebpackPlugin([resolve(__dirname, 'dist')])
75 | ];
76 | };
77 |
78 | const externals = () => {
79 | return {
80 | react: 'react',
81 | 'react-dom': 'react-dom',
82 | 'prop-types': 'prop-types',
83 | 'html-tags': 'html-tags',
84 | 'animate-keyframes': 'animate-keyframes',
85 | 'element-utils': 'element-utils'
86 | };
87 | };
88 |
89 | const entry = () => {
90 | return {
91 | [pkg.name]: join(__dirname, '../index.js')
92 | };
93 | };
94 |
95 | module.exports = {
96 | jsLoader,
97 | output,
98 | styleLoader,
99 | plugins,
100 | externals,
101 | entry
102 | };
103 |
--------------------------------------------------------------------------------
/packages/animate-components/webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | const {
2 | jsLoader,
3 | styleLoader,
4 | output,
5 | plugins,
6 | externals,
7 | entry
8 | } = require('./config');
9 |
10 | // All configurations in ./config.js
11 | module.exports = {
12 | entry: entry(),
13 | output: output(),
14 | devtool: 'cheap-module-source-map',
15 | cache: true,
16 | module: {
17 | rules: [jsLoader(), styleLoader()]
18 | },
19 | target: 'web',
20 | externals: externals(),
21 | plugins: plugins()
22 | };
23 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["babili", "flow", "es2015"],
3 | "plugins": ["transform-flow-strip-types"]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/.flowconfig:
--------------------------------------------------------------------------------
1 | [include]
2 | ./keyframes.js
3 | ./main.js
4 |
5 | [ignore]
6 | .*/node_modules/styled-components/.*
7 | .*/node_modules/
8 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | /node_modules
3 | build
4 | coverage
5 | dist
6 | entry.js
7 | index.js
8 |
9 | # misc
10 | .DS_Store
11 | .env
12 | npm-debug.log*
13 | lerna-debug.log
14 | yarn.lock
15 | yarn-error.log
16 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/README.md:
--------------------------------------------------------------------------------
1 | ## animate-keyframes
2 | 
3 |
4 | > ***Keyframes for animations***
5 |
6 | ## Install
7 | ```
8 | npm install animate-keyframes
9 | ```
10 |
11 | ## Usage
12 | Keyframes are required when you use [Merge](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/docs/usage.md#merge-component) and [Disappear](https://github.com/nitin42/animate-components/blob/master/packages/animate-components/docs/usage.md#disappear-component) Component. Earlier they were bundled within the same package ([`animate-components`](../animate-components)) so there are few changes when importing them.
13 |
14 | To import any keyframe,
15 |
16 | ```
17 | import { fadeIn } from 'animate-keyframes';
18 | ```
19 |
20 | ## List of keyframes
21 |
22 | ### Bounce
23 |
24 | * `bounce`
25 | * `bounceUp`
26 | * `bounceRight`
27 | * `bounceLeft`
28 | * `bounceDown`
29 |
30 | ### Fade
31 |
32 | * `fadeIn`
33 | * `up`
34 | * `right`
35 | * `left`
36 | * `down`
37 | * `downBig`
38 | * `upBig`
39 | * `leftBig`
40 | * `rightBig`
41 |
42 | ### Flip
43 |
44 | * `flip`
45 | * `flipX`
46 | * `flipY`
47 |
48 | ### LightSpeed
49 |
50 | * `lightOut`
51 | * `lightIn`
52 |
53 | ### Rotate
54 |
55 | * `rotateIn`
56 | * `rotateRight`
57 | * `rotateLeft`
58 | * `rotateUpRight`
59 | * `rotateUpLeft`
60 |
61 | ### Slide
62 |
63 | * `slideUp`
64 | * `slideDown`
65 | * `slideLeft`
66 | * `slideRight`
67 |
68 | ### Special
69 |
70 | * `flash`
71 | * `rollOut`
72 | * `rollIn`
73 | * `rubber`
74 | * `swing`
75 | * `zoom`
76 | * `hinge`
77 | * `pulse`
78 | * `expandUp`
79 | * `entrance`
80 | * `hatch`
81 | * `starWars`
82 |
83 | ### Perspective
84 |
85 | * `perspectiveDown`
86 | * `perspectiveUp`
87 | * `perspectiveLeft`
88 | * `perspectiveRight`
89 |
90 | ### Bingo
91 |
92 | * `puffmeout`
93 | * `puffmein`
94 | * `vanishout`
95 | * `vanishin`
96 |
97 | ### Expanse
98 |
99 | * `expanseUp`
100 | * `expanseDown`
101 | * `expanseLeft`
102 | * `expanseRight`
103 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/flow-typed/npm/styled-components_v2.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 3a2f61dde69e3311cdc6d0f14863a9ef
2 | // flow-typed version: b2ad6292df/styled-components_v2.x.x/flow_>=v0.25.x
3 |
4 | // @flow
5 |
6 | type $npm$styledComponents$Interpolation = ((executionContext: Object) => string) | string | number;
7 | type $npm$styledComponents$NameGenerator = (hash: number) => string
8 |
9 | type $npm$styledComponents$StyledComponent = (
10 | strings: Array,
11 | ...interpolations: Array<$npm$styledComponents$Interpolation>
12 | ) => ReactClass<*>;
13 |
14 |
15 | type $npm$styledComponents$Theme = {[key: string]: mixed};
16 | type $npm$styledComponents$ThemeProviderProps = {
17 | theme: $npm$styledComponents$Theme | ((outerTheme: $npm$styledComponents$Theme) => void)
18 | };
19 | type $npm$styledComponents$Component =
20 | | ReactClass<*>
21 | | (props: *) => React$Element<*>;
22 |
23 | class Npm$StyledComponents$ThemeProvider extends React$Component {
24 | props: $npm$styledComponents$ThemeProviderProps;
25 | }
26 |
27 | type $npm$styledComponents$StyleSheetManagerProps = {
28 | sheet: mixed
29 | }
30 |
31 | class Npm$StyledComponents$StyleSheetManager extends React$Component {
32 | props: $npm$styledComponents$StyleSheetManagerProps;
33 | }
34 |
35 | class Npm$StyledComponents$ServerStyleSheet {
36 | instance: StyleSheet
37 | collectStyles: (children: any) => React$Element<*>
38 | getStyleTags: () => string
39 | getStyleElement: () => React$Element<*>
40 | }
41 |
42 | declare module 'styled-components' {
43 | declare type Interpolation = $npm$styledComponents$Interpolation;
44 | declare type NameGenerator = $npm$styledComponents$NameGenerator;
45 |
46 | declare type StyledComponent = $npm$styledComponents$StyledComponent;
47 |
48 | declare type Theme = $npm$styledComponents$Theme;
49 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps;
50 | declare type Component = $npm$styledComponents$Component;
51 |
52 | declare module.exports: {
53 | injectGlobal: (strings: Array, ...interpolations: Array) => void,
54 | css: (strings: Array, ...interpolations: Array) => Array,
55 | keyframes: (strings: Array, ...interpolations: Array) => string,
56 | withTheme: (component: Component) => React$Component<*, ThemeProviderProps, *>,
57 | ServerStyleSheet: typeof Npm$StyledComponents$ServerStyleSheet,
58 | StyleSheetManager: typeof Npm$StyledComponents$StyleSheetManager,
59 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider,
60 | (baseComponent: Component): StyledComponent,
61 | a: StyledComponent,
62 | abbr: StyledComponent,
63 | address: StyledComponent,
64 | area: StyledComponent,
65 | article: StyledComponent,
66 | aside: StyledComponent,
67 | audio: StyledComponent,
68 | b: StyledComponent,
69 | base: StyledComponent,
70 | bdi: StyledComponent,
71 | bdo: StyledComponent,
72 | big: StyledComponent,
73 | blockquote: StyledComponent,
74 | body: StyledComponent,
75 | br: StyledComponent,
76 | button: StyledComponent,
77 | canvas: StyledComponent,
78 | caption: StyledComponent,
79 | cite: StyledComponent,
80 | code: StyledComponent,
81 | col: StyledComponent,
82 | colgroup: StyledComponent,
83 | data: StyledComponent,
84 | datalist: StyledComponent,
85 | dd: StyledComponent,
86 | del: StyledComponent,
87 | details: StyledComponent,
88 | dfn: StyledComponent,
89 | dialog: StyledComponent,
90 | div: StyledComponent,
91 | dl: StyledComponent,
92 | dt: StyledComponent,
93 | em: StyledComponent,
94 | embed: StyledComponent,
95 | fieldset: StyledComponent,
96 | figcaption: StyledComponent,
97 | figure: StyledComponent,
98 | footer: StyledComponent,
99 | form: StyledComponent,
100 | h1: StyledComponent,
101 | h2: StyledComponent,
102 | h3: StyledComponent,
103 | h4: StyledComponent,
104 | h5: StyledComponent,
105 | h6: StyledComponent,
106 | head: StyledComponent,
107 | header: StyledComponent,
108 | hgroup: StyledComponent,
109 | hr: StyledComponent,
110 | html: StyledComponent,
111 | i: StyledComponent,
112 | iframe: StyledComponent,
113 | img: StyledComponent,
114 | input: StyledComponent,
115 | ins: StyledComponent,
116 | kbd: StyledComponent,
117 | keygen: StyledComponent,
118 | label: StyledComponent,
119 | legend: StyledComponent,
120 | li: StyledComponent,
121 | link: StyledComponent,
122 | main: StyledComponent,
123 | map: StyledComponent,
124 | mark: StyledComponent,
125 | menu: StyledComponent,
126 | menuitem: StyledComponent,
127 | meta: StyledComponent,
128 | meter: StyledComponent,
129 | nav: StyledComponent,
130 | noscript: StyledComponent,
131 | object: StyledComponent,
132 | ol: StyledComponent,
133 | optgroup: StyledComponent,
134 | option: StyledComponent,
135 | output: StyledComponent,
136 | p: StyledComponent,
137 | param: StyledComponent,
138 | picture: StyledComponent,
139 | pre: StyledComponent,
140 | progress: StyledComponent,
141 | q: StyledComponent,
142 | rp: StyledComponent,
143 | rt: StyledComponent,
144 | ruby: StyledComponent,
145 | s: StyledComponent,
146 | samp: StyledComponent,
147 | script: StyledComponent,
148 | section: StyledComponent,
149 | select: StyledComponent,
150 | small: StyledComponent,
151 | source: StyledComponent,
152 | span: StyledComponent,
153 | strong: StyledComponent,
154 | style: StyledComponent,
155 | sub: StyledComponent,
156 | summary: StyledComponent,
157 | sup: StyledComponent,
158 | table: StyledComponent,
159 | tbody: StyledComponent,
160 | td: StyledComponent,
161 | textarea: StyledComponent,
162 | tfoot: StyledComponent,
163 | th: StyledComponent,
164 | thead: StyledComponent,
165 | time: StyledComponent,
166 | title: StyledComponent,
167 | tr: StyledComponent,
168 | track: StyledComponent,
169 | u: StyledComponent,
170 | ul: StyledComponent,
171 | var: StyledComponent,
172 | video: StyledComponent,
173 | wbr: StyledComponent,
174 |
175 | // SVG
176 | circle: StyledComponent,
177 | clipPath: StyledComponent,
178 | defs: StyledComponent,
179 | ellipse: StyledComponent,
180 | g: StyledComponent,
181 | image: StyledComponent,
182 | line: StyledComponent,
183 | linearGradient: StyledComponent,
184 | mask: StyledComponent,
185 | path: StyledComponent,
186 | pattern: StyledComponent,
187 | polygon: StyledComponent,
188 | polyline: StyledComponent,
189 | radialGradient: StyledComponent,
190 | rect: StyledComponent,
191 | stop: StyledComponent,
192 | svg: StyledComponent,
193 | text: StyledComponent,
194 | tspan: StyledComponent,
195 | };
196 | }
197 |
198 | declare module 'styled-components/native' {
199 | declare type Interpolation = $npm$styledComponents$Interpolation;
200 | declare type NameGenerator = $npm$styledComponents$NameGenerator;
201 |
202 | declare type StyledComponent = $npm$styledComponents$StyledComponent;
203 |
204 | declare type Theme = $npm$styledComponents$Theme;
205 | declare type ThemeProviderProps = $npm$styledComponents$ThemeProviderProps;
206 | declare type Component = $npm$styledComponents$Component;
207 |
208 | declare module.exports: {
209 | css: (strings: Array, ...interpolations: Array) => Array,
210 | withTheme: (component: Component) => React$Component<*, ThemeProviderProps, *>,
211 | keyframes: (strings: Array, ...interpolations: Array) => string,
212 | ThemeProvider: typeof Npm$StyledComponents$ThemeProvider,
213 |
214 | (baseComponent: Component): StyledComponent,
215 |
216 | ActivityIndicator: StyledComponent,
217 | ActivityIndicatorIOS: StyledComponent,
218 | ART: StyledComponent,
219 | Button: StyledComponent,
220 | DatePickerIOS: StyledComponent,
221 | DrawerLayoutAndroid: StyledComponent,
222 | FlatList: StyledComponent,
223 | Image: StyledComponent,
224 | ImageEditor: StyledComponent,
225 | ImageStore: StyledComponent,
226 | KeyboardAvoidingView: StyledComponent,
227 | ListView: StyledComponent,
228 | MapView: StyledComponent,
229 | Modal: StyledComponent,
230 | Navigator: StyledComponent,
231 | NavigatorIOS: StyledComponent,
232 | Picker: StyledComponent,
233 | PickerIOS: StyledComponent,
234 | ProgressBarAndroid: StyledComponent,
235 | ProgressViewIOS: StyledComponent,
236 | RecyclerViewBackedScrollView: StyledComponent,
237 | RefreshControl: StyledComponent,
238 | ScrollView: StyledComponent,
239 | SectionList: StyledComponent,
240 | SegmentedControlIOS: StyledComponent,
241 | Slider: StyledComponent,
242 | SliderIOS: StyledComponent,
243 | SnapshotViewIOS: StyledComponent,
244 | StatusBar: StyledComponent,
245 | SwipeableListView: StyledComponent,
246 | Switch: StyledComponent,
247 | SwitchAndroid: StyledComponent,
248 | SwitchIOS: StyledComponent,
249 | TabBarIOS: StyledComponent,
250 | Text: StyledComponent,
251 | TextInput: StyledComponent,
252 | ToastAndroid: StyledComponent,
253 | ToolbarAndroid: StyledComponent,
254 | Touchable: StyledComponent,
255 | TouchableHighlight: StyledComponent,
256 | TouchableNativeFeedback: StyledComponent,
257 | TouchableOpacity: StyledComponent,
258 | TouchableWithoutFeedback: StyledComponent,
259 | View: StyledComponent,
260 | ViewPagerAndroid: StyledComponent,
261 | VirtualizedList: StyledComponent,
262 | WebView: StyledComponent,
263 | };
264 | }
265 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./src/keyframes');
2 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "animate-keyframes",
3 | "version": "0.1.6",
4 | "description": "Keyframes for animate-components",
5 | "main": "./dist/keyframes.js",
6 | "repository": "https://github.com/nitin42/animate-components",
7 | "author": "Nitin Tulswani",
8 | "license": "MIT",
9 | "scripts": {
10 | "prebuild": "rm -rf ./dist",
11 | "flow": "./node_modules/.bin/flow",
12 | "build": "./node_modules/.bin/babel src -d dist",
13 | "prepublishOnly": "yarn flow && yarn build"
14 | },
15 | "files": [
16 | "dist"
17 | ],
18 | "dependencies": {
19 | "styled-components": "^2.1.0"
20 | },
21 | "devDependencies": {
22 | "babel-cli": "^6.24.1",
23 | "babel-plugin-transform-flow-strip-types": "^6.22.0",
24 | "babel-preset-babili": "^0.1.4",
25 | "babel-preset-es2015": "^6.24.1",
26 | "babel-preset-flow": "^6.23.0",
27 | "flow-bin": "^0.48.0",
28 | "flow-typed": "^2.1.2"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/src/keyframes.js:
--------------------------------------------------------------------------------
1 | import {
2 | Bouncing,
3 | Fade,
4 | Flippy,
5 | Light,
6 | Rotate,
7 | Special,
8 | Slide,
9 | Perspective,
10 | Bingo,
11 | Expanse
12 | } from "./main";
13 |
14 | const { bounce, bounceDown, bounceUp, bounceLeft, bounceRight } = Bouncing;
15 | const {
16 | fadeIn,
17 | left,
18 | leftBig,
19 | right,
20 | rightBig,
21 | down,
22 | downBig,
23 | up,
24 | upBig
25 | } = Fade;
26 | const { flip, flipInX, flipInY, flipOutX, flipOutY } = Flippy;
27 | const { lightIn, lightOut } = Light;
28 | const {
29 | rotateIn,
30 | rotateRight,
31 | rotateLeft,
32 | rotateUpLeft,
33 | rotateUpRight
34 | } = Rotate;
35 | const {
36 | flash,
37 | rollOut,
38 | rollIn,
39 | rubber,
40 | swing,
41 | zoom,
42 | hinge,
43 | hingeDrop,
44 | pulse,
45 | expandUp,
46 | entrance,
47 | hatch,
48 | starWars
49 | } = Special;
50 | const { slideUp, slideDown, slideLeft, slideRight } = Slide;
51 | const {
52 | perspectiveDown,
53 | perspectiveUp,
54 | perspectiveRight,
55 | perspectiveLeft
56 | } = Perspective;
57 | const { puffmeout, puffmein, vanishin, vanishout } = Bingo;
58 | const { expanseUp, expanseRight, expanseDown, expanseLeft } = Expanse;
59 |
60 | export {
61 | bounce,
62 | bounceDown,
63 | bounceLeft,
64 | bounceRight,
65 | bounceUp,
66 | fadeIn,
67 | left,
68 | down,
69 | downBig,
70 | leftBig,
71 | rightBig,
72 | right,
73 | up,
74 | upBig,
75 | flip,
76 | flipInX,
77 | flipInY,
78 | flipOutX,
79 | flipOutY,
80 | lightIn,
81 | lightOut,
82 | rotateIn,
83 | rotateLeft,
84 | rotateRight,
85 | rotateUpLeft,
86 | rotateUpRight,
87 | flash,
88 | rollOut,
89 | rollIn,
90 | rubber,
91 | swing,
92 | zoom,
93 | hinge,
94 | hingeDrop,
95 | pulse,
96 | expandUp,
97 | entrance,
98 | hatch,
99 | starWars,
100 | slideDown,
101 | slideLeft,
102 | slideRight,
103 | slideUp,
104 | perspectiveDown,
105 | perspectiveUp,
106 | perspectiveLeft,
107 | perspectiveRight,
108 | puffmein,
109 | puffmeout,
110 | vanishout,
111 | vanishin,
112 | expanseDown,
113 | expanseUp,
114 | expanseLeft,
115 | expanseRight
116 | };
117 |
--------------------------------------------------------------------------------
/packages/animate-keyframes/src/main.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import { keyframes } from 'styled-components';
4 |
5 | type keyframe = string;
6 |
7 | type KeyframeObject = {
8 | [key: string | any]: keyframe
9 | };
10 |
11 | // Bingo
12 | const Bingo: KeyframeObject = {
13 | puffmeout: keyframes`
14 | 0% {
15 | opacity: 1;
16 | -ms-transform-origin: 50% 50%;
17 | transform-origin: 50% 50%;
18 | -ms-transform: scale(1, 1);
19 | transform: scale(1, 1);
20 | -webkit-filter: blur(0px);
21 | filter: blur(0px);
22 | }
23 | 100% {
24 | opacity: 0;
25 | -ms-transform-origin: 50% 50%;
26 | transform-origin: 50% 50%;
27 | -ms-transform: scale(2, 2);
28 | transform: scale(2, 2);
29 | -webkit-filter: blur(3px);
30 | filter: blur(3px);
31 | }
32 | `,
33 | puffmein: keyframes`
34 | 0% {
35 | opacity: 0;
36 | -ms-transform-origin: 50% 50%;
37 | transform-origin: 50% 50%;
38 | -ms-transform: scale(2, 2);
39 | transform: scale(2, 2);
40 | -webkit-filter: blur(3px);
41 | filter: blur(3px);
42 | }
43 | 100% {
44 | opacity: 1;
45 | -ms-transform-origin: 50% 50%;
46 | transform-origin: 50% 50%;
47 | -ms-transform: scale(1, 1);
48 | transform: scale(1, 1);
49 | -webkit-filter: blur(0px);
50 | filter: blur(0px);
51 | }
52 | `,
53 | vanishout: keyframes`
54 | 0% {
55 | opacity: 1;
56 | -ms-transform-origin: 50% 50%;
57 | transform-origin: 50% 50%;
58 | -ms-transform: scale(1, 1);
59 | transform: scale(1, 1);
60 | -webkit-filter: blur(0px);
61 | filter: blur(0px);
62 | }
63 | 100% {
64 | opacity: 0;
65 | -ms-transform-origin: 50% 50%;
66 | transform-origin: 50% 50%;
67 | -ms-transform: scale(2, 2);
68 | transform: scale(2, 2);
69 | -webkit-filter: blur(18px);
70 | filter: blur(18px);
71 | }
72 | `,
73 | vanishin: keyframes`
74 | 0% {
75 | opacity: 0;
76 | -ms-transform-origin: 50% 50%;
77 | transform-origin: 50% 50%;
78 | -ms-transform: scale(2, 2);
79 | transform: scale(2, 2);
80 | -webkit-filter: blur(18px);
81 | filter: blur(18px);
82 | }
83 | 100% {
84 | opacity: 1;
85 | -ms-transform-origin: 50% 50%;
86 | transform-origin: 50% 50%;
87 | -ms-transform: scale(1, 1);
88 | transform: scale(1, 1);
89 | -webkit-filter: blur(0px);
90 | filter: blur(0px);
91 | }
92 | `,
93 | };
94 |
95 | const Bouncing: KeyframeObject = {
96 | bounce: keyframes`
97 | from {
98 | animation-timing-function: cubic-bezier(0.200, 0.620, 0.340, 1.000);
99 | }
100 | 0% {
101 | opacity: 0;
102 | transform: scale3d(.3, .3, .3);
103 | }
104 | 20% {
105 | transform: scale3d(1.1, 1.1, 1.1);
106 | }
107 | 40% {
108 | transform: scale3d(.9, .9, .9);
109 | }
110 | 60% {
111 | opacity: 1;
112 | transform: scale3d(1.1, 1.1, 1.1);
113 | }
114 | 80% {
115 | transform: scale3d(.97, .97, .97);
116 | }
117 | to {
118 | opacity: 1;
119 | transform: scale3d(1, 1, 1);
120 | }
121 | `,
122 | bounceDown: keyframes`
123 | from {
124 | animation-timing-function: cubic-bezier(0.200, 0.620, 0.340, 1.000);
125 | }
126 | 0% {
127 | transform: translate3d(0, -2000px, 0);
128 | }
129 | 60% {
130 | transform: translate3d(0, 25px, 0);
131 | }
132 | 75% {
133 | transform: translate3d(0, -15px, 0);
134 | }
135 | 90% {
136 | transform: translate3d(0, 5px, 0);
137 | }
138 | to {
139 | transform: translate3d(0, 0, 0);
140 | }
141 | `,
142 | bounceUp: keyframes`
143 | from {
144 | animation-timing-function: cubic-bezier(0.200, 0.620, 0.340, 1.000);
145 | }
146 | 0% {
147 | transform: translate3d(0, 2000px, 0);
148 | }
149 | 60% {
150 | transform: translate3d(0, -25px, 0);
151 | }
152 | 75% {
153 | transform: translate3d(0, 10px, 0);
154 | }
155 | 90% {
156 | transform: translate3d(0, -5px, 0);
157 | }
158 | to {
159 | transform: translate3d(0, 0, 0);
160 | }
161 | `,
162 | bounceLeft: keyframes`
163 | from, 60% 75% 90%, to {
164 | animation-timing-function: cubic-bezier(0.200, 0.620, 0.340, 1.000);
165 | }
166 | 0% {
167 | opacity: 0;
168 | transform: translate3d(-2000px, 0, 0);
169 | }
170 | 60% {
171 | opacity: 1;
172 | transform: translate3d(25px, 0, 0);
173 | }
174 | 75% {
175 | transform: translate3d(-10px, 0, 0);
176 | }
177 | 90% {
178 | transform: translate3d(5px, 0, 0);
179 | }
180 | to {
181 | transform: none;
182 | }
183 | `,
184 | bounceRight: keyframes`
185 | from, 60% 75% 90%, to {
186 | animation-timing-function: cubic-bezier(0.200, 0.620, 0.340, 1.000);
187 | }
188 | 0% {
189 | opacity: 0;
190 | transform: translate3d(2000px, 0, 0);
191 | }
192 | 60% {
193 | opacity: 1;
194 | transform: translate3d(-25px, 0, 0);
195 | }
196 | 75% {
197 | transform: translate3d(10px, 0, 0);
198 | }
199 | 90% {
200 | transform: translate3d(-5px, 0, 0);
201 | }
202 | to {
203 | transform: none;
204 | }
205 | `,
206 | };
207 |
208 | const Expanse: KeyframeObject = {
209 | expanseUp: keyframes`
210 | 0% {
211 | opacity: 0;
212 | -ms-transform-origin: 50% 0%;
213 | transform-origin: 50% 0%;
214 | -ms-transform: scale(.2) translate(0%, -200%);
215 | transform: scale(.2) translate(0%, -200%);
216 | }
217 | 100% {
218 | opacity: 1;
219 | -ms-transform-origin: 50% 0%;
220 | transform-origin: 50% 0%;
221 | -ms-transform: scale(1) translate(0%, 0%);
222 | transform: scale(1) translate(0%, 0%);
223 | }
224 | `,
225 | expanseDown: keyframes`
226 | 0% {
227 | opacity: 0;
228 | -ms-transform-origin: 50% 100%;
229 | transform-origin: 50% 100%;
230 | -ms-transform: scale(.2) translate(0%, 200%);
231 | transform: scale(.2) translate(0%, 200%);
232 | }
233 | 100% {
234 | opacity: 1;
235 | -ms-transform-origin: 50% 100%;
236 | transform-origin: 50% 100%;
237 | -ms-transform: scale(1) translate(0%, 0%);
238 | transform: scale(1) translate(0%, 0%);
239 | }
240 | `,
241 | expanseLeft: keyframes`
242 | 0% {
243 | opacity: 0;
244 | -ms-transform-origin: 0% 50%;
245 | transform-origin: 0% 50%;
246 | -ms-transform: scale(.2) translate(-200%, 0%);
247 | transform: scale(.2) translate(-200%, 0%);
248 | }
249 | 100% {
250 | opacity: 1;
251 | -ms-transform-origin: 0% 50%;
252 | transform-origin: 0% 50%;
253 | -ms-transform: scale(1) translate(0%, 0%);
254 | transform: scale(1) translate(0%, 0%);
255 | }
256 | `,
257 | expanseRight: keyframes`
258 | 0% {
259 | opacity: 0;
260 | -ms-transform-origin: 100% 50%;
261 | transform-origin: 100% 50%;
262 | -ms-transform: scale(.2) translate(200%, 0%);
263 | transform: scale(.2) translate(200%, 0%);
264 | }
265 | 100% {
266 | opacity: 1;
267 | -ms-transform-origin: 100% 50%;
268 | transform-origin: 100% 50%;
269 | -ms-transform: scale(1) translate(0%, 0%);
270 | transform: scale(1) translate(0%, 0%);
271 | }
272 | `,
273 | };
274 |
275 | const Fade: KeyframeObject = {
276 | fadeIn: keyframes`
277 | 0% {
278 | opacity: 0;
279 | }
280 | 100% {
281 | opacity: 1;
282 | }
283 | `,
284 | left: keyframes`
285 | from {
286 | opacity: 0;
287 | transform: translate3d(-100%, 0, 0);
288 | }
289 | to {
290 | opacity: 1;
291 | -ms-transform: none;
292 | transform: none;
293 | }
294 | `,
295 | leftBig: keyframes`
296 | from {
297 | opacity: 0;
298 | transform: translate3d(-2000px, 0, 0);
299 | }
300 | to {
301 | opacity: 1;
302 | -ms-transform: none;
303 | transform: none;
304 | }
305 | `,
306 | right: keyframes`
307 | from {
308 | opacity: 0;
309 | transform: translate3d(100%, 0, 0);
310 | }
311 | to {
312 | opacity: 1;
313 | -ms-transform: none;
314 | transform: none;
315 | }
316 | `,
317 | rightBig: keyframes`
318 | from {
319 | opacity: 0;
320 | transform: translate3d(2000px, 0, 0);
321 | }
322 | to {
323 | opacity: 1;
324 | -ms-transform: none;
325 | transform: none;
326 | }
327 | `,
328 | down: keyframes`
329 | from {
330 | opacity: 0;
331 | transform: translate3d(0, -100%, 0);
332 | }
333 | to {
334 | opacity: 1;
335 | -ms-transform: none;
336 | transform: none;
337 | }
338 | `,
339 | downBig: keyframes`
340 | from {
341 | opacity: 0;
342 | transform: translate3d(0, -2000px, 0);
343 | }
344 | to {
345 | opacity: 1;
346 | -ms-transform: none;
347 | transform: none;
348 | }
349 | `,
350 | up: keyframes`
351 | from {
352 | opacity: 0;
353 | transform: translate3d(0, 100%, 0);
354 | }
355 | to {
356 | opacity: 1;
357 | -ms-transform: none;
358 | transform: none;
359 | }
360 | `,
361 | upBig: keyframes`
362 | from {
363 | opacity: 0;
364 | transform: translate3d(0, 2000px, 0);
365 | }
366 | to {
367 | opacity: 1;
368 | -ms-transform: none;
369 | transform: none;
370 | }
371 | `,
372 | };
373 |
374 | const Flippy: KeyframeObject = {
375 | flip: keyframes`
376 | from {
377 | transform: perspective(450px) rotate3d(0, 1, 0, -360deg);
378 | animation-timing-function: ease-out;
379 | }
380 | 40% {
381 | transform: perspective(450px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -190deg);
382 | animation-timing-function: ease-out;
383 | }
384 | 50% {
385 | transform: perspective(450px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -170px);
386 | animation-timing-function: ease-in;
387 | }
388 | 80% {
389 | transform: perspective(450px) scale3d(.90, .90, .90);
390 | animation-timing-function: ease-in;
391 | }
392 | to {
393 | transform: perspective(450px);
394 | animation-timing-function: ease-in;
395 | }
396 | `,
397 | flipInX: keyframes`
398 | from {
399 | transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
400 | animation-timing-function: ease-in;
401 | opacity: 0;
402 | }
403 | 40% {
404 | transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
405 | animation-timing-function: ease-in;
406 | }
407 | 60% {
408 | transform: perspective(400px) rotate3d(1, 0, 0, 10deg);
409 | opacity: 1;
410 | }
411 | 80% {
412 | transform: perspective(400px) rotate3d(1, 0, 0, -5deg);
413 | }
414 | to {
415 | transform: perspective(400px);
416 | }
417 | `,
418 | flipInY: keyframes`
419 | from {
420 | transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
421 | animation-timing-function: ease-in;
422 | opacity: 0;
423 | }
424 | 40% {
425 | transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
426 | animation-timing-function: ease-in;
427 | }
428 | 60% {
429 | transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
430 | opacity: 1;
431 | }
432 | 80% {
433 | transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
434 | }
435 | to {
436 | transform: perspective(400px);
437 | }
438 | `,
439 | flipOutX: keyframes`
440 | from {
441 | transform: perspective(400px);
442 | }
443 | 40% {
444 | transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
445 | animation-timing-function: ease-in;
446 | }
447 | 60% {
448 | transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
449 | opacity: 1;
450 | }
451 | 80% {
452 | transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
453 | }
454 | to {
455 | transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
456 | animation-timing-function: ease-in;
457 | opacity: 0;
458 | }
459 | `,
460 | flipOutY: keyframes`
461 | from {
462 | transform: perspective(400px);
463 | }
464 | 40% {
465 | transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
466 | animation-timing-function: ease-in;
467 | }
468 | 60% {
469 | transform: perspective(400px) rotate3d(0, 1, 0, 2-deg);
470 | opacity: 1;
471 | }
472 | 80% {
473 | transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
474 | }
475 | to {
476 | transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
477 | animation-timing-function: ease-in;
478 | opacity: 0;
479 | }
480 | `,
481 | };
482 |
483 | const Light: KeyframeObject = {
484 | lightIn: keyframes`
485 | from {
486 | transform: translate3d(100%, 0, 0) skew(-30deg);
487 | opacity: 0;
488 | }
489 | 40% {
490 | -ms-transform: skew(20deg);
491 | transform: skew(20deg);
492 | opacity: 1;
493 | }
494 | 80% {
495 | -ms-transform: skew(-5deg);
496 | transform: skew(-5deg);
497 | opacity: 1;
498 | }
499 | to {
500 | -ms-transform: none;
501 | transform: none;
502 | opacity: 1;
503 | }
504 | `,
505 | lightOut: keyframes`
506 | from {
507 | opacity: 1;
508 | }
509 | to {
510 | transform: translate3d(100%, 0, 0) skew(30deg);
511 | opacity: 0;
512 | }
513 | `,
514 | };
515 |
516 | const Perspective: KeyframeObject = {
517 | perspectiveDown: keyframes`
518 | 0% {
519 | -ms-transform-origin: 0 100%;
520 | transform-origin: 0 100%;
521 | transform: perspective(800px) rotateX(0deg);
522 | }
523 | 100% {
524 | -ms-transform-origin: 0 100%;
525 | transform-origin: 0 100%;
526 | transform: perspective(800px) rotateX(-180deg);
527 | }
528 | `,
529 | perspectiveUp: keyframes`
530 | 0% {
531 | -ms-transform-origin: 0 0;
532 | transform-origin: 0 0;
533 | transform: perspective(800px) rotateX(0deg);
534 | }
535 | 100% {
536 | -ms-transform-origin: 0 0;
537 | transform-origin: 0 0;
538 | transform: perspective(800px) rotateX(180deg);
539 | }
540 | `,
541 | perspectiveRight: keyframes`
542 | 0% {
543 | -ms-transform-origin: 100% 0;
544 | transform-origin: 100% 0;
545 | transform: perspective(800px) rotateY(0deg);
546 | }
547 | 100% {
548 | -ms-transform-origin: 100% 0;
549 | transform-origin: 100% 0;
550 | transform: perspective(800px) rotateY(180deg);
551 | }
552 | `,
553 | perspectiveLeft: keyframes`
554 | 0% {
555 | -ms-transform-origin: 0 0;
556 | transform-origin: 0 0;
557 | transform: perspective(800px) rotateY(0deg);
558 | }
559 | 100% {
560 | -ms-transform-origin: 0 0;
561 | transform-origin: 0 0;
562 | transform: perspective(800px) rotateY(-180deg);
563 | }
564 | `,
565 | };
566 |
567 | const Rotate: KeyframeObject = {
568 | rotateIn: keyframes`
569 | from {
570 | -ms-transform-origin: center;
571 | transform-origin: center;
572 | transform: rotate3d(0, 0, 1, -200deg);
573 | opacity: 0;
574 | }
575 | to {
576 | -ms-transform: none;
577 | transform: none;
578 | opacity: 1;
579 | }
580 | `,
581 | rotateLeft: keyframes`
582 | from {
583 | -ms-transform-origin: left bottom;
584 | transform-origin: left bottom;
585 | transform: rotate3d(0, 0, 1, -45deg);
586 | opacity: 0;
587 | }
588 | to {
589 | -ms-transform-origin: left bottom;
590 | transform-origin: left bottom;
591 | -ms-transform: none;
592 | transform: none;
593 | opacity: 1;
594 | }
595 | `,
596 | rotateRight: keyframes`
597 | from {
598 | -ms-transform-origin: right bottom;
599 | transform-origin: right bottom;
600 | transform: rotate3d(0, 0, 1, 45deg);
601 | opacity: 0;
602 | }
603 | to {
604 | -ms-transform-origin: right bottom;
605 | transform-origin: right bottom;
606 | -ms-transform: none;
607 | transform: none;
608 | opacity: 1;
609 | }
610 | `,
611 | rotateUpRight: keyframes`
612 | from {
613 | -ms-transform-origin: right bottom;
614 | transform-origin: right bottom;
615 | transform: rotate3d(0, 0, 1, -45deg);
616 | opacity: 0;
617 | }
618 | to {
619 | -ms-transform-origin: right bottom;
620 | transform-origin: right bottom;
621 | -ms-transform: none;
622 | transform: none;
623 | opacity: 1;
624 | }
625 | `,
626 | rotateUpLeft: keyframes`
627 | from {
628 | -ms-transform-origin: left bottom;
629 | transform-origin: left bottom;
630 | transform: rotate3d(0, 0, 1, 45deg);
631 | opacity: 0;
632 | }
633 | to {
634 | -ms-transform-origin: left bottom;
635 | transform-origin: left bottom;
636 | -ms-transform: none;
637 | transform: none;
638 | opacity: 1;
639 | }
640 | `,
641 | };
642 |
643 | const Slide: KeyframeObject = {
644 | slideDown: keyframes`
645 | from {
646 | transform: translate3d(0, -100%, 0);
647 | }
648 | to {
649 | transform: translate3d(0, 0, 0);
650 | }
651 | `,
652 |
653 | slideUp: keyframes`
654 | from {
655 | transform: translate3d(0, 100%, 0);
656 | }
657 | to {
658 | transform: translate3d(0, 0, 0);
659 | }
660 | `,
661 |
662 | slideLeft: keyframes`
663 | from {
664 | transform: translate3d(-100%, 0, 0);
665 | }
666 | to {
667 | transform: translate3d(0, 0, 0);
668 | }
669 | `,
670 |
671 | slideRight: keyframes`
672 | from {
673 | transform: translate3d(100%, 0, 0);
674 | }
675 | to {
676 | transform: translate3d(0, 0, 0);
677 | }
678 | `,
679 | };
680 |
681 | const Special: KeyframeObject = {
682 | flash: keyframes`
683 | from {
684 | opacity: 1;
685 | }
686 | 25% {
687 | opacity: 0;
688 | }
689 | 50% {
690 | opacity: 1;
691 | }
692 | 75% {
693 | opacity: 0;
694 | }
695 | to {
696 | opacity: 1;
697 | }
698 | `,
699 | rollIn: keyframes`
700 | from {
701 | transform: translate3d(-100%, 0, 0) rotate3d(0, 0, 1, -120deg);
702 | opacity: 0;
703 | }
704 | to {
705 | -ms-transform: none;
706 | transform: none;
707 | opacity: 1;
708 | }
709 | `,
710 | rollOut: keyframes`
711 | from {
712 | opacity: 1;
713 | }
714 | to {
715 | transform: translate3d(100%, 0, 0) rotate3d(0, 0, 1, 120deg);
716 | opacity: 0;
717 | }
718 | `,
719 | rubber: keyframes`
720 | from {
721 | transform: scale3d(1, 1, 1);
722 | }
723 | 30% {
724 | transform: scale3d(1.25, 0.75, 1);
725 | }
726 | 40% {
727 | transform: scale3d(0.75, 1.25, 1);
728 | }
729 | 50% {
730 | transform: scale3d(1.15, 0.85, 1);
731 | }
732 | 65% {
733 | transform: scale3d(.95, 1.05, 1);
734 | }
735 | 75% {
736 | transform: scale3d(1.05, .95, 1);
737 | }
738 | to {
739 | transform: scale3d(1, 1, 1);
740 | }
741 | `,
742 | swing: keyframes`
743 | 20% {
744 | transform: rotate3d(0, 0, 1, 15deg);
745 | }
746 | 40% {
747 | transform: rotate3d(0, 0, 1, -10deg);
748 | }
749 | 60% {
750 | transform: rotate3d(0, 0, 1, 5deg);
751 | }
752 | 80% {
753 | transform: rotate3d(0, 0, 1, -5deg);
754 | }
755 | to {
756 | transform: rotate3d(0, 0, 1, 0deg);
757 | }
758 | `,
759 | zoom: keyframes`
760 | from {
761 | opacity: 0;
762 | transform: scale3d(.4, .4, .4);
763 | }
764 | to {
765 | opacity: 1;
766 | }
767 | `,
768 | hinge: keyframes`
769 | from {
770 | -ms-transform-origin: top-left;
771 | transform-origin: top-left;
772 | animation-timing-function: ease-in-out;
773 | opacity: 1;
774 | }
775 | 20%, 40% {
776 | -ms-transform-origin: top-left;
777 | transform-origin: top-left;
778 | -ms-transform: rotate(0, 0, 1, 80deg);
779 | transform: rotate(0, 0, 1, 80deg);
780 | animation-timing-function: ease-in-out;
781 | opacity: 1;
782 | }
783 | 60%, 80% {
784 | -ms-transform-origin: top-left;
785 | transform-origin: top-left;
786 | -ms-transform: rotate(0, 0, 1, 20deg);
787 | transform: rotate(0, 0, 1, 20deg);
788 | animation-timing-function: ease-in-out;
789 | opacity: 1;
790 | }
791 | to {
792 | transform: translate3d(0, 700px, 0);
793 | opacity: 0;
794 | }
795 | `,
796 | hingeDrop: keyframes`
797 | from {
798 | -ms-transform-origin: top-left;
799 | transform-origin: top left;
800 | animation-timing-function: ease-in-out;
801 | opacity: 1;
802 | }
803 |
804 | 20%, 60% {
805 | -ms-transform: rotate(0, 0, 1, 80deg);
806 | transform: rotate3d(0, 0, 1, 80deg);
807 | -ms-transform-origin: top-left;
808 | transform-origin: top left;
809 | animation-timing-function: ease-in-out;
810 | }
811 |
812 | 40%, 80% {
813 | -ms-transform: rotate(0, 0, 1, 60deg);
814 | transform: rotate3d(0, 0, 1, 60deg);
815 | -ms-transform-origin: top-left;
816 | transform-origin: top left;
817 | animation-timing-function: ease-in-out;
818 | opacity: 1;
819 | }
820 |
821 | to {
822 | transform: translate3d(0, 700px, 0);
823 | opacity: 0;
824 | }
825 | `,
826 | pulse: keyframes`
827 | from {
828 | transform: scale3d(1, 1, 1);
829 | }
830 | 50% {
831 | transform: scale3d(1.4, 1.4, 1.4);
832 | }
833 | to {
834 | transform: scale3d(1, 1, 1);
835 | }
836 | `,
837 | expandUp: keyframes`
838 | 0% {
839 | transform: translateY(100%) scale(0.6) scaleY(0.5);
840 | }
841 | 60%{
842 | transform: translateY(-7%) scaleY(1.12);
843 | }
844 | 75%{
845 | transform: translateY(3%);
846 | }
847 | 100% {
848 | transform: translateY(0%) scale(1) scaleY(1);
849 | }
850 | `,
851 | entrance: keyframes`
852 | 0% {
853 | transform: scale(0.3) rotate(6deg) translateX(-30%) translateY(30%);
854 | opacity: 0.1;
855 | }
856 | 30% {
857 | transform: scale(1.03) rotate(-2deg) translateX(2%) translateY(-2%);
858 | opacity: 1;
859 | }
860 | 45% {
861 | transform: scale(0.98);
862 | opacity: 1;
863 | }
864 | 60% {
865 | transform: scale(1.01);
866 | opacity: 1;
867 | }
868 | 75% {
869 | transform: scale(0.99);
870 | opacity: 1;
871 | }
872 | 90% {
873 | transform: scale(1.01);
874 | opacity: 1;
875 | }
876 | 100% {
877 | transform: scale(1);
878 | opacity: 1;
879 | }
880 | `,
881 | hatch: keyframes`
882 | 0% {
883 | transform: scaleY(0.6);
884 | }
885 | 20% {
886 | transform: rotate(-2deg) scaleY(1.05);
887 | }
888 | 35% {
889 | transform: rotate(2deg) scaleY(1);
890 | }
891 | 50% {
892 | transform: rotate(-2deg);
893 | }
894 | 65% {
895 | transform: rotate(1deg);
896 | }
897 | 80% {
898 | transform: rotate(-1deg);
899 | }
900 | 100% {
901 | transform: none;
902 | }
903 | `,
904 | starWars: keyframes`
905 | 0% {
906 | opacity: 0;
907 | transform: scale(1.5) translateY(-0.75em);
908 | }
909 | 20% {
910 | opacity: 1;
911 | }
912 | 90% {
913 | opacity: 1;
914 | transform: scale(1);
915 | }
916 | 100% {
917 | opacity: 0;
918 | transform: translateZ(-1000em);
919 | }
920 | `,
921 | };
922 |
923 | export {
924 | Bouncing,
925 | Fade,
926 | Flippy,
927 | Light,
928 | Rotate,
929 | Special,
930 | Slide,
931 | Perspective,
932 | Bingo,
933 | Expanse,
934 | }
935 |
--------------------------------------------------------------------------------
/packages/element-utils/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "development": {
4 | "presets": ["flow", "es2015", "react"]
5 | },
6 | "production": {
7 | "presets": ["babili", "flow", "es2015", "react"]
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/element-utils/.flowconfig:
--------------------------------------------------------------------------------
1 | [include]
2 | ./getElement.js
3 | ./Render.js
4 |
5 | [ignore]
6 | .*/node_modules/
7 |
--------------------------------------------------------------------------------
/packages/element-utils/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | /node_modules
3 | dist
4 |
5 | # misc
6 | .DS_Store
7 | .env
8 | npm-debug.log*
9 | lerna-debug.log
10 | yarn.lock
11 | yarn-error.log
12 |
--------------------------------------------------------------------------------
/packages/element-utils/README.md:
--------------------------------------------------------------------------------
1 | # element-utils
2 |
3 | This package contains utility functions for [`animate-components`](../animate-components).
4 |
5 | * **getElementType** - Get the element type from the prop passed to animation component.
6 | * **avoidNesting** - Avoid DOM nesting of same elements.
7 | * **Render** - Render the components with some helpers.
8 |
--------------------------------------------------------------------------------
/packages/element-utils/__tests__/mods.test.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from "react";
2 | import { getElementType, avoidNest } from "../src/getElement";
3 | import Render from "../src/Render";
4 |
5 | class App extends Component {
6 | render() {
7 | return (
8 |
9 |
Hello
10 |
11 | );
12 | }
13 | }
14 |
15 | App.defaultProps = {
16 | as: "div"
17 | };
18 |
19 | class NotDefault extends Component {
20 | render() {
21 | return (
22 |
23 |
Hello
24 |
25 | );
26 | }
27 | }
28 |
29 | describe("avoidNest", () => {
30 | it("should be a function", () => {
31 | expect(typeof avoidNest).toBe("function");
32 | });
33 |
34 | it("return elementType prop if child type and prop 'as' are same. ", () => {
35 | const child = { type: "h1" };
36 |
37 | const elementType = "div";
38 |
39 | expect(avoidNest(elementType, child, App)).toBe("div");
40 | });
41 |
42 | it("return elementType prop if no child passed", () => {
43 | const elementType = "div";
44 |
45 | expect(avoidNest(elementType, "", App)).toBe("div");
46 | });
47 |
48 | it("return elementType prop if its type is 'div'", () => {
49 | const child = {
50 | type: "div"
51 | };
52 |
53 | const elementType = "div";
54 |
55 | expect(avoidNest(elementType, child, App)).toBe("div");
56 | });
57 | });
58 |
59 | describe("getElementType", () => {
60 | it("should be a function", () => {
61 | expect(typeof getElementType).toBe("function");
62 | });
63 |
64 | it("return default elementType if (as === default.as)", () => {
65 | const props = {
66 | as: "div"
67 | };
68 |
69 | expect(getElementType(App, props)).toBe("div");
70 | });
71 |
72 | it("return prop 'as' if (as !== default.as) ", () => {
73 | const props = {
74 | as: "h1"
75 | };
76 |
77 | expect(getElementType(App, props)).toBe("h1");
78 | });
79 |
80 | it("returns prop 'as' if no default prop", () => {
81 | const props = {
82 | as: "h2"
83 | };
84 |
85 | expect(getElementType(NotDefault, props)).toBe("h2");
86 | });
87 |
88 | it("return div if no default and as prop", () => {
89 | const props = {
90 | as: ""
91 | };
92 |
93 | expect(getElementType(NotDefault, props)).toBe("div");
94 | });
95 | });
96 |
97 | describe("Render Function - Returns an element type and renders the component with the styles and other html attributes", () => {
98 | let props = {
99 | as: "div",
100 | children: {
101 | type: "p",
102 | props: {
103 | children: "Hello"
104 | }
105 | }
106 | };
107 |
108 | let state = {
109 | styles: {
110 | animation: "fadeIn 3s"
111 | }
112 | };
113 |
114 | let rest = {
115 | className: "main"
116 | };
117 |
118 | let output = Render(App, props, state, rest);
119 |
120 | it("should be a function", () => {
121 | expect(typeof Render).toBe("function");
122 | });
123 |
124 | it("should return an element type", () => {
125 | expect(output.type).toBe("div");
126 | });
127 |
128 | it("should render the children (when component is not passed explicitly through prop)", () => {
129 | expect(output.props.children).toEqual({
130 | props: { children: "Hello" },
131 | type: "p"
132 | });
133 | });
134 |
135 | it("should render the component when passed through component prop", () => {
136 | props.component = NotDefault;
137 | props.children = {};
138 | output = Render(App, props, state, rest);
139 | expect(typeof output.props.children.type).toBe("function");
140 | });
141 |
142 | describe("attributes", () => {
143 | it("should include the styles and animation", () => {
144 | expect(output.props.style).toEqual({ animation: "fadeIn 3s" });
145 | });
146 |
147 | it("should include the html attributes", () => {
148 | expect(output.props.className).toBe("main");
149 | });
150 | });
151 | });
152 |
--------------------------------------------------------------------------------
/packages/element-utils/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "element-utils",
3 | "version": "0.1.2",
4 | "description": "Utility functions for React elements",
5 | "main": "./dist/index.js",
6 | "repository": "https://github.com/nitin42/animate-components/",
7 | "author": "Nitin Tulswani",
8 | "license": "MIT",
9 | "scripts": {
10 | "flow": "./node_modules/.bin/flow",
11 | "prebuild": "rm -rf ./dist",
12 | "build": "NODE_ENV=production ./node_modules/.bin/babel src -d dist",
13 | "test": "NODE_ENV=development ./node_modules/.bin/jest",
14 | "test:watch": "NODE_ENV=development ./node_modules/.bin/jest --watch",
15 | "prepublishOnly": "yarn flow && yarn test && yarn build"
16 | },
17 | "files": [
18 | "dist"
19 | ],
20 | "devDependencies": {
21 | "babel-cli": "^6.24.1",
22 | "babel-plugin-transform-flow-strip-types": "^6.22.0",
23 | "babel-preset-babili": "^0.1.4",
24 | "babel-preset-es2015": "^6.24.1",
25 | "babel-preset-flow": "^6.23.0",
26 | "babel-preset-react": "^6.24.1",
27 | "flow-bin": "^0.48.0",
28 | "jest": "^20.0.4"
29 | },
30 | "dependencies": {
31 | "react": "^16.0.0"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/element-utils/src/Render.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import React from "react";
4 | import { avoidNest, getElementType } from "./getElement";
5 |
6 | const Render = (
7 | ComposedComponent: any,
8 | props: Object,
9 | state: Object,
10 | rest: any,
11 | DisplayName: any
12 | ): ?React$Element => {
13 | const ElementType = getElementType(ComposedComponent, props);
14 | const { styles } = state;
15 | const Wrapper = props.component;
16 | const NormalizedComponent =
17 | avoidNest(ElementType, props, DisplayName) || "div";
18 |
19 | return (
20 |
21 | {Wrapper ? React.createElement(Wrapper, props.children) : props.children}
22 |
23 | );
24 | };
25 |
26 | export default Render;
27 |
--------------------------------------------------------------------------------
/packages/element-utils/src/getElement.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | // Component name passed as string in HOC and React class in merge
4 | const avoidNest = (
5 | elementAs: string,
6 | props: Object,
7 | DisplayName: any
8 | ): string => {
9 | let elementType = elementAs;
10 | if (!props.children) return elementType;
11 |
12 | if (elementType === "div") return elementType; // Wrap with div (default)
13 |
14 | const { type } = props.children;
15 | if (type === elementType) {
16 | elementType = "div"; // Wrap with div and don't mutate the children element type.
17 | console.warn(
18 | `'${DisplayName}' component rendered with an element type 'div' (DOM nesting validated). You provided an element type '${props.as}' to the prop 'as' which was similar to the children type '${type}'. More info - https://goo.gl/wsXFiF`
19 | );
20 | return elementType;
21 | }
22 |
23 | return elementType;
24 | };
25 |
26 | const getElementType = (Component: any, props: Object): string => {
27 | const { defaultProps = {} } = Component;
28 | if (props.as && props.as !== defaultProps.as) return props.as;
29 |
30 | return defaultProps.as || "div";
31 | };
32 |
33 | export { avoidNest, getElementType };
34 |
--------------------------------------------------------------------------------
/packages/element-utils/src/index.js:
--------------------------------------------------------------------------------
1 | import { avoidNest, getElementType } from './getElement';
2 | import Render from './Render';
3 |
4 | export {
5 | avoidNest,
6 | getElementType,
7 | Render,
8 | }
9 |
--------------------------------------------------------------------------------
/scripts/check.js:
--------------------------------------------------------------------------------
1 | const shell = require('shelljs');
2 | const clearConsole = require('react-dev-utils/clearConsole');
3 | const chalk = require('chalk');
4 |
5 | const tty_mode = process.stdout.isTTY;
6 |
7 | let log = (arg) => console.log(arg);
8 |
9 | let build = () => {
10 | log(chalk.green("\nBuilding the project..."));
11 | shell.exec('yarn build >&-', (code, stderr) => {
12 | if (code !== 0) {
13 | log(chalk.red("\n⚠️ Build failed."));
14 | } else log(chalk.yellow("\n✅ Build completed."))
15 | lint();
16 | });
17 | }
18 |
19 | let lint = () => {
20 | log(chalk.green("\nRunning ESLint plugin..."));
21 | shell.exec('yarn lint >&-', (code) => {
22 | if (code !== 0) {
23 | log(chalk.red("\n⚠️ There were some errors. Run `yarn lint` to check the errors.\n"));
24 | } else log(chalk.yellow("\n✅ No errors.\n"))
25 | });
26 | }
27 |
28 | let main = () => {
29 | if (tty_mode) {
30 | clearConsole();
31 | }
32 | build();
33 | }
34 |
35 | main();
36 |
--------------------------------------------------------------------------------
/starter/App.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import glamorous from 'glamorous-native';
3 | import reactPrimitives from 'react-primitives';
4 |
5 | function createNative(componentConstructor, tag) {
6 | if (typeof tag !== 'string' && typeof tag !== 'function') {
7 | throw new Error(`Cannot create glamorous component for ${tag}`);
8 | }
9 |
10 | return componentConstructor(tag);
11 | }
12 |
13 | const composer = (tag) => createNative(glamorous, tag)
14 |
15 | const NativeAlias = composer(reactPrimitives['View']);
16 |
17 | const StyledView = NativeAlias({ color: 'red', fontSize: '1.3em' });
18 |
19 | class App extends Component {
20 | render() {
21 | return (
22 |
23 | Hello
24 |
25 | );
26 | }
27 | }
28 |
29 | export default App;
30 |
--------------------------------------------------------------------------------
/starter/comp.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 |
3 | export default class Comp extends Component {
4 | render () {
5 | return (
6 | Hello World
7 | )
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/starter/index.css:
--------------------------------------------------------------------------------
1 | .main {
2 | color: violet;
3 | }
4 |
--------------------------------------------------------------------------------
/starter/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render } from 'react-dom';
3 |
4 | import App from './App';
5 |
6 | render( , document.getElementById('app'));
7 |
--------------------------------------------------------------------------------
/starter/webpack.config.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 | const { join, resolve } = require("path");
3 | const HtmlWebpackPlugin = require("html-webpack-plugin");
4 |
5 | const VENDOR = ["react", "react-dom", 'inferno', 'inferno-component'];
6 |
7 | module.exports = {
8 | entry: {
9 | main: [
10 | "webpack-dev-server/client?http://0.0.0.0:8080",
11 | "webpack/hot/only-dev-server",
12 | join(__dirname, "index.js")
13 | ],
14 | vendor: VENDOR
15 | },
16 | output: {
17 | filename: "[name].js",
18 | path: resolve(__dirname, "build"),
19 | publicPath: "/"
20 | },
21 | devServer: {
22 | publicPath: "/",
23 | noInfo: true,
24 | historyApiFallback: true
25 | },
26 | stats: {
27 | chunks: true,
28 | chunkModules: true,
29 | colors: true,
30 | errors: true,
31 | errorDetails: true,
32 | timings: true,
33 | version: true,
34 | warnings: true
35 | },
36 | devtool: "eval",
37 | module: {
38 | rules: [
39 | {
40 | test: /\.js$/,
41 | exclude: [/node_modules/, /__tests__/, /docs/, /coverage/],
42 | use: ["babel-loader"]
43 | },
44 | {
45 | test: /\.css$/,
46 | use: ["style-loader", "css-loader"]
47 | }
48 | ]
49 | },
50 | plugins: [
51 | new webpack.HotModuleReplacementPlugin(),
52 | new webpack.NamedModulesPlugin(),
53 | new HtmlWebpackPlugin({
54 | template: require("html-webpack-template"),
55 | appMountId: "app"
56 | }),
57 | new webpack.optimize.UglifyJsPlugin(),
58 | new webpack.optimize.CommonsChunkPlugin({
59 | name: "vendor"
60 | })
61 | ]
62 | };
63 |
--------------------------------------------------------------------------------
/tasks.md:
--------------------------------------------------------------------------------
1 | # Tasks
2 |
3 | - [x] Reduce build size
4 | - [x] UMD build
5 | - [x] Webpack build
6 | - [x] component prop
7 | - [x] Delay rendering of components along with the animation because it seems weird when component
8 | has been rendered by React but animations are delayed. This will keep both in sync and will be
9 | processed through the timeout prop (type: Number). Though this won't be replacing the delay
10 | attribute of an animation but its an addon for existing library.
11 | - [x] Code refactor
12 | - [ ] Component Transitioning
13 | - [x] Misc Components like perform animation and then disapper (Node removal from DOM instead of hiding using component state which is imperative).
14 | - [ ] More animations
15 | - [ ] Integration
16 |
--------------------------------------------------------------------------------
/typings/animate-components.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | type Delay$Component$Props = {
4 | timeout: number,
5 | children?: React$Element
6 | };
7 |
8 | type Delay$Component$State = {
9 | show: boolean
10 | };
11 |
12 | type Merge$Component$Props = {
13 | one: Object,
14 | two: Object,
15 | as: string,
16 | style?: Object,
17 | component?: Function,
18 | children?: React$Element
19 | };
20 |
21 | type Merge$Component$State = {
22 | styles: Object
23 | };
24 |
25 | type Disappear$Component$Props = {
26 | name: string,
27 | duration: string,
28 | as: string,
29 | timingFunction: string,
30 | component?: Function,
31 | children?: React$Element,
32 | rest?: any
33 | };
34 |
35 | type High$Order$Component$Props = {
36 | duration: string,
37 | timingFunction: string,
38 | delay: string,
39 | direction: string,
40 | iterations: string,
41 | backfaceVisible: string,
42 | fillMode: string,
43 | playState: string,
44 | as: string,
45 | component?: Function,
46 | children?: React$Element,
47 | forceInterpolate?: Object,
48 | style?: Object
49 | };
50 |
51 | type High$Order$Component$State = {
52 | styles: Object
53 | };
54 |
55 | class HighOrderComponent extends React$Component {
56 | props: High$Order$Component$Props;
57 | state: High$Order$Component$State;
58 | setAnimation: (Props: High$Order$Component$Props) => void;
59 | }
60 |
61 | class Disappear$Component extends React$Component {
62 | props: Disappear$Component$Props;
63 | performAndDisapper: (prop: Disappear$Component$Props) => void;
64 | }
65 |
66 | class Merge$Component extends React$Component {
67 | props: Merge$Component$Props;
68 | state: Merge$Component$State;
69 | }
70 |
71 | class Delay$Component extends React$Component {
72 | props: Delay$Component$Props;
73 | state: Delay$Component$State;
74 | setShowValue: () => void;
75 | }
76 |
77 | declare module "animate-components" {
78 | declare type High$Order$Component = typeof HighOrderComponent;
79 |
80 | declare module.exports: {
81 | Bounce: High$Order$Component,
82 | BounceUp: High$Order$Component,
83 | BounceRight: High$Order$Component,
84 | BounceLeft: High$Order$Component,
85 | BounceDown: High$Order$Component,
86 | FadeIn: High$Order$Component,
87 | FadeInUp: High$Order$Component,
88 | FadeInRight: High$Order$Component,
89 | FadeInLeft: High$Order$Component,
90 | FadeInDown: High$Order$Component,
91 | FadeInUpBig: High$Order$Component,
92 | FadeInLeftBig: High$Order$Component,
93 | FadeInRightBig: High$Order$Component,
94 | Flip: High$Order$Component,
95 | FlipX: High$Order$Component,
96 | FlipY: High$Order$Component,
97 | LightOut: High$Order$Component,
98 | LightIn: High$Order$Component,
99 | RotateIn: High$Order$Component,
100 | RotateRight: High$Order$Component,
101 | RotateLeft: High$Order$Component,
102 | RotateUpRight: High$Order$Component,
103 | RotateUpLeft: High$Order$Component,
104 | Flash: High$Order$Component,
105 | RollOut: High$Order$Component,
106 | RollIn: High$Order$Component,
107 | Rubber: High$Order$Component,
108 | Swing: High$Order$Component,
109 | Zoom: High$Order$Component,
110 | Hinge: High$Order$Component,
111 | Pulse: High$Order$Component,
112 | SlideUp: High$Order$Component,
113 | SlideDown: High$Order$Component,
114 | SlideLeft: High$Order$Component,
115 | SlideRight: High$Order$Component,
116 | StarWars: High$Order$Component,
117 | ExpandUp: High$Order$Component,
118 | Entrance: High$Order$Component,
119 | Hatch: High$Order$Component,
120 | PDown: High$Order$Component,
121 | PUp: High$Order$Component,
122 | PRight: High$Order$Component,
123 | PLeft: High$Order$Component,
124 | PuffIn: High$Order$Component,
125 | PuffOut: High$Order$Component,
126 | VanishIn: High$Order$Component,
127 | VanishOut: High$Order$Component,
128 | ExpanseLeft: High$Order$Component,
129 | ExpanseRight: High$Order$Component,
130 | ExpanseDown: High$Order$Component,
131 | ExpanseUp: High$Order$Component,
132 | Merge: typeof Merge$Component,
133 | Delay: typeof Delay$Component,
134 | Disappear: typeof Disappear$Component,
135 | hoc: High$Order$Component
136 | };
137 | }
138 |
--------------------------------------------------------------------------------