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

Commit 55b9af8

Browse files
committed
chore: rename reveal to focal reveal, reveal move to focal reveal move, simple reveal to reveal
1 parent 48d085f commit 55b9af8

21 files changed

Lines changed: 302 additions & 302 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ easy to use animations with powerful orchestration for React.js 🧙✨
1111
It's all about **animation** 🧙✨ - it can help with:
1212

1313
- [Moving an element](https://yubabajs.com/move) from one position to another
14-
- [Revealing elements](https://yubabajs.com/reveal-move) like you see above
14+
- [Revealing elements](https://yubabajs.com/focal-reveal-move) like you see above
1515
- [Supporting animations](https://yubabajs.com/supporting-animations) by obstructing elements in view; and
1616
- [Hiding children elements](https://yubabajs.com/advanced-usage#delay-showing-content-until-all-animations-have-finished) until animations have completed to trick users 🤫
1717
- [Orchestrating](https://yubabajs.com/advanced-usage#wait-for-the-previous-animation-to-finish-before-starting-the-next) when animations should happen and [in what order](https://yubabajs.com/advanced-usage#controlling-in-what-order-animations-should-execute)

packages/yubaba/src/__docs__/1-introduction/docs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ easy to use animations with powerful orchestration for React.js 🧙✨
1919
It's all about **animation** 🧙✨ - it can help with:
2020

2121
- [Moving an element](/move) from one position to another
22-
- [Revealing elements](/reveal-move) like you see above
22+
- [Revealing elements](/focal-reveal-move) like you see above
2323
- [Supporting animations](/supporting-animations) by obstructing elements in view; and
2424
- [Hiding children elements](/advanced-usage#delay-showing-content-until-all-animations-have-finished) until animations have completed to trick users 🤫
2525
- [Orchestrating](/advanced-usage#wait-for-the-previous-animation-to-finish-before-starting-the-next) when animations should happen and [in what order](/advanced-usage#controlling-in-what-order-animations-should-execute)

packages/yubaba/src/__docs__/3-advanced-usage/EmailChain.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from '@material-ui/core';
2222
import * as Styled from './styled';
2323
import { WrappedBaba as Baba } from '../../Baba';
24-
import RevealMove from '../../animations/RevealMove';
24+
import FocalRevealMove from '../../animations/FocalRevealMove';
2525
import ConcealMove from '../../animations/ConcealMove';
2626
import FocalTarget from '../../FocalTarget';
2727

@@ -41,7 +41,7 @@ const EmailChain = () => {
4141
{Styled.data.map((email, index) => (
4242
<React.Fragment key={index}>
4343
<Baba name={`card-${index}`} in={props.in}>
44-
<RevealMove duration={600}>
44+
<FocalRevealMove duration={600}>
4545
{baba => (
4646
<div {...baba}>
4747
<ListItem button>
@@ -57,7 +57,7 @@ const EmailChain = () => {
5757
</ListItem>
5858
</div>
5959
)}
60-
</RevealMove>
60+
</FocalRevealMove>
6161
</Baba>
6262
<Divider variant="inset" />
6363
</React.Fragment>

packages/yubaba/src/__docs__/3-advanced-usage/docs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import * as Styled from './styled';
2929
import { WrappedBaba as Baba } from '../../Baba';
3030
import { WrappedBabaManager as BabaManager } from '../../BabaManager';
3131
import CircleExpand from '../../animations/CircleExpand';
32-
import RevealMove from '../../animations/RevealMove';
32+
import FocalRevealMove from '../../animations/FocalRevealMove';
3333
import ConcealMove from '../../animations/ConcealMove';
3434
import FocalTarget from '../../FocalTarget';
3535
import Move from '../../animations/Move';

packages/yubaba/src/__docs__/focal-animations/docs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ menu: Focal animations
99
The bread and butter of `yubaba` 🍞.
1010

1111
Focal animations are all about a single focal element that we want to transition from one state to another.
12-
While multiple elements _may_ be utilised in a focal animation (e.g. how [RevealMove](/reveal-move) works),
12+
While multiple elements _may_ be utilised in a focal animation (e.g. how [FocalRevealMove](/focal-reveal-move) works),
1313
the animations are always interested in a single focal element.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: FocalReveal
3+
route: /focal-reveal
4+
menu: Focal animations
5+
---
6+
7+
import { Playground, PropsTable } from 'docz';
8+
import * as Common from 'yubaba-common';
9+
import Reveal from '../index';
10+
11+
# FocalReveal
12+
13+
Will reveal a container around a marked focal element using `width` and `height`,
14+
or alternatively `clip-path`.
15+
See [FocalRevealMove](/focal-reveal-move) for what this looks like.
16+
17+
This component requires the use of a [FocalTarget](/focal-target) to mark the focal element.
18+
19+
## Usage
20+
21+
```js
22+
import { Reveal } from 'yubaba';
23+
```
24+
25+
## Props
26+
27+
<PropsTable of={Reveal} />
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
import * as React from 'react';
2+
import { css } from 'emotion';
3+
import Collector, {
4+
CollectorChildrenProps,
5+
AnimationCallback,
6+
CollectorActions,
7+
} from '../../Collector';
8+
import { standard } from '../../lib/curves';
9+
import { combine } from '../../lib/style';
10+
import { dynamic } from '../../lib/duration';
11+
import { Duration } from '../types';
12+
13+
export interface FocalRevealProps extends CollectorChildrenProps {
14+
/**
15+
* How long the animation should take over {duration}ms.
16+
*/
17+
duration: Duration;
18+
19+
/**
20+
* zIndex to be applied to the moving element.
21+
*/
22+
zIndex?: number;
23+
24+
/**
25+
* Timing function to be used in the transition.
26+
*/
27+
timingFunction: string;
28+
29+
/**
30+
* Set to false to disable transforming the children to the X position of the focal element.
31+
* Defaults to true.
32+
*/
33+
childrenTransformX: boolean;
34+
35+
/**
36+
* Set to false to disable transforming the children to the Y position of the focal element.
37+
* Defaults to `true`.
38+
*/
39+
childrenTransformY: boolean;
40+
41+
/**
42+
* Will transition using clip-path over height and width.
43+
* This results in a more resilient transition since page flow isn't affected at the cost of browser support.
44+
* See: https://caniuse.com/#feat=css-clip-path
45+
*/
46+
useClipPath?: boolean;
47+
}
48+
49+
export default class FocalReveal extends React.Component<FocalRevealProps> {
50+
static defaultProps = {
51+
duration: 'dynamic',
52+
timingFunction: standard(),
53+
childrenTransformX: true,
54+
childrenTransformY: true,
55+
};
56+
57+
beforeAnimate: AnimationCallback = (data, onFinish, setChildProps) => {
58+
if (!data.destination.focalTargetElementBoundingBox) {
59+
throw new Error(`yubaba
60+
<FocalTarget /> was not found, if you haven't defined one make sure to add one as a descendant of your target Baba.`);
61+
}
62+
63+
const { childrenTransformX, childrenTransformY, useClipPath } = this.props;
64+
65+
const offsetChildrenX = childrenTransformX
66+
? data.destination.focalTargetElementBoundingBox.location.left -
67+
data.destination.elementBoundingBox.location.left
68+
: 0;
69+
const offsetChildrenY = childrenTransformY
70+
? data.destination.focalTargetElementBoundingBox.location.top -
71+
data.destination.elementBoundingBox.location.top
72+
: 0;
73+
74+
const revealStyles = useClipPath
75+
? {
76+
clipPath: `inset(0 ${data.destination.elementBoundingBox.size.width -
77+
data.destination.focalTargetElementBoundingBox.size.width}px ${data.destination
78+
.elementBoundingBox.size.height -
79+
data.destination.focalTargetElementBoundingBox.size.height}px 0)`,
80+
}
81+
: {
82+
height: data.destination.focalTargetElementBoundingBox.size.height,
83+
width: data.destination.focalTargetElementBoundingBox.size.width,
84+
};
85+
86+
setChildProps({
87+
style: prevStyles =>
88+
data.destination.focalTargetElementBoundingBox
89+
? {
90+
...prevStyles,
91+
...revealStyles,
92+
opacity: 1,
93+
visibility: 'visible',
94+
willChange: combine('height, width, clip-path')(prevStyles.willChange),
95+
overflow: 'hidden',
96+
}
97+
: undefined,
98+
className: () =>
99+
data.destination.focalTargetElementBoundingBox
100+
? css({
101+
'> *': {
102+
transform: `translate3d(-${offsetChildrenX}px, -${offsetChildrenY}px, 0)`,
103+
},
104+
})
105+
: undefined,
106+
});
107+
108+
onFinish();
109+
};
110+
111+
animate: AnimationCallback = (data, onFinish, setChildProps) => {
112+
const { timingFunction, duration, useClipPath } = this.props;
113+
const calculatedDuration =
114+
duration === 'dynamic'
115+
? dynamic(data.origin.elementBoundingBox, data.destination.elementBoundingBox)
116+
: duration;
117+
118+
const revealStyles = useClipPath
119+
? {
120+
clipPath: 'inset(0 0 0 0)',
121+
}
122+
: {
123+
height: data.destination.elementBoundingBox.size.height,
124+
width: data.destination.elementBoundingBox.size.width,
125+
};
126+
127+
setChildProps({
128+
style: prevStyles => ({
129+
...prevStyles,
130+
...revealStyles,
131+
transition: combine(
132+
`height ${calculatedDuration}ms ${timingFunction}, width ${calculatedDuration}ms ${timingFunction}, clip-path ${calculatedDuration}ms ${timingFunction}`
133+
)(prevStyles.transition),
134+
}),
135+
className: () =>
136+
css({
137+
'> *': {
138+
transform: `translate3d(0, 0, 0)`,
139+
transition: `transform ${calculatedDuration}ms ${timingFunction}`,
140+
},
141+
}),
142+
});
143+
144+
setTimeout(() => onFinish(), calculatedDuration);
145+
};
146+
147+
render() {
148+
const { children } = this.props;
149+
150+
return (
151+
<Collector
152+
data={{
153+
action: CollectorActions.animation,
154+
payload: {
155+
beforeAnimate: this.beforeAnimate,
156+
animate: this.animate,
157+
},
158+
}}
159+
>
160+
{children}
161+
</Collector>
162+
);
163+
}
164+
}

packages/yubaba/src/animations/RevealMove/__docs__/docs.mdx renamed to packages/yubaba/src/animations/FocalRevealMove/__docs__/docs.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
name: RevealMove
3-
route: /reveal-move
2+
name: FocalRevealMove
3+
route: /focal-reveal-move
44
menu: Focal animations
55
---
66

@@ -20,14 +20,14 @@ import PlayButton from '@material-ui/icons/PlayArrow';
2020
import BackIcon from '@material-ui/icons/ArrowBack';
2121
import MoreVert from '@material-ui/icons/MoreVert';
2222
import { lighten } from 'polished';
23-
import RevealMove from '../index';
23+
import FocalRevealMove from '../index';
2424
import Noop from '../../Noop';
2525
import Baba from '../../../Baba';
2626
import FocalTarget from '../../../FocalTarget';
2727
import * as Styled from './styled';
2828
import albumArt from './images/halcyda.png';
2929

30-
# RevealMove
30+
# FocalRevealMove
3131

3232
Is a composite animation of Reveal and [Move](/move).
3333
Useful for transitioning from a parent to a child,
@@ -37,20 +37,20 @@ Requires the use of the [FocalTarget](/focal-target) component to specify the fo
3737
## Usage
3838

3939
```js
40-
import Baba, { RevealMove, FocalTarget } from 'yubaba';
40+
import Baba, { FocalRevealMove, FocalTarget } from 'yubaba';
4141
```
4242

4343
<Playground>
4444
{() => {
4545
const revealingImage = ({ albumArt }) => (
4646
<Baba name="reveal-move">
47-
<RevealMove useClipPath>
47+
<FocalRevealMove useClipPath>
4848
{({ ref, style }) => (
4949
<Link to="/details">
5050
<Styled.BackgroundImage src={albumArt} style={style} innerRef={ref} />
5151
</Link>
5252
)}
53-
</RevealMove>
53+
</FocalRevealMove>
5454
</Baba>
5555
);
5656

@@ -211,7 +211,7 @@ import Baba, { RevealMove, FocalTarget } from 'yubaba';
211211

212212
## Props
213213

214-
<PropsTable of={RevealMove} />
214+
<PropsTable of={FocalRevealMove} />
215215

216216
## Caveats
217217

packages/yubaba/src/animations/RevealMove/__docs__/images/halcyda.png renamed to packages/yubaba/src/animations/FocalRevealMove/__docs__/images/halcyda.png

File renamed without changes.

packages/yubaba/src/animations/RevealMove/__docs__/styled.tsx renamed to packages/yubaba/src/animations/FocalRevealMove/__docs__/styled.tsx

File renamed without changes.

0 commit comments

Comments
 (0)