mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
fix #17
* 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
This commit is contained in:
53
packages/react-bootstrap-table2-example/examples/basic/index.js
vendored
Normal file
53
packages/react-bootstrap-table2-example/examples/basic/index.js
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
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 } />;
|
||||
Reference in New Issue
Block a user