Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit f6f55b7

Browse files
authored
Merge pull request #115 from madou/rename-baba-to-animator
chore: renames baba component to animator
2 parents 866a973 + b90b445 commit f6f55b7

45 files changed

Lines changed: 428 additions & 433 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ yarn add yubaba react@^16.4.x react-dom@^16.4.x emotion@^10.x.x
4141
## Usage
4242

4343
```js
44-
import Baba, { Move } from 'yubaba';
44+
import Animator, { Move } from 'yubaba';
4545

4646
({ isLarge }) => (
47-
<Baba name="my-first-baba" key={isLarge}>
48-
<Move>{baba => <div {...baba} className={isLarge ? 'large' : 'small'} />}</Move>
49-
</Baba>
47+
<Animator name="my-first-baba" key={isLarge}>
48+
<Move>{anim => <div {...anim} className={isLarge ? 'large' : 'small'} />}</Move>
49+
</Animator>
5050
);
5151
```
5252

packages/yubaba-common/src/createMoveExamples/index.tsx

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
---
2-
name: Baba
3-
route: /baba
2+
name: Animator
3+
route: /animator
44
---
55

66
import { Playground, Props } from 'docz';
7-
import Baba from '../index';
7+
import Animator from '../index';
88

9-
# Baba
9+
# Animator
1010

1111
This is the brains component.
1212
When unmounting or flipping the `in` prop from `true` to `false`,
13-
it will execute all the animations **top to bottom** if a matching Baba pair (either itself or another Baba element) is found within `50ms`.
13+
it will execute all the animations **top to bottom** if a matching Animator pair (either itself or another Animator element) is found within `50ms`.
1414

1515
> **Tip -** See [Getting started](/getting-started) for more information on how to use this component.
1616
1717
## Usage
1818

1919
```js
20-
import Baba from 'yubaba';
20+
import Animator from 'yubaba';
2121

2222
const ListItem = ({ index }) => (
23-
<Baba name={`item-${index}`}>
23+
<Animator name={`item-${index}`}>
2424
{({ ref, style, className }) => <div ref={ref} style={style} className={className} />}
25-
</Baba>
25+
</Animator>
2626
);
2727
```
2828

2929
## Props
3030

31-
<Props of={Baba} />
31+
<Props of={Animator} />

packages/yubaba/src/Baba/__snapshots__/test.tsx.snap renamed to packages/yubaba/src/Animator/__snapshots__/test.tsx.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<Baba /> should pass dom data to child animation 1`] = `
3+
exports[`<Animator /> should pass dom data to child animation 1`] = `
44
Array [
55
Object {
66
"destination": Object {
@@ -49,7 +49,7 @@ Array [
4949
]
5050
`;
5151

52-
exports[`<Baba /> should pass dom data to child animation when using in prop 1`] = `
52+
exports[`<Animator /> should pass dom data to child animation when using in prop 1`] = `
5353
Array [
5454
Object {
5555
"destination": Object {
@@ -98,7 +98,7 @@ Array [
9898
]
9999
`;
100100

101-
exports[`<Baba /> should pass target dom data to child animation 1`] = `
101+
exports[`<Animator /> should pass target dom data to child animation 1`] = `
102102
Object {
103103
"location": Object {
104104
"left": 0,
@@ -116,7 +116,7 @@ Object {
116116
}
117117
`;
118118

119-
exports[`<Baba /> should render markup in a portal created by multiple animations 1`] = `
119+
exports[`<Animator /> should render markup in a portal created by multiple animations 1`] = `
120120
Array [
121121
<Portal
122122
containerInfo={
@@ -147,7 +147,7 @@ Array [
147147
]
148148
`;
149149

150-
exports[`<Baba /> should render markup in a portal created in an animation 1`] = `
150+
exports[`<Animator /> should render markup in a portal created in an animation 1`] = `
151151
<Portal
152152
containerInfo={
153153
<div>
@@ -163,7 +163,7 @@ exports[`<Baba /> should render markup in a portal created in an animation 1`] =
163163
</Portal>
164164
`;
165165

166-
exports[`<Baba /> should update markup created in an animation in after animate phase 1`] = `
166+
exports[`<Animator /> should update markup created in an animation in after animate phase 1`] = `
167167
<Portal
168168
containerInfo={
169169
<div>
@@ -179,7 +179,7 @@ exports[`<Baba /> should update markup created in an animation in after animate
179179
</Portal>
180180
`;
181181

182-
exports[`<Baba /> should update markup created in an animation in animate phase 1`] = `
182+
exports[`<Animator /> should update markup created in an animation in animate phase 1`] = `
183183
<Portal
184184
containerInfo={
185185
<div>
@@ -195,7 +195,7 @@ exports[`<Baba /> should update markup created in an animation in animate phase
195195
</Portal>
196196
`;
197197

198-
exports[`<Baba /> should update markup in a portal created by multiple animations in animate phase 1`] = `
198+
exports[`<Animator /> should update markup in a portal created by multiple animations in animate phase 1`] = `
199199
Array [
200200
<Portal
201201
containerInfo={
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { getElementBoundingBox } from '../lib/dom';
1717
import defer from '../lib/defer';
1818
import noop from '../lib/noop';
1919
import { precondition, warn } from '../lib/log';
20-
import * as babaStore from '../lib/babaStore';
20+
import * as store from '../lib/animatorStore';
2121
import { InjectedProps, withVisibilityManagerContext } from '../VisibilityManager';
2222

2323
export type AnimationFunc = () => Promise<void>;
@@ -41,23 +41,23 @@ export interface State {
4141
animationsMarkup: React.ReactPortal[];
4242
}
4343

44-
export interface BabaProps extends CollectorChildrenProps, InjectedProps {
44+
export interface AnimatorProps extends CollectorChildrenProps, InjectedProps {
4545
/**
46-
* Name of the yubaba animation, this should match the target yubaba.
46+
* Name of the animator, this should match the target animator.
4747
*/
4848
name: string;
4949

5050
/**
51-
* Used alternatively to the implicit animation triggering via unmounting or mounting of Baba components.
51+
* Used alternatively to the implicit animation triggering via unmounting or mounting of Animator components.
5252
* Only use `in` if your component is expected to persist through the entire lifecyle of the app.
5353
* When you transition to the "next page" make sure to set your "in" to false. When you transition
54-
* back to the original page set the "in" prop back to true. This lets the Baba components know when to
54+
* back to the original page set the "in" prop back to true. This lets the Animator components know when to
5555
* execute the animations.
5656
*/
5757
in?: boolean;
5858

5959
/**
60-
* Callback called when all animations have finished and been cleaned up. Fired from the triggering Baba
60+
* Callback called when all animations have finished and been cleaned up. Fired from the triggering Animator
6161
* component.
6262
*/
6363
onFinish: () => void;
@@ -66,7 +66,7 @@ export interface BabaProps extends CollectorChildrenProps, InjectedProps {
6666
* Time this component will wait until it throws away the animation.
6767
* Defaults to 50ms, might want to bump it up if loading something that was code split.
6868
*/
69-
timeToWaitForNextBaba: number;
69+
timeToWaitForNextAnimator: number;
7070

7171
/**
7272
* HTMLElement container used when creating elements for animations,
@@ -75,12 +75,12 @@ export interface BabaProps extends CollectorChildrenProps, InjectedProps {
7575
container: HTMLElement | (() => HTMLElement);
7676
}
7777

78-
export default class Baba extends React.PureComponent<BabaProps, State> {
79-
static displayName = 'Baba';
78+
export default class Animator extends React.PureComponent<AnimatorProps, State> {
79+
static displayName = 'Animator';
8080

8181
static defaultProps = {
8282
onFinish: noop,
83-
timeToWaitForNextBaba: 50,
83+
timeToWaitForNextAnimator: 50,
8484
container: document.body,
8585
};
8686

@@ -106,30 +106,30 @@ export default class Baba extends React.PureComponent<BabaProps, State> {
106106
componentDidMount() {
107107
const { in: componentIn, name } = this.props;
108108

109-
if (componentIn === undefined && babaStore.has(name)) {
109+
if (componentIn === undefined && store.has(name)) {
110110
// A child has already been stored, so this is probably the matching pair.
111111
this.executeAnimations();
112112
return;
113113
}
114114

115115
if (componentIn === undefined || componentIn) {
116116
// Ok nothing is there yet, show ourself and store DOM data for later.
117-
// We'll be waiting for another Baba to mount.
117+
// We'll be waiting for another Animator to mount.
118118
this.showSelfAndNotifyManager();
119119
}
120120
}
121121

122-
componentWillUpdate(prevProps: BabaProps) {
122+
componentWillUpdate(prevProps: AnimatorProps) {
123123
const { in: isIn } = this.props;
124124
if (prevProps.in === false && isIn === true) {
125125
// We're being removed from "in". Let's recalculate our DOM position.
126126
this.storeDOMData();
127-
this.delayedClearBabaStore();
127+
this.delayedClearStore();
128128
this.abortAnimations();
129129
}
130130
}
131131

132-
componentDidUpdate(prevProps: BabaProps) {
132+
componentDidUpdate(prevProps: AnimatorProps) {
133133
const { in: isIn, name } = this.props;
134134

135135
if (isIn === prevProps.in) {
@@ -147,7 +147,7 @@ export default class Baba extends React.PureComponent<BabaProps, State> {
147147
}
148148

149149
if (isIn) {
150-
if (babaStore.has(name)) {
150+
if (store.has(name)) {
151151
this.executeAnimations();
152152
return;
153153
}
@@ -158,7 +158,7 @@ export default class Baba extends React.PureComponent<BabaProps, State> {
158158

159159
componentWillUnmount() {
160160
this.storeDOMData();
161-
this.delayedClearBabaStore();
161+
this.delayedClearStore();
162162
this.abortAnimations();
163163
this.unmounting = true;
164164
}
@@ -173,28 +173,28 @@ export default class Baba extends React.PureComponent<BabaProps, State> {
173173
}
174174
}
175175

176-
delayedClearBabaStore() {
177-
const { name, timeToWaitForNextBaba } = this.props;
176+
delayedClearStore() {
177+
const { name, timeToWaitForNextAnimator } = this.props;
178178

179-
setTimeout(() => babaStore.remove(name), timeToWaitForNextBaba);
179+
setTimeout(() => store.remove(name), timeToWaitForNextAnimator);
180180
}
181181

182182
storeDOMData() {
183183
if (this.unmounting) {
184184
return;
185185
}
186186

187-
// If there is only a Baba target and no child animations
187+
// If there is only a Animator target and no child animations
188188
// data will be undefined, which means there are no animations to store.
189189
if (this.data) {
190190
if (process.env.NODE_ENV === 'development') {
191191
precondition(
192192
this.element,
193193
`The ref was not set when trying to store data, check that a child element has a ref passed. This needs to be set so we can take a snapshot of the origin DOM element.
194194
195-
<${Baba.displayName} name="${this.props.name}">
195+
<${Animator.displayName} name="${this.props.name}">
196196
{props => <div ref={props.ref} />}
197-
</${Baba.displayName}>
197+
</${Animator.displayName}>
198198
`
199199
);
200200
}
@@ -214,7 +214,7 @@ If it's an image, try and have the image loaded before mounting, or set a static
214214
// NOTE: Currently in react 16.3 if the parent being unmounted is a Fragment
215215
// there is a chance for sibling elements to be removed from the DOM first
216216
// resulting in inaccurate calculations of location. Watch out!
217-
const data: babaStore.BabaData = {
217+
const data: store.AnimatorData = {
218218
elementData: {
219219
element: this.element as HTMLElement,
220220
elementBoundingBox,
@@ -225,14 +225,14 @@ If it's an image, try and have the image loaded before mounting, or set a static
225225
collectorData: this.data,
226226
};
227227

228-
babaStore.set(name, data);
228+
store.set(name, data);
229229
}
230230
}
231231

232232
executeAnimations = () => {
233233
const { name, container: getContainer, context } = this.props;
234234
const container = typeof getContainer === 'function' ? getContainer() : getContainer;
235-
const fromTarget = babaStore.get(name);
235+
const fromTarget = store.get(name);
236236

237237
if (fromTarget) {
238238
const { collectorData, elementData } = fromTarget;
@@ -474,4 +474,4 @@ If it's an image, try and have the image loaded before mounting, or set a static
474474
}
475475
}
476476

477-
export const WrappedBaba = withVisibilityManagerContext(Baba);
477+
export const WrappedAnimator = withVisibilityManagerContext(Animator);
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import * as React from 'react';
22
import { storiesOf } from '@storybook/react';
3-
import Baba from './index';
3+
import Animator from './index';
44
import Noop from '../animations/Noop';
55

6-
interface BabaProfilerProps {
6+
interface AnimatorProfilerProps {
77
iterations: number;
88
}
99

10-
interface BabaProfilerState {
10+
interface AnimatorProfilerState {
1111
start: boolean;
1212
profiling: boolean;
1313
finished: boolean;
1414
}
1515

16-
class BabaProfiler extends React.Component<BabaProfilerProps, BabaProfilerState> {
17-
state: BabaProfilerState = BabaProfiler.getDefaultState();
16+
class AnimatorProfiler extends React.Component<AnimatorProfilerProps, AnimatorProfilerState> {
17+
state: AnimatorProfilerState = AnimatorProfiler.getDefaultState();
1818

1919
curStart: number = -1;
2020

@@ -72,7 +72,7 @@ class BabaProfiler extends React.Component<BabaProfilerProps, BabaProfilerState>
7272
this.curEnd = -1;
7373
this.results = [];
7474
this.iteration = 1;
75-
this.setState(BabaProfiler.getDefaultState(), this.start);
75+
this.setState(AnimatorProfiler.getDefaultState(), this.start);
7676
};
7777

7878
static getDefaultState() {
@@ -110,33 +110,33 @@ class BabaProfiler extends React.Component<BabaProfilerProps, BabaProfilerState>
110110
return (
111111
<div>
112112
{!this.state.start ? (
113-
<Baba name="profiler">
113+
<Animator name="profiler">
114114
<Noop>
115-
{baba => (
116-
<div {...baba}>
115+
{anim => (
116+
<div {...anim}>
117117
<span>{this.iteration}</span>
118118
</div>
119119
)}
120120
</Noop>
121-
</Baba>
121+
</Animator>
122122
) : (
123123
<div>
124-
<Baba name="profiler" onFinish={this.onNextIteration}>
125-
{baba => (
126-
<div {...baba}>
124+
<Animator name="profiler" onFinish={this.onNextIteration}>
125+
{anim => (
126+
<div {...anim}>
127127
<span>{this.iteration}</span>
128128
</div>
129129
)}
130-
</Baba>
130+
</Animator>
131131
</div>
132132
)}
133133
</div>
134134
);
135135
}
136136
}
137137

138-
storiesOf('yubaba/Baba', module)
139-
.add('profiler (1)', () => <BabaProfiler iterations={1} />)
140-
.add('profiler (10)', () => <BabaProfiler iterations={10} />)
141-
.add('profiler (100)', () => <BabaProfiler iterations={100} />)
142-
.add('profiler (1000)', () => <BabaProfiler iterations={1000} />);
138+
storiesOf('yubaba/Animator', module)
139+
.add('profiler (1)', () => <AnimatorProfiler iterations={1} />)
140+
.add('profiler (10)', () => <AnimatorProfiler iterations={10} />)
141+
.add('profiler (100)', () => <AnimatorProfiler iterations={100} />)
142+
.add('profiler (1000)', () => <AnimatorProfiler iterations={1000} />);

0 commit comments

Comments
 (0)