Skip to content

Commit 76f4795

Browse files
committed
add story for caption table for bootstrap4
1 parent ee829eb commit 76f4795

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react';
2+
3+
import BootstrapTable from 'react-bootstrap-table-next';
4+
import Code from 'components/common/code-block';
5+
import { productsGenerator } from 'utils/common';
6+
7+
const products = productsGenerator();
8+
9+
const columns = [{
10+
dataField: 'id',
11+
text: 'Product ID'
12+
}, {
13+
dataField: 'name',
14+
text: 'Product Name'
15+
}, {
16+
dataField: 'price',
17+
text: 'Product Price'
18+
}];
19+
20+
const sourceCode = `\
21+
import BootstrapTable from 'react-bootstrap-table-next';
22+
23+
const columns = [{
24+
dataField: 'id',
25+
text: 'Product ID'
26+
}, {
27+
dataField: 'name',
28+
text: 'Product Name'
29+
}, {
30+
dataField: 'price',
31+
text: 'Product Price'
32+
}];
33+
34+
const CaptionElement = () => <h3 style={{ borderRadius: '0.25em', textAlign: 'center', color: 'purple', border: '1px solid purple', padding: '0.5em' }}>Component as Header</h3>;
35+
36+
<BootstrapTable bootstrap4 keyField="id" data={ products } caption="Plain text header" columns={ columns } />
37+
38+
<BootstrapTable bootstrap4 keyField="id" data={ products } caption={<CaptionElement />} columns={ columns } />
39+
`;
40+
41+
const Caption = () => <h3 style={ { borderRadius: '0.25em', textAlign: 'center', color: 'purple', border: '1px solid purple', padding: '0.5em' } }>Component as Header</h3>;
42+
43+
export default () => (
44+
<div>
45+
<BootstrapTable bootstrap4 keyField="id" data={ products } caption="Plain text header" columns={ columns } />
46+
<BootstrapTable bootstrap4 keyField="id" data={ products } caption={ <Caption /> } columns={ columns } />
47+
<Code>{ sourceCode }</Code>
48+
</div>
49+
);

packages/react-bootstrap-table2-example/stories/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import TabIndexCellTable from 'examples/basic/tabindex-column';
1818

1919
// bootstrap 4
2020
import Bootstrap4DefaultSortTable from 'examples/bootstrap4/sort';
21+
import Bootstrap4CaptionTable from 'examples/bootstrap4/caption-table';
2122
import Bootstrap4RowSelectionTable from 'examples/bootstrap4/row-selection';
2223
import Bootstrap4PaginationTable from 'examples/bootstrap4/pagination';
2324
import Bootstrap4ColumnToggleTable from 'examples/bootstrap4/column-toggle';
@@ -268,6 +269,7 @@ storiesOf('Basic Table', module)
268269
storiesOf('Bootstrap 4', module)
269270
.addDecorator(bootstrapStyle(BOOTSTRAP_VERSION.FOUR))
270271
.add('Sort table with bootstrap 4', () => <Bootstrap4DefaultSortTable />)
272+
.add('Table Caption bootstrap 4', () => <Bootstrap4CaptionTable />)
271273
.add('Row selection table with bootstrap 4', () => <Bootstrap4RowSelectionTable />)
272274
.add('Pagination table with bootstrap 4', () => <Bootstrap4PaginationTable />)
273275
.add('Column Toggle with bootstrap 4', () => <Bootstrap4ColumnToggleTable />)

0 commit comments

Comments
 (0)