Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f9ccbd0

Browse files
chunming-cAllenFang
authored andcommitted
examples enhance
* 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
1 parent ae5c677 commit f9ccbd0

24 files changed

+129
-297
lines changed

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
],
7171
"testEnvironment": "node",
7272
"testMatch": [
73-
"**/test/*.js"
73+
"**/test/**/*.js"
7474
]
7575
}
7676
}

‎packages/react-bootstrap-table2-example/.storybook/webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ const sourcePath = path.join(__dirname, '../../react-bootstrap-table2/src');
44
const sourceStylePath = path.join(__dirname, '../../react-bootstrap-table2/style');
55
const storyPath = path.join(__dirname, '../stories');
66
const examplesPath = path.join(__dirname, '../examples');
7+
const srcPath = path.join(__dirname, '../src');
78
const aliasPath = {
89
examples: examplesPath,
9-
common: path.join(examplesPath, 'common'),
1010
stories: storyPath,
11+
src: srcPath,
12+
components: path.join(srcPath, 'components'),
13+
utils: path.join(srcPath, 'utils'),
1114
};
1215

1316
const loaders = [{

‎packages/react-bootstrap-table2-example/examples/basic/borderless-table.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
import React from 'react';
22

33
import { BootstrapTableful } from 'react-bootstrap-table2';
4-
import Code from 'common/codeBlock';
4+
import Code from 'components/common/code-block';
5+
import { productsGenerator } from 'utils/common';
56

6-
const products = [];
7-
8-
function addProducts(quantity) {
9-
const startId = products.length;
10-
for (let i = 0; i < quantity; i += 1) {
11-
const id = startId + i;
12-
products.push({
13-
id,
14-
name: `Item name ${id}`,
15-
price: 2100 + i
16-
});
17-
}
18-
}
19-
20-
addProducts(5);
7+
const products = productsGenerator();
218

229
const columns = [{
2310
dataField: 'id',

‎packages/react-bootstrap-table2-example/examples/basic/index.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
import React from 'react';
22

33
import { BootstrapTableful } from 'react-bootstrap-table2';
4-
import Code from 'common/codeBlock';
4+
import Code from 'components/common/code-block';
5+
import { productsGenerator } from 'utils/common';
56

6-
const products = [];
7-
8-
function addProducts(quantity) {
9-
const startId = products.length;
10-
for (let i = 0; i < quantity; i += 1) {
11-
const id = startId + i;
12-
products.push({
13-
id,
14-
name: `Item name ${id}`,
15-
price: 2100 + i
16-
});
17-
}
18-
}
19-
20-
addProducts(5);
7+
const products = productsGenerator();
218

229
const columns = [{
2310
dataField: 'id',

‎packages/react-bootstrap-table2-example/examples/basic/no-data-table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
import { BootstrapTableful } from 'react-bootstrap-table2';
4-
import Code from 'common/codeBlock';
4+
import Code from 'components/common/code-block';
55

66
const columns = [{
77
dataField: 'id',

‎packages/react-bootstrap-table2-example/examples/basic/striped-hover-condensed-table.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
import React from 'react';
22

33
import { BootstrapTableful } from 'react-bootstrap-table2';
4-
import Code from 'common/codeBlock';
4+
import Code from 'components/common/code-block';
5+
import { productsGenerator } from 'utils/common';
56

6-
const products = [];
7-
8-
function addProducts(quantity) {
9-
const startId = products.length;
10-
for (let i = 0; i < quantity; i += 1) {
11-
const id = startId + i;
12-
products.push({
13-
id,
14-
name: `Item name ${id}`,
15-
price: 2100 + i
16-
});
17-
}
18-
}
19-
20-
addProducts(5);
7+
const products = productsGenerator();
218

229
const columns = [{
2310
dataField: 'id',

‎packages/react-bootstrap-table2-example/examples/columns/column-align-table.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,10 @@
22
import React from 'react';
33

44
import { BootstrapTableful } from 'react-bootstrap-table2';
5-
import Code from 'common/codeBlock';
5+
import Code from 'components/common/code-block';
6+
import { productsGenerator } from 'utils/common';
67

7-
const products = [];
8-
9-
function addProducts(quantity) {
10-
const startId = products.length;
11-
for (let i = 0; i < quantity; i += 1) {
12-
const id = startId + i;
13-
products.push({
14-
id,
15-
name: `Item name ${id}`,
16-
price: 2100 + i
17-
});
18-
}
19-
}
20-
21-
addProducts(5);
8+
const products = productsGenerator();
229

2310
const columns = [{
2411
dataField: 'id',

‎packages/react-bootstrap-table2-example/examples/columns/column-class-table.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,10 @@
22
import React from 'react';
33

44
import { BootstrapTableful } from 'react-bootstrap-table2';
5-
import Code from 'common/codeBlock';
5+
import Code from 'components/common/code-block';
6+
import { productsGenerator } from 'utils/common';
67

7-
const products = [];
8-
9-
function addProducts(quantity) {
10-
const startId = products.length;
11-
for (let i = 0; i < quantity; i += 1) {
12-
const id = startId + i;
13-
products.push({
14-
id,
15-
name: `Item name ${id}`,
16-
price: 2100 + i
17-
});
18-
}
19-
}
20-
21-
addProducts(5);
8+
const products = productsGenerator();
229

2310
const columns = [{
2411
dataField: 'id',

‎packages/react-bootstrap-table2-example/examples/columns/column-event-table.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,10 @@
33
import React from 'react';
44

55
import { BootstrapTableful } from 'react-bootstrap-table2';
6-
import Code from 'common/codeBlock';
6+
import Code from 'components/common/code-block';
7+
import { productsGenerator } from 'utils/common';
78

8-
const products = [];
9-
10-
function addProducts(quantity) {
11-
const startId = products.length;
12-
for (let i = 0; i < quantity; i += 1) {
13-
const id = startId + i;
14-
products.push({
15-
id,
16-
name: `Item name ${id}`,
17-
price: 2100 + i
18-
});
19-
}
20-
}
21-
22-
addProducts(5);
9+
const products = productsGenerator();
2310

2411
const columns = [{
2512
dataField: 'id',

‎packages/react-bootstrap-table2-example/examples/columns/column-format-table.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
import React from 'react';
22

33
import { BootstrapTableful } from 'react-bootstrap-table2';
4-
import Code from 'common/codeBlock';
4+
import Code from 'components/common/code-block';
5+
import { productsGenerator } from 'utils/common';
56

6-
const products = [];
7-
8-
function addProducts(quantity) {
9-
const startId = products.length;
10-
for (let i = 0; i < quantity; i += 1) {
11-
const id = startId + i;
12-
products.push({
13-
id,
14-
name: `Item name ${id}`,
15-
price: 2100 + i,
16-
onSale: Math.random() >= 0.5
17-
});
18-
}
19-
}
20-
21-
addProducts(5);
7+
const products = productsGenerator();
228

239
function priceFormatter(cell, row) {
2410
if (row.onSale) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /