Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bf04aef
adding prettier
mattgperry Nov 16, 2018
9d13ea2
adding husky
mattgperry Nov 16, 2018
b07e12d
adding initial files
mattgperry Nov 19, 2018
71c5ea7
adding pose resolver
mattgperry Nov 19, 2018
86d1ffc
adding useTransform
mattgperry Nov 19, 2018
4c61c4d
removing generics
mattgperry Nov 19, 2018
c721b3c
adding tests
mattgperry Nov 20, 2018
e78df9a
update todos
mattgperry Nov 20, 2018
ad6deda
adding default transition definitions
mattgperry Nov 20, 2018
90a8b02
passing current and velocity to dynamic poses
mattgperry Nov 20, 2018
a92f294
adding rollup
mattgperry Nov 20, 2018
3105d6f
adding velocity to motion value
mattgperry Nov 21, 2018
6ee6cee
adding default transitions
mattgperry Nov 21, 2018
3207e83
adding transitions
mattgperry Nov 21, 2018
b20edcd
adding cycle functionality
mattgperry Nov 21, 2018
5f2fe5d
adding latest tests
mattgperry Nov 22, 2018
6827e85
latest
mattgperry Nov 23, 2018
0af90e9
Added `make test`
nvh Nov 23, 2018
10c1879
Added .prettierrc.json
nvh Nov 23, 2018
d53d69e
test
mattgperry Nov 23, 2018
d4052cc
Merge branch 'initial-api' of https://github.com/framer/FramerMotion …
mattgperry Nov 23, 2018
03142bf
latest tests
mattgperry Nov 23, 2018
8273772
Remove prettier config from package.json
nvh Nov 23, 2018
fe7481f
Added make pretty and make lint
nvh Nov 23, 2018
74f8610
Let prettier handle the semicolons
nvh Nov 23, 2018
73e104f
Banning all default exports
nvh Nov 23, 2018
20289ac
Add staggerChildren to BaseTransition
nvh Nov 23, 2018
b0157f1
latest
mattgperry Nov 23, 2018
524720f
updating test imports
mattgperry Nov 23, 2018
9124086
Improved types of createMotionComponent
nvh Nov 23, 2018
78162c8
rename target to targetValue
nvh Nov 23, 2018
3064a63
Move MotionProps to ComponentFactory type
nvh Nov 23, 2018
78a6252
Added forgotten spread
nvh Nov 23, 2018
dc49b69
latest tests
mattgperry Nov 23, 2018
1e42476
latest
mattgperry Nov 23, 2018
087136a
Improving the motion types
nvh Nov 23, 2018
aee0246
Even more specific types for motion
nvh Nov 23, 2018
58fd4ba
Remove unused imports
nvh Nov 23, 2018
0d19074
animate between value types
mattgperry Nov 23, 2018
ef25b70
adding new values if not yet encountered before pose transform
mattgperry Nov 23, 2018
c7144bc
Added some type magic to make strictly typed string named poses possible
nvh Nov 23, 2018
4b9dc87
Added default pose
nvh Nov 25, 2018
5952b1d
Improved typing of usePose
nvh Nov 25, 2018
8e27bc4
Made MotionValue typed with generic
nvh Nov 25, 2018
37a8462
Removed usuless infer
nvh Nov 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/node_modules
/.cache-loader
.DS_Store
/dist
/lib
/tmp
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 120,
"tabWidth": 4,
"semi": false,
"trailingComma": "es5"
}
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ bootstrap:: node_modules/.yarn-integrity
dev: bootstrap
webpack-dev-server --config=dev/webpack/config.js

test: bootstrap
yarn test

lint: bootstrap
tslint --project tsconfig.json
tslint --project tsconfig.json --fix

pretty: bootstrap
prettier --write */**/*.tsx */**/*.ts

.PHONY: dev lint
6 changes: 6 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# TODOs

## Features
- Fix prop types on `motion`
- Coordination across children (ie `staggerChildren`): (explore later)
- `setPose.cycle`
Binary file added dev/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions dev/examples/convert-value-types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from "react"
import { motion, usePose } from "@framer"
import { Box } from "../styled"

const MotionBox = motion(Box)({
b: { width: "auto" },
c: { width: "calc(50vw)", x: 0 },
a: { width: 100, x: 100 },
})

export const App = () => {
const [pose, setPose] = usePose("b", ["b", "a", "c"])

return (
<div style={{ flex: "0 0 100%" }}>
<MotionBox pose={pose} onClick={() => setPose.cycle()} />
</div>
)
}
34 changes: 34 additions & 0 deletions dev/examples/custom-transition.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from "react"
import { motion, usePose } from "@framer"
import { Box } from "../styled"
import { useInterval } from "../inc/use-interval"

const MotionBox = motion(Box)({
ping: {
x: 100,
y: "0vh",
opacity: 0,
transition: {
x: false,
default: { duration: 4000 },
},
transitionEnd: { display: "none" },
},
pong: {
x: -100,
y: "20vh",
opacity: 1,
display: "block",
transition: { duration: 300 },
},
})

export const App = () => {
const [pose, setPose] = usePose<typeof MotionBox>("ping")

useInterval(() => {
setPose(pose.get() === "ping" ? "pong" : "ping")
}, 1000)

return <MotionBox pose={pose} />
}
25 changes: 25 additions & 0 deletions dev/examples/dynamic-pose.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from "react"
import { motion, usePose } from "@framer"
import { Box } from "../styled"
import { useInterval } from "../inc/use-interval"

const MotionBox = motion(Box)({
ping: {
x: 100,
y: "0vh",
transition: { duration: 100 },
},
pong: ({ targetValue }) => {
return { x: targetValue, y: "0vh" }
},
})

export const App = () => {
const [pose, setPose] = usePose<typeof MotionBox>("ping")

useInterval(() => {
setPose(pose.get() === "ping" ? "pong" : "ping")
}, 1000)

return <MotionBox pose={pose} targetValue={-100} />
}
24 changes: 24 additions & 0 deletions dev/examples/pose-as-array-prop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as React from "react"
import { motion } from "@framer"
import { Box } from "../styled"
import { useInterval } from "../inc/use-interval"

const MotionBox = motion(Box)({
a: { scale: 2 },
b: { scale: 0.5 },
c: { background: "#00f" },
})

export const App = () => {
const [pose, setPose] = React.useState<"a" | "b" | "c">("a")

useInterval(
() => {
setPose(pose === "a" ? "b" : "a")
},
1000,
[pose]
)

return <MotionBox pose={[pose, "c"]} />
}
19 changes: 19 additions & 0 deletions dev/examples/pose-as-hook.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from "react"
import { motion, usePose } from "@framer"
import { Box } from "../styled"
import { useInterval } from "../inc/use-interval"

const MotionBox = motion(Box)({
ping: { x: 100 },
pong: { x: -100 },
})

export const App = () => {
const [pose, setPose] = usePose<typeof MotionBox>("ping")

useInterval(() => {
setPose(pose.get() === "ping" ? "pong" : "ping")
}, 1000)

return <MotionBox pose={pose} />
}
18 changes: 18 additions & 0 deletions dev/examples/pose-as-string-prop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from "react"
import { useState } from "react"
import { motion } from "@framer"
import { Box } from "../styled"
import { ComponentPoseNames } from "motion/types"

const MotionBox = motion(Box)({
default: { scale: 1 },
pressed: { scale: 1.2 },
})

type Poses = ComponentPoseNames<typeof MotionBox>

export const App = () => {
const [pose, setPose] = useState<Poses>("default")

return <MotionBox pose={pose} onMouseDown={() => setPose("pressed")} onMouseUp={() => setPose("default")} />
}
50 changes: 50 additions & 0 deletions dev/examples/pose-children.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as React from "react"
import { useState } from "react"
import { motion } from "@framer"
import { useInterval } from "../inc/use-interval"

const Parent = motion.div({
visible: {
opacity: 1,
y: 0,
transition: {
staggerChildren: 50,
},
},
hidden: { opacity: 0, y: 100 },
})

const Child = motion.div({
visible: { opacity: 1, x: 0 },
hidden: { opacity: 0, x: -100 },
})

const parentStyles = {
width: 400,
height: 500,
background: "red",
padding: 10,
}

const childStyles = {
width: "100%",
height: 50,
background: "black",
marginBottom: 30,
}

export const App = () => {
const [pose, setPose] = useState<"visible" | "hidden">("hidden")

useInterval(() => setPose(pose === "hidden" ? "visible" : "hidden"), 2000, [pose])

return (
<Parent style={parentStyles} pose={pose}>
<div>
<Child style={childStyles} />
<Child style={childStyles} />
<Child style={childStyles} />
</div>
</Parent>
)
}
21 changes: 21 additions & 0 deletions dev/examples/pose-default-override.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from "react"
import { motion } from "@framer"

const Test = React.forwardRef((props: { foo: number; bar: string }, ref: React.Ref<HTMLDivElement>) => {
return (
<div ref={ref}>
{props.foo},{props.bar}
</div>
)
})

const MotionBox = motion(Test)(() => {
return {
default: { rotate: 0, backgroundColor: "#f00" },
foo: { rotate: 45, backgroundColor: "#0f0" },
}
})

export const App = () => {
return <MotionBox pose={"foo"} foo={9} bar={"test"} />
}
11 changes: 11 additions & 0 deletions dev/examples/pose-default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as React from "react"
import { motion } from "@framer"
import { Box } from "../styled"

const MotionBox = motion(Box)({
default: { scale: 2, backgroundColor: "#f00" },
})

export const App = () => {
return <MotionBox />
}
9 changes: 9 additions & 0 deletions dev/examples/render-component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from "react"
import { motion } from "@framer"
import { Box } from "../styled"

const MotionBox = motion(Box)()

export const App = () => {
return <MotionBox className="test" />
}
8 changes: 8 additions & 0 deletions dev/examples/render-element.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from "react"
import { motion } from "@framer"

const MotionBox = motion.ul()

export const App = () => {
return <MotionBox style={{ width: 100, height: 100, background: "green", padding: 0 }} />
}
9 changes: 0 additions & 9 deletions dev/examples/test.tsx

This file was deleted.

8 changes: 8 additions & 0 deletions dev/inc/use-interval.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useEffect } from "react"

export const useInterval = (callback: () => void, interval: number = 1000, args: any[] = []) => {
useEffect(() => {
const int = setInterval(callback, interval)
return () => clearInterval(int)
}, args)
}
16 changes: 16 additions & 0 deletions dev/styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import styled from "styled-components"

export const Container = styled.div`
min-width: 100vw;
min-height: 100vh;
background: #343d48;
display: flex;
align-items: center;
justify-content: center;
`

export const Box = styled.div`
width: 100px;
height: 100px;
background: #fff;
`
47 changes: 25 additions & 22 deletions dev/webpack/config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
const path = require("path")
const config = require("../../webpack.config")
const webpack = require("webpack")
const chalk = require("chalk")
const path = require('path');
const config = require('../../webpack.config');
const webpack = require('webpack');
const chalk = require('chalk');

const DEV_SERVER_PORT = 9990
const DEV_SERVER_PORT = 9990;

console.log(chalk.bold.green(`\nRunning at: http://0.0.0.0:${DEV_SERVER_PORT}/\n`))
console.log(
chalk.bold.green(`\nRunning at: http://0.0.0.0:${DEV_SERVER_PORT}/\n`)
);

config.entry = {
framer: [
"react-dev-utils/webpackHotDevClient",
path.join(__dirname, "..", "..", "src", "loader"),
path.join(__dirname, "index"),
],
}
framer: [
'react-dev-utils/webpackHotDevClient',
path.join(__dirname, '..', '..', 'src', 'index'),
path.join(__dirname, 'index')
]
};

config.devServer = {
contentBase: path.join(__dirname),
hot: false,
inline: false,
// quiet: true,
// open: true,
// openPage: "/",
stats: "errors-only",
port: DEV_SERVER_PORT,
}
Object.assign(exports, config)
contentBase: path.join(__dirname),
hot: false,
inline: false,
// quiet: true,
// open: true,
// openPage: "/",
stats: 'errors-only',
port: DEV_SERVER_PORT
};

Object.assign(exports, config);
7 changes: 6 additions & 1 deletion dev/webpack/examples.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react"
import { basename, extname } from "path"
import { Container } from "../styled"

const context = require["context"]("../examples", true, /\.(tsx?)$/)

Expand Down Expand Up @@ -53,7 +54,11 @@ export class App extends React.Component {
// Update the document title to the example
document.title = exampleName

return React.createElement(exampleApp.App)
return (
<Container>
<exampleApp.App />
</Container>
)
} else {
return (
<p>
Expand Down
2 changes: 2 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "jest-dom/extend-expect"
import "react-testing-library/cleanup-after-each"
Loading