mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
* storybook environment setup * customized loader * add basic example of BasicTable * add script to bootstrap storybook * import bootstrap css for storybook * update webpack.config for adding loader for font and css * add sass loader and allow to customize css for storybook * uncheck lint for react-bootstrap-table-example * package example has its own lint check * run yarn in each package when boostrapping lerna * add peerDependencies for package example
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
|
|
import { BootstrapTable } from 'react-bootstrap-table2';
|
|
|
|
const products = [];
|
|
|
|
function addProducts(quantity) {
|
|
const startId = products.length;
|
|
for (let i = 0; i < quantity; i += 1) {
|
|
const id = startId + i;
|
|
products.push({
|
|
id,
|
|
name: `Item name ${id}`,
|
|
price: 2100 + i,
|
|
nest: {
|
|
address: 'Address 1',
|
|
postcal: '0922-1234'
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
addProducts(5);
|
|
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'Product ID',
|
|
style: {
|
|
backgroundColor: 'red'
|
|
},
|
|
headerTitle: (column, colIndex) => 'yes~~~ oh', // eslint-disable-line no-unused-vars
|
|
classes: 'my-xxx'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name',
|
|
headerTitle: true,
|
|
formatter: (cell, row) =>
|
|
(<h3>{ cell }::: ${ row.price }</h3>)
|
|
}, {
|
|
dataField: 'price',
|
|
text: 'Product Price',
|
|
style: (cell, row, colIndex) => ({ // eslint-disable-line no-unused-vars
|
|
backgroundColor: 'blue'
|
|
})
|
|
}, {
|
|
dataField: 'nest.address',
|
|
text: 'Address'
|
|
}, {
|
|
dataField: 'nest.postcal',
|
|
text: 'Postal'
|
|
}];
|
|
|
|
export default () => <BootstrapTable keyField="id" data={ products } columns={ columns } />;
|