Skip to content

Commit 785cfa2

Browse files
committed
update readme
1 parent 3f410d7 commit 785cfa2

File tree

3 files changed

+107
-4
lines changed

3 files changed

+107
-4
lines changed

README.md

+103
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cht8687/help)
33

44
<big><h1 align="center">React expandable listview</h1></big>
5+
<h2 align="center">Rend components or plain object in an expandable way!</h2>
56

67
<p align="center">
78
<a href="https://circleci.com/gh/cht8687/react-expandable-listview">
@@ -83,11 +84,16 @@ The component accepts three props.
8384

8485
#### `data`: PropTypes.array.isRequired
8586

87+
* note that `isReactComponent` is used to select if you want to render a react object or not.
88+
89+
### Render plain object
90+
8691
```js
8792
const DATALIST = [
8893
{
8994
headerName : "ListG",
9095
isOpened: true,
96+
isReactComponent: false,
9197
items : [{
9298
title : "items1"
9399
}, {
@@ -105,6 +111,7 @@ const DATALIST = [
105111
},{
106112
headerName : "ListH",
107113
isOpened: true,
114+
isReactComponent: false,
108115
items : [{
109116
title : "items1"
110117
}, {
@@ -117,6 +124,102 @@ const DATALIST = [
117124
];
118125
```
119126

127+
### Render react component
128+
129+
If you want to render a react component, for example, a menu object, you can set `isReactComponent` to `true`:
130+
131+
```js
132+
export default class Menu extends React.Component {
133+
static get menuItems() {
134+
return [
135+
{
136+
headerName: 'Products',
137+
isOpened: false,
138+
height: 100,
139+
isReactComponent: true,
140+
items: [
141+
(
142+
<Link
143+
to="admin/products/all"
144+
className="btn btn-default"
145+
activeClassName="active"
146+
>
147+
All
148+
</Link>
149+
),
150+
(
151+
<Link
152+
to="admin/products/expired"
153+
className="btn btn-default"
154+
activeClassName="active"
155+
>
156+
Expired
157+
</Link>
158+
),
159+
(
160+
<Link
161+
to="admin/products/submitted"
162+
className="btn btn-default"
163+
activeClassName="active"
164+
>
165+
Submitted
166+
</Link>
167+
),
168+
],
169+
},
170+
{
171+
headerName: 'Promotions',
172+
isOpened: false,
173+
height: 100,
174+
isReactComponent: true,
175+
items: [
176+
(
177+
<Link
178+
to="admin/promotions/active"
179+
className="btn btn-default"
180+
activeClassName="active"
181+
>
182+
Active
183+
</Link>
184+
),
185+
],
186+
},
187+
{
188+
headerName: 'Settings',
189+
isOpened: false,
190+
height: 100,
191+
isReactComponent: true,
192+
items: [
193+
(
194+
<Link
195+
to="admin/settings/all"
196+
className="btn btn-default"
197+
activeClassName="active"
198+
>
199+
Al
200+
</Link>
201+
),
202+
],
203+
},
204+
];
205+
}
206+
207+
render() {
208+
return (
209+
<div id="admin-menu">
210+
<ReactExpandableListView
211+
data={this.constructor.menuItems}
212+
headerAttName="headerName"
213+
itemsAttName="items"
214+
/>
215+
</div>
216+
);
217+
}
218+
}
219+
220+
```
221+
222+
120223
Note `height` varible defines the height you want each list to be like.
121224
You can set different height data to suit the content of each section.
122225

src/example/const.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const DATA = [
22
{
33
headerName: 'ListA',
44
isOpened: true,
5-
isReactComponent: false,
5+
// isReactComponent: false,
66
items: [{
77
title: 'items1'
88
},
@@ -26,7 +26,7 @@ export const DATA = [
2626
{
2727
headerName: 'ListB is bravo',
2828
isOpened: true,
29-
isReactComponent: false,
29+
// isReactComponent: false,
3030
items: [{
3131
title: 'items1'
3232
},
@@ -50,7 +50,7 @@ export const DATA = [
5050
{
5151
headerName: 'ListC is Charlie',
5252
isOpened: true,
53-
isReactComponent: false,
53+
// isReactComponent: false,
5454
items: [{
5555
title: 'items1'
5656
},

src/lib/ListItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default class ListItem extends React.Component {
77
isReactComponent: React.PropTypes.bool
88
};
99
}
10-
10+
1111
render () {
1212
const { isReactComponent } = this.props;
1313
return (

0 commit comments

Comments
 (0)