mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
fix #77
* 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:
47
packages/react-bootstrap-table2-example/examples/basic/table-with-caption.js
vendored
Normal file
47
packages/react-bootstrap-table2-example/examples/basic/table-with-caption.js
vendored
Normal 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>
|
||||
);
|
||||
Reference in New Issue
Block a user