Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit c42f166

Browse files
committed
📝 (transitions) add guides/transitions
1 parent fba8b03 commit c42f166

22 files changed

Lines changed: 122 additions & 41 deletions

docs/Roadmap.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ route: /roadmap
77

88
If there is a real interest on `react-gondola` and its phylosophy, I might add support for the following features:
99

10-
- go back event listener
11-
- transitions
10+
import { StrikeThrough } from "./components/StrikeThrough";
11+
12+
- <StrikeThrough>go back event listener</StrikeThrough> 🎉 Done !
13+
- <StrikeThrough>transitions</StrikeThrough> 🎉 Done !
1214
- navigation gestures
1315

1416
Tweet me some encouragements 😁 and star the repo !

docs/components/StrikeThrough.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { Text } from 'react-native';
3+
4+
export function StrikeThrough(props: { children: string }) {
5+
return (
6+
<Text
7+
style={{
8+
textDecorationLine: 'line-through',
9+
textDecorationStyle: 'solid'
10+
}}
11+
>
12+
{props.children}
13+
</Text>
14+
);
15+
}

docs/guides/Transitions.mdx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Transitions
3+
menu: Guides
4+
route: /guides/transitions
5+
---
6+
7+
# Transitions
8+
9+
In order to use transitions between two screens, simply add the `Transitioner` key to your stops.
10+
11+
## Basic example
12+
13+
```ts
14+
import React from "react";
15+
import { createCanal } from "react-gondola";
16+
import { SildeLeft } from "react-gondola/transitions";
17+
import { FirstName } from "./FirstName";
18+
import { LastName } from "./LastName";
19+
20+
const SignInCanal = createCanal([
21+
{ name: "firstName", Component: FirstName },
22+
{ name: "lastName", Component: LastName, Transitioner: SildeLeft }
23+
]);
24+
```
25+
26+
## Available transitioners
27+
28+
| Transitioner | Import | transition |
29+
| :-------------------------------------------------------------------: | ---------------------------------------------------------- | :--------------------------------------------------: |
30+
| `SildeLeft` | `import { SildeLeft } from "react-gondola/transitions";` | ![Slide Left transition](./assets/slideLeft.gif) |
31+
| `SildeUp` | `import { SildeUp } from "react-gondola/transitions";` | ![Slide Up transition](./assets/slideUp.gif) |
32+
| `RotateCrazy` (⚠️ experimental: this might be removed without notice) | `import { RotateCrazy } from "react-gondola/transitions";` | ![Rotate Crazy transition](./assets/rotateCrazy.gif) |
33+
34+
## Create your own transitioner
35+
36+
You can create your own transitioner if the one availables does not fit your needs ! Get some inspiration by looking at `SlideLeft` source code and get started !
37+
38+
1. Your transitioner need to extend `TransitionComponent` (imported from `react-gondola/transitions`).
39+
2. Your transitioner will receive a `directionForward` prop. If true, your transitioner need to play the transition forward. Else, it need to play the transition backward.
40+
3. (Optionnal but recommended) If you use jest, you can test your component using `describeTransitioner` from `react-gondola/transitions/describeTransitioner`
41+
42+
⚠️ If you use jest and want to test you Transitioner wihch uses `react-native-reanimated`, make sure you correctly mocked `react-native-reanimated`.
43+
44+
```js
45+
// in your jest setup file, use the following
46+
47+
jest.mock("react-native-reanimated/src/ReanimatedEventEmitter");
48+
jest.mock("react-native-reanimated/src/ReanimatedModule", () => ({
49+
configureNativeProps: () => {},
50+
connectNodes: () => {},
51+
disconnectNodes: () => {},
52+
createNode: () => {},
53+
configureProps: () => {},
54+
getValue: () => {},
55+
dropNode: () => {}
56+
}));
57+
jest.mock("react-native-reanimated/src/derived/evaluateOnce");
58+
jest.mock("react-native-reanimated/src/core/AnimatedProps");
59+
```

docs/guides/assets/rotateCrazy.gif

458 KB
Loading

docs/guides/assets/slideLeft.gif

364 KB
Loading

docs/guides/assets/slideUp.gif

280 KB
Loading

doczrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
menu: [
77
'Welcome',
88
'Getting Started',
9+
{ name: 'Guides', menu: ['Transitions'] },
910
'Example',
1011
'Contribute',
1112
'Roadmap',
@@ -16,6 +17,7 @@ module.exports = {
1617
config.resolve.alias = Object.assign({}, config.resolve.alias, {
1718
'react-native$': 'react-native-web',
1819
'react-gondola$': path.resolve(__dirname, 'src/index.ts'), // eslint-disable-line
20+
'react-gondola/transitions$': path.resolve(__dirname, 'src/transitions/index.ts'), // eslint-disable-line
1921
});
2022
return config;
2123
},

example/src/Exemple.mdx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@ name: Example
33
route: /example
44
---
55

6-
# Example
7-
8-
The following example runs with `react-native-web` 🎉
9-
10-
import { Playground } from "docz";
11-
import { View } from "react-native";
12-
import App from "./App";
13-
14-
<Playground>
15-
<View style={{ alignItems: "center" }}>
16-
<View style={{ width: 320, height: 568 }}>
17-
<App />
18-
</View>
19-
</View>
20-
</Playground>
21-
226
## Run the example project
237

248
- Clone this repository.

example/src/canals/SignIn/SignIn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class SignIn extends Component {
3333
},
3434
{
3535
Component: LastName,
36-
Transitioner: SlideLeft,
36+
Transitioner: RotateCrazy,
3737
name: 'lastName',
3838
onBack: this.goBackward,
3939
props: { onNext: this.goForward }

src/StopValidator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { ComponentType } from 'react';
22

3-
import { TransitionComponentType } from './transitions/Transition.d';
3+
import { TransitionComponentType } from './transitions/Transition';
44

55
export interface IStop<T extends string> {
66
name: T;

0 commit comments

Comments
 (0)