Skip to content

Commit 9917c11

Browse files
authored
Optimized components, new styling api and other fixes (#5)
* Removed redundant code * Fixed styled-components generating several classes. * Table styling * Updated styles * Updated styles * For optimization * Added styling * Complete styling api * Update README.md * Update README.md * 0.2.0 * Added Codacy badge
1 parent 46b28bb commit 9917c11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1378
-1544
lines changed

.babelrc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"presets": [
3+
[
4+
"/Users/eon/Documents/GitHub/redux-datatable/node_modules/babel-preset-env/lib/index.js",
5+
{
6+
"loose": true,
7+
"modules": false
8+
}
9+
],
10+
"/Users/eon/Documents/GitHub/redux-datatable/node_modules/babel-preset-react/lib/index.js",
11+
"/Users/eon/Documents/GitHub/redux-datatable/node_modules/babel-preset-stage-1/lib/index.js"
12+
],
13+
"plugins": [
14+
"/Users/eon/Documents/GitHub/redux-datatable/node_modules/babel-plugin-transform-decorators-legacy/lib/index.js",
15+
[
16+
"/Users/eon/Documents/GitHub/redux-datatable/node_modules/babel-plugin-transform-react-remove-prop-types/lib/index.js",
17+
{
18+
"mode": "wrap"
19+
}
20+
],
21+
[
22+
"/Users/eon/Documents/GitHub/redux-datatable/node_modules/babel-plugin-transform-runtime/lib/index.js",
23+
{
24+
"helpers": false,
25+
"polyfill": false,
26+
"regenerator": true
27+
}
28+
]
29+
],
30+
"ignore": [
31+
".spec.js",
32+
".test.js",
33+
"-test.js",
34+
"/__tests__/"
35+
]
36+
}

README.md

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[Developed by Flipbyte](https://www.flipbyte.com/)
44

55
[![npm package][npm-badge]][npm]
6+
[![Codacy Badge][codacy-badge]][codacy]
67

78
Datatable built using React and Redux to fetch JSON data asynchronously using REST API.
89

@@ -46,33 +47,30 @@ import { reducer, epics } from '@flipbyte/redux-datatable';
4647
name: 'your_table_name', // this is the key used to set your table data inside the table reducer
4748
height: 500,
4849
rowHeight: 50,
49-
pagination: {
50-
items: [{
51-
type: 'limiter',
52-
visible: true,
53-
position: 10,
54-
options: [10, 20, 50, 200, 2000],
55-
default: 200,
56-
style: {
57-
right: false,
58-
}
59-
}, {
60-
type: 'pages',
61-
visible: true,
62-
position: 20,
63-
style: {
50+
pagination: {
51+
// visible: true, // or an object { top: true, bottom: false } default visible
52+
items: {
53+
limiter: {
54+
type: 'limiter',
55+
visible: true,
56+
position: 10,
57+
options: [10, 20, 50, 200, 2000],
58+
default: 200,
59+
},
60+
pages: {
61+
type: 'pages',
62+
visible: true,
63+
position: 20,
6464
right: true,
65-
}
66-
}, {
67-
type: 'resultCount',
68-
visible: true,
69-
position: 30,
70-
style: {
71-
width: '350px',
72-
textAlign: 'center',
73-
}
74-
}]
75-
},
65+
},
66+
resultCount: {
67+
type: 'resultCount',
68+
visible: true,
69+
position: 30,
70+
right: true,
71+
},
72+
}
73+
},
7674
routes: { // You can add other routes and handle them using custom actions.
7775
get: { // The route used to fetch data and it's params
7876
route: '/{your_route}',
@@ -95,9 +93,6 @@ import { reducer, epics } from '@flipbyte/redux-datatable';
9593
label: 'Columns',
9694
visible: true,
9795
state: false,
98-
style: {
99-
right: true
100-
}
10196
},
10297
...
10398
]
@@ -199,29 +194,24 @@ const YourComponent = () =>
199194
| routes | object | true | - | Routes definition to fetch data and other custom routes config for custom handling (Check below) |
200195
| toolbar | array | false | [] | Toolbar definition (Check below) |
201196
| columns | array | true | - | Columns to display |
197+
| styles | object | false | {} | Custom styles for your table |
202198

203199
#### Pagination object
204200

205201
| Key | Type | Required | Default | Description |
206202
| ------------ | ------------ | ------------ | ------------ | ------------ |
207-
| items | array | false | [] | Array of item objects available for display in the pagination bar. Check below for items available |
203+
| items | object | false | {} | Items available for display in the pagination bar. Check below for items available |
208204
| visible | boolean/object | false | true | Whether the pagination is visible or not |
209205

210-
##### Pagination items array:
206+
##### Pagination items object:
211207

212208
| Key | Type | Required | Default | Description |
213209
| ------------ | ------------ | ------------ | ------------ | ------------ |
214210
| type | string | true | - | One of the following: limiter, pages, resultCount |
215211
| visible | boolean | false | true | Whether the item is visible |
216-
| style | object | false | {} | Stylable properties |
217212
| **Limiter specific options** | | | | |
218213
| options | array | true | - | Array of integers with limiter options |
219214
| default | array | true | - | One of the values in the limiter options key |
220-
| **- style** | | | | |
221-
| right | boolean | false | false | Align the item to the right |
222-
| width | integer | false | 200 | Width of the item |
223-
| textAlign | string | false | left | Align the text of the item to the right, left or center|
224-
| fontSize | string | false | 14 | The font size of the text in the item |
225215

226216
#### Routes object
227217

@@ -244,18 +234,13 @@ Toolbar config is an array of array of object where objects are the toolbar item
244234
| label | string | true | - | Label for the toolbar item |
245235
| visible | boolean | false | true | Whether the item is visible |
246236
| state | boolean | false | false | Whether to pass the state object as item prop |
247-
| style | object | false | {} | Define toolbar item styles |
248237
| **For type: actions** | | | | |
249238
| options | array | true | - | Array of option objects |
250239
| **-- options** | | | | |
251240
| type | string | true | action | Available option: action |
252241
| name | string | true | - | Unique name for the action |
253242
| label | string | true | - | Label for the action |
254243
| thunk | function | true | - | An action creator which is dispatched on action click. Check demo schema. |
255-
| **- styles** | | | | |
256-
| right | boolean | false | false | Align the item to the right |
257-
| width | integer | false | 200 | Width of the item |
258-
| fontSize | string | false | 14 | The font size of the text in the item |
259244

260245
#### Columns object
261246

@@ -276,8 +261,29 @@ Toolbar config is an array of array of object where objects are the toolbar item
276261
| label | string | true | - | Label for the action |
277262
| thunk | function | true | - | An action creator which is dispatched on action click. Check demo schema. |
278263

264+
#### Styles object
265+
266+
Styles has the following properties avaailable:
267+
268+
| Key | Type | Required | Default | Description |
269+
| ------------ | ------------ | ------------ | ------------ | ------------ |
270+
| tableContainer | styled-components style object | false | - | Outer table container |
271+
| table | styled-components style object | false | - | Table component |
272+
| thead | styled-components style object | false | - | Table header component |
273+
| tbody | styled-components style object | false | - | Table body component |
274+
| tr | object | false | - | Table rows - the object can contain the following keys `header`, `filter`, `body`, each of whose values is a styled-components style object| |
275+
| th | styled-components style object | false | - | Table header columns |
276+
| td | object | false | - | Table columns - the object contain the following keys `filter`, `body` whose value is a styled-components style object |
277+
| toolbar | object | false | - | Keys `container` and `row` which are styled-components style object and `item` which is an object with keys that are the names of the respective items (as defined in the config) and the value is a styled-components style object |
278+
| pagination | object | false | - | Keys `container` - a styled-components style object and `item` - same as above toolbar item |
279+
| filter | object | false | - | Each key is the name of the column and the value is the styled-components style object |
280+
| body | object | false | - | Same as `filter` (above) |
281+
279282
## License
280283
The MIT License (MIT)
281284

282285
[npm-badge]: https://img.shields.io/npm/v/@flipbyte/redux-datatable.svg
283286
[npm]: https://www.npmjs.com/package/@flipbyte/redux-datatable
287+
288+
[codacy-badge]: https://api.codacy.com/project/badge/Grade/67274650b4874f5db55ede76156ab4d2
289+
[codacy]: https://www.codacy.com/app/flipbyte/redux-datatable?utm_source=github.com&utm_medium=referral&utm_content=flipbyte/redux-datatable&utm_campaign=Badge_Grade

demo/src/css/simple-sidebar.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ body {
3838

3939
.content {
4040
position: fixed;
41-
overflow: scroll;
41+
overflow: hidden;
4242
height: 100%;
4343
top: 60px;
4444
}
@@ -54,7 +54,7 @@ body {
5454

5555
#page-content-wrapper {
5656
min-width: 0;
57-
width: 100%;
57+
/* width: 100%; */
5858
margin-left: 15rem;
5959
}
6060

demo/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Provider } from 'react-redux';
66
import configureStore from './store';
77
import config from './config';
88

9-
import '../../node_modules/bootstrap/dist/css/bootstrap.css';
9+
// import '../../node_modules/bootstrap/dist/css/bootstrap.css';
1010
import './css/simple-sidebar.css';
1111
import './css/styles.css';
1212

0 commit comments

Comments
 (0)