mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
* utils for products generator * load test for each *.test.js file in packages folder * [test] unit test for utils/common * refactor all products with productGenerator for all examples * refactor folder structure * move component <Code /> to src/components/common * rename component file name
60 lines
1.1 KiB
JavaScript
60 lines
1.1 KiB
JavaScript
/* eslint no-unused-vars: 0 */
|
|
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();
|
|
|
|
function priceFormatter(column, colIndex) {
|
|
return (
|
|
<h5><strong>$$ { column.text } $$</strong></h5>
|
|
);
|
|
}
|
|
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'Product ID'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name'
|
|
}, {
|
|
dataField: 'price',
|
|
text: 'Product Price',
|
|
headerFormatter: priceFormatter
|
|
}];
|
|
|
|
const sourceCode = `\
|
|
function priceFormatter(column, colIndex) {
|
|
return (
|
|
<h5><strong>$$ { column.text } $$</strong></h5>
|
|
);
|
|
}
|
|
|
|
const columns = [
|
|
// omit...
|
|
{
|
|
dataField: 'price',
|
|
text: 'Product Price',
|
|
headerFormatter: priceFormatter
|
|
}];
|
|
|
|
<BootstrapTableful
|
|
keyField="id"
|
|
data={ products }
|
|
columns={ columns }
|
|
/>
|
|
`;
|
|
|
|
export default () => (
|
|
<div>
|
|
<BootstrapTableful
|
|
keyField="id"
|
|
data={ products }
|
|
columns={ columns }
|
|
/>
|
|
<Code>{ sourceCode }</Code>
|
|
</div>
|
|
);
|