Skip to content

Commit 6a17947

Browse files
Fabian Kundevutran
Fabian Kunde
authored andcommitted
readme updated
1 parent 067b9c2 commit 6a17947

File tree

1 file changed

+64
-43
lines changed

1 file changed

+64
-43
lines changed

README.md

+64-43
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,71 @@
1-
React Off-Canvas
2-
=====
1+
# React Off-Canvas
32

43
Off-canvas menus for React.
54

65
## Installation
76

8-
````bash
7+
```bash
98
$ npm install --save react-offcanvas
10-
````
9+
```
1110

1211
## Usage
1312

1413
### Basic Usage
1514

16-
````jsx
17-
<OffCanvas width={300} transitionDuration={300} isMenuOpened={false} position={"left"}>
18-
<OffCanvasBody className={"my-body-class"} style={{fontSize: '18px'}}>
15+
```jsx
16+
<OffCanvas
17+
width={300}
18+
transitionDuration={300}
19+
isMenuOpened={false}
20+
position={"left"}
21+
>
22+
<OffCanvasBody className={"my-body-class"} style={{ fontSize: "18px" }}>
1923
This is the canvas body.
2024
</OffCanvasBody>
21-
<OffCanvasMenu className={"my-menu-class"} style={{fontWeight: 'bold'}}>
25+
<OffCanvasMenu className={"my-menu-class"} style={{ fontWeight: "bold" }}>
2226
This is the canvas menu.
2327
</OffCanvasMenu>
2428
</OffCanvas>
25-
````
29+
```
2630

2731
### Within An Application
2832

2933
You'll need to hook up your application to handle the state for toggling the menu. Check out the basic example below:
3034

31-
````js
32-
'use strict';
35+
```js
36+
"use strict";
3337

34-
import React, { Component } from 'react';
35-
import { OffCanvas, OffCanvasMenu, OffCanvasBody } from 'react-offcanvas';
38+
import React, { Component } from "react";
39+
import { OffCanvas, OffCanvasMenu, OffCanvasBody } from "react-offcanvas";
3640

3741
export default class App extends Component {
38-
3942
componentWillMount() {
4043
// sets the initial state
4144
this.setState({
4245
isMenuOpened: false
43-
})
46+
});
4447
}
4548

4649
render() {
4750
return (
48-
<OffCanvas width={300} transitionDuration={300} isMenuOpened={this.state.isMenuOpened} position={"right"}>
49-
<OffCanvasBody className={styles.bodyClass} style={{fontSize: '30px'}}>
51+
<OffCanvas
52+
width={300}
53+
transitionDuration={300}
54+
effect={"parallax"}
55+
isMenuOpened={this.state.isMenuOpened}
56+
position={"right"}
57+
>
58+
<OffCanvasBody
59+
className={styles.bodyClass}
60+
style={{ fontSize: "30px" }}
61+
>
5062
<p>This is the main body container.</p>
51-
<p><a href="#" onClick={this.handleClick.bind(this)}>Click here</a> to toggle the menu.</p>
63+
<p>
64+
<a href="#" onClick={this.handleClick.bind(this)}>
65+
Click here
66+
</a>{" "}
67+
to toggle the menu.
68+
</p>
5269
</OffCanvasBody>
5370
<OffCanvasMenu className={styles.menuClass}>
5471
<p>Placeholder content.</p>
@@ -58,7 +75,11 @@ export default class App extends Component {
5875
<li>Link 3</li>
5976
<li>Link 4</li>
6077
<li>Link 5</li>
61-
<li><a href="#" onClick={this.handleClick.bind(this)}>Toggle Menu</a></li>
78+
<li>
79+
<a href="#" onClick={this.handleClick.bind(this)}>
80+
Toggle Menu
81+
</a>
82+
</li>
6283
</ul>
6384
</OffCanvasMenu>
6485
</OffCanvas>
@@ -69,41 +90,41 @@ export default class App extends Component {
6990
// toggles the menu opened state
7091
this.setState({ isMenuOpened: !this.state.isMenuOpened });
7192
}
72-
7393
}
74-
````
94+
```
7595

7696
## Components
7797

7898
### `OffCanvas`
7999

80100
This is the main component you will be using to compose your body and menu.
81101

82-
| Prop | Type | Default | Description |
83-
| :--- | :--- | :--- | :--- |
84-
| `width` | `number` | 250 | The width of the menu and off-canvas transition. |
85-
| `transitionDuration` | `number` | 250 | The time in ms for the transition. |
86-
| `isMenuOpened` | `bool` | false | Is the menu opened or not. |
87-
| `position` | `string` | "left" | Position the menu to the "left" or "right". |
102+
| Prop | Type | Default | Description |
103+
| :------------------- | :------- | :------ | :-------------------------------------------------------- |
104+
| `width` | `number` | 250 | The width of the menu and off-canvas transition. |
105+
| `transitionDuration` | `number` | 250 | The time in ms for the transition. |
106+
| `isMenuOpened` | `bool` | false | Is the menu opened or not. |
107+
| `position` | `string` | "left" | Position the menu to the "left" or "right". |
108+
| `effect` | `string` | "push" | Position the menu to the "push", "overlay" or "parallax". |
88109

89110
### `OffCanvasBody`
90111

91-
| Prop | Type | Default | Description |
92-
| :--- | :--- | :--- | :--- |
93-
| `width` | `number` | 250 | The width of the menu and off-canvas transition. |
94-
| `transitionDuration` | `number` | 250 | The time in ms for the transition. |
95-
| `isMenuOpened` | `bool` | false | Is the menu opened or not. |
96-
| `position` | `string` | "left" | Position the menu to the "left" or "right". |
97-
| `className` | `string` | | Custom className for the element. |
98-
| `style` | `object` | | CSS style object for the element. |
112+
| Prop | Type | Default | Description |
113+
| :------------------- | :------- | :------ | :----------------------------------------------- |
114+
| `width` | `number` | 250 | The width of the menu and off-canvas transition. |
115+
| `transitionDuration` | `number` | 250 | The time in ms for the transition. |
116+
| `isMenuOpened` | `bool` | false | Is the menu opened or not. |
117+
| `position` | `string` | "left" | Position the menu to the "left" or "right". |
118+
| `className` | `string` | | Custom className for the element. |
119+
| `style` | `object` | | CSS style object for the element. |
99120

100121
### `OffCanvasMenu`
101122

102-
| Prop | Type | Default | Description |
103-
| :--- | :--- | :--- | :--- |
104-
| `width` | `number` | 250 | The width of the menu and off-canvas transition. |
105-
| `transitionDuration` | `number` | 250 | The time in ms for the transition. |
106-
| `isMenuOpened` | `bool` | false | Is the menu opened or not. |
107-
| `position` | `string` | "left" | Position the menu to the "left" or "right". |
108-
| `className` | `string` | | Custom className for the element. |
109-
| `style` | `object` | | CSS style object for the element. |
123+
| Prop | Type | Default | Description |
124+
| :------------------- | :------- | :------ | :----------------------------------------------- |
125+
| `width` | `number` | 250 | The width of the menu and off-canvas transition. |
126+
| `transitionDuration` | `number` | 250 | The time in ms for the transition. |
127+
| `isMenuOpened` | `bool` | false | Is the menu opened or not. |
128+
| `position` | `string` | "left" | Position the menu to the "left" or "right". |
129+
| `className` | `string` | | Custom className for the element. |
130+
| `style` | `object` | | CSS style object for the element. |

0 commit comments

Comments
 (0)