Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit 0548ad3

Browse files
author
Brandon Dail
committed
Add flowtype
1 parent 241a596 commit 0548ad3

File tree

8 files changed

+49
-20
lines changed

8 files changed

+49
-20
lines changed

.flowconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[ignore]
2+
<PROJECT_ROOT>/demo/.*
3+
<PROJECT_ROOT>/lib/.*
4+
<PROJECT_ROOT>/dist/.*
5+
<PROJECT_ROOT>/node_modules/.*
6+
7+
8+
[include]
9+
10+
[libs]
11+
12+
[options]

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "animation library for Radium",
55
"main": "index.js",
66
"scripts": {
7+
"flow": "flow",
78
"test": "jest"
89
},
910
"keywords": [
@@ -14,12 +15,11 @@
1415
],
1516
"author": "Brandon Dail <[email protected]>",
1617
"license": "MIT",
17-
"peerDependencies": {
18-
"radium": "^0.18.1"
19-
},
2018
"devDependencies": {
2119
"builder": "^3.0.0",
22-
"builder-radium-component-dev": "^2.1.2"
20+
"builder-radium-component-dev": "^2.1.2",
21+
"flow-bin": "^0.32.0",
22+
"radium": "^0.18.1"
2323
},
2424
"dependencies": {
2525
"builder-radium-component": "^2.1.2",

src/components/bounce.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import Radium from 'radium';
1+
// @flow
22
import { translate3d, cubicBezier } from '../utils';
3+
import type { Animation, Keyframe } from '../types';
34

4-
const base = {
5+
const base: Keyframe = {
56
animationTimingFunction: cubicBezier(
67
0.2125,
78
0.610,
@@ -11,7 +12,7 @@ const base = {
1112
transform: translate3d(0, 0, 0),
1213
}
1314

14-
const bounce = {
15+
const bounce: Animation = {
1516
'0%': base,
1617
'20%': base,
1718
'40%': {

src/components/flash.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
const visible = {
1+
import type { Keyframe, Animation } from '../types';
2+
3+
const visible: Keyframe = {
24
opacity: 1,
35
};
46

5-
const invisible = {
7+
const invisible: Keyframe = {
68
opacity: 0,
79
};
810

9-
const flash = {
11+
const flash: Animation = {
1012
from: visible,
1113
'25%': invisible,
1214
'50%': visible,

src/components/jello.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { skewXY } from '../utils';
2+
import type { Keyframe, Animation } from '../types';
23

3-
const noSkew = {
4+
const noSkew: Keyframe = {
45
transform: 'none',
56
};
67

7-
const jello = {
8+
const jello: Animation = {
89
from: noSkew,
910
'11.1%': noSkew,
1011
'22.2%': {

src/components/pulse.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { scale3d } from '../utils';
2+
import type { Animation } from '../types';
23

3-
const pulse = {
4+
const pulse: Animation = {
45
from: {
56
transform: scale3d(1, 1, 1),
67
},

src/types.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @flow
2+
export type Keyframe = {
3+
[property: string]: string | number,
4+
}
5+
6+
export type Animation = {
7+
[keyframe: string]: Keyframe,
8+
}

src/utils.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
// @flow
22

3-
export const cubicBezier = (a, b, c, d) =>
4-
`cubic-bezier(${a}, ${b}, ${c}, ${d})`;
3+
export const cubicBezier = (
4+
a: number,
5+
b: number,
6+
c: number,
7+
d: number
8+
): string => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
59

6-
export const translate3d = (a, b, c ) =>
10+
export const translate3d = (a: number, b: number, c: number): string =>
711
`translate3d(${a}px, ${b}px, ${c}px)`;
812

9-
export const scale3d = (a, b, c) =>
13+
export const scale3d = (a: number, b: number, c: number): string =>
1014
`scale3d(${a}, ${b}, ${c})`;
1115

12-
export const skewX = (deg) =>
16+
export const skewX = (deg: number): string =>
1317
`skewX(${deg}deg)`;
1418

15-
export const skewY = (deg) =>
19+
export const skewY = (deg: number): string =>
1620
`skewY(${deg}deg)`;
1721

18-
export const skewXY = (x, y) =>
22+
export const skewXY = (x: number, y: number): string =>
1923
`${skewX(x)} ${skewY(y)}`;

0 commit comments

Comments
 (0)