Skip to content

Commit d95444d

Browse files
committed
feat: 🎸 improve <ListTable> and add reference to docs
1 parent 66fad9b commit d95444d

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const MyComponent = mock();
9494
- [`<OutsideClick>`](./docs/en/OutsideClick.md)
9595
- [`<Ripple>`](./docs/en/Ripple.md) and [`withRipple()`](./docs/en/Ripple.md#withripple) &mdash; [**example**](https://codesandbox.io/s/983q7jr80o)
9696
- [`<Img>`](./docs/en/Img.md)
97+
- [`<ListTable>`](./docs/en/ListTable.md)
9798
- [`<WidthQuery>`](./docs/en/WidthQuery.md), [`<View>`](./docs/en/View.md), [`<WindowWidthQuery>`](./docs/en/WindowWidthQuery.md), and [`<InlineWidthQuery>`](./docs/en/InlineWidthQuery.md)
9899
- [`<Audio>`](./docs/en/Audio.md) and [`<Video>`](./docs/en/Video.md)
99100
- [`<Speak>`](./docs/en/Speak.md), [`<Vibrate>`](./docs/en/Vibrate.md), [`<Alert>`](./docs/en/Alert.md)

‎docs/en/ListTable.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# `<ListTable>`
2+
3+
Wraps `children` into a table with specified column number.
4+
5+
## Usage
6+
7+
Below renders 2x3 table.
8+
9+
```jsx
10+
import {ListTable} from 'libreact/lib/ListTable';
11+
12+
<ListTable cols={2}>
13+
<div>1</div>
14+
<div>2</div>
15+
<div>3</div>
16+
<div>4</div>
17+
<div>5</div>
18+
<div>6</div>
19+
</ListTable>
20+
```
21+
22+
23+
## Props
24+
25+
- `cols` &mdash; optional, number or columns table should have, defaults to `3`.
26+
- `renderRow` &mdash; optional, function that receives an array of `<td>` cells as React
27+
elements and should return a `<tr>` React element, defaults to `cells => h('tr', null, ...cells)`.

‎docs/en/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
- [`<OutsideClick>`](./OutsideClick.md)
6161
- [`<Ripple>`](./Ripple.md) and [`withRipple()`](./Ripple.md#withripple) &mdash; [**example**](https://codesandbox.io/s/983q7jr80o)
6262
- [`<Img>`](./Img.md)
63+
- [`<ListTable>`](./ListTable.md)
6364
- [`<WidthQuery>`](./WidthQuery.md), [`<View>`](./View.md), [`<WindowWidthQuery>`](./WindowWidthQuery.md), and [`<InlineWidthQuery>`](./InlineWidthQuery.md)
6465
- [`<Audio>`](./Audio.md) and [`<Video>`](./Video.md)
6566
- [`<Speak>`](./Speak.md), [`<Vibrate>`](./Vibrate.md), [`<Alert>`](./Alert.md), `<Prompt>`, `<Confirm>`

‎docs/en/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
* [OutsideClick](OutsideClick.md)
6969
* [Ripple](Ripple.md)
7070
* [Img](Img.md)
71+
* [ListTable](ListTable.md)
7172
* [Group](Group.md)
7273
* [InfiniteScroll](InfiniteScroll.md)
7374
* [WidthQuery](WidthQuery.md)

‎src/ListTable/__story__/story.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {ListTable} from '..';
44
import ShowDocs from '../../ShowDocs'
55

66
storiesOf('UI/ListTable', module)
7-
// .add('Documentation', () => h(ShowDocs, {md: require('../../../docs/en/ListTable.md')}))
7+
.add('Documentation', () => h(ShowDocs, {md: require('../../../docs/en/ListTable.md')}))
88
.add('Default', () =>
99
<ListTable>
1010
<div>1</div>

‎src/ListTable/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ const h = React.createElement;
44

55
const defaultRenderRow = cells => h('tr', null, ...cells);
66

7-
export interface Props {
7+
export interface Props extends React.AllHTMLAttributes<any> {
88
cols?: number;
99
renderRow?: (cells: React.ReactElement<any>[]) => React.ReactElement<any>;
1010
}
1111

12-
export const ListTable: React.SFC<Props> = ({cols, renderRow, children}) => {
12+
export const ListTable: React.SFC<Props> = ({cols, renderRow, children, ...rest}) => {
1313
const list = React.Children.toArray(children);
1414
const rows: React.ReactElement<any>[] = [];
1515
const length = list.length;
@@ -25,7 +25,7 @@ export const ListTable: React.SFC<Props> = ({cols, renderRow, children}) => {
2525
rows.push(renderRow(cells));
2626
}
2727

28-
return h('table', null, h('tbody', null,
28+
return h('table', rest, h('tbody', null,
2929
...rows,
3030
));
3131
};

0 commit comments

Comments
 (0)