* Implement basic usage of table <caption> element

Add tableCaption prop, which can be a component / string

Add simple test and an example to Storybook

* Fix Caption example & Code syle fix for return statement

* Rename tableCaption > caption
This commit is contained in:
Esa Juhana
2017-10-10 10:10:54 +03:00
committed by Allen
parent 7760d6a7f8
commit 3d6a293e5e
5 changed files with 87 additions and 2 deletions

View File

@@ -0,0 +1,47 @@
import React from 'react';
import { BootstrapTableful } from 'react-bootstrap-table2';
import Code from 'components/common/code-block';
import { productsGenerator } from 'utils/common';
const products = productsGenerator();
const columns = [{
dataField: 'id',
text: 'Product ID'
}, {
dataField: 'name',
text: 'Product Name'
}, {
dataField: 'price',
text: 'Product Price'
}];
const sourceCode = `\
const columns = [{
dataField: 'id',
text: 'Product ID'
}, {
dataField: 'name',
text: 'Product Name'
}, {
dataField: 'price',
text: 'Product Price'
}];
const CaptionElement = () => <h3 style={{ borderRadius: '0.25em', textAlign: 'center', color: 'purple', border: '1px solid purple', padding: '0.5em' }}>Component as Header</h3>;
<BootstrapTableful keyField="id" data={ products } caption="Plain text header" columns={ columns } />
<BootstrapTableful keyField="id" data={ products } caption={<CaptionElement />} columns={ columns } />
`;
const Caption = () => <h3 style={{ borderRadius: '0.25em', textAlign: 'center', color: 'purple', border: '1px solid purple', padding: '0.5em' }}>Component as Header</h3>;
export default () => (
<div>
<BootstrapTableful keyField="id" data={ products } caption="Plain text header" columns={ columns } />
<BootstrapTableful keyField="id" data={ products } caption={<Caption />} columns={ columns } />
<Code>{ sourceCode }</Code>
</div>
);