|
| 1 | +--- |
| 2 | +name: Getting Started |
| 3 | +--- |
| 4 | + |
| 5 | +# Getting Started |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +React-gondola needs the following dependencies; if you do not have those installed, you need to install them with the correspondig command: |
| 10 | + |
| 11 | +| Dependencie name | Yarn Installation command | NPM Installation command | |
| 12 | +| :--------------: | :-----------------------: | :----------------------: | |
| 13 | +| `mobx` | `yarn add mobx` | `npm i mobx` | |
| 14 | +| `rxjs` | `yarn add rxjs` | `npm i rxjs` | |
| 15 | + |
| 16 | +Then, install React-Gondola with: |
| 17 | + |
| 18 | +`yarn add react-gondola` |
| 19 | + |
| 20 | +or |
| 21 | + |
| 22 | +`npm i react-gondola` |
| 23 | + |
| 24 | +## Basic Usage |
| 25 | + |
| 26 | +### Create a canal |
| 27 | + |
| 28 | +In order to create a canal, use the `createCanal` function. Pass it your screens in the business order. |
| 29 | + |
| 30 | +```ts |
| 31 | +import React from "react"; |
| 32 | +import { createCanal } from "react-gondola"; |
| 33 | +import { FirstName } from "./FirstName"; |
| 34 | +import { LastName } from "./LastName"; |
| 35 | + |
| 36 | +const SignInCanal = createCanal([ |
| 37 | + { name: "firstName", Component: FirstName }, |
| 38 | + { name: "lastName", Component: LastName } |
| 39 | +]); |
| 40 | +``` |
| 41 | + |
| 42 | +Then, use the canal wherever you want in your app. Specify wether to show/hide a screen by using the screen's name as a prop: |
| 43 | + |
| 44 | +```ts |
| 45 | +import React, { Component } from "react"; |
| 46 | +import { SignInCanal } from "./canals/SignIn"; |
| 47 | + |
| 48 | +export default class App extends Component { |
| 49 | + render() { |
| 50 | + return <SignInCanal firstName />; |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +That's all ! |
| 56 | + |
| 57 | +### Add some full screen page |
| 58 | + |
| 59 | +If you want to add full screen page, pass the `isFullScreen` flag when creating a canal. In the following example, `confirm` is a full screen page. |
| 60 | + |
| 61 | +```ts |
| 62 | +import React from "react"; |
| 63 | +import { createCanal } from "react-gondola"; |
| 64 | +import { FirstName } from "./FirstName"; |
| 65 | +import { LastName } from "./LastName"; |
| 66 | + |
| 67 | +const SignInCanal = createCanal([ |
| 68 | + { name: "firstName", Component: FirstName }, |
| 69 | + { name: "lastName", Component: LastName }, |
| 70 | + { name: "confirm", Component: Confirm, isFullScreen: true } |
| 71 | +]); |
| 72 | +``` |
| 73 | + |
| 74 | +In order to render the full screen page at the top level in your app, add the `FullScreenPortal` at the top level in your rendering tree. |
| 75 | + |
| 76 | +```ts |
| 77 | +import React, { Component } from "react"; |
| 78 | +import { SignInCanal } from "./canals/SignIn"; |
| 79 | +import { FullScreenPortal } from "react-gondola"; |
| 80 | + |
| 81 | +export default class App extends Component { |
| 82 | + render() { |
| 83 | + return ( |
| 84 | + <FullScreenPortal> |
| 85 | + <SignInCanal firstName lastName confirm /> |
| 86 | + </FullScreenPortal> |
| 87 | + ); |
| 88 | + } |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +You are ready to use React-Gondola |
0 commit comments