-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from HybridFox/feature/table
Feature/table
- Loading branch information
Showing
26 changed files
with
1,526 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,4 +131,4 @@ class Body extends Component { | |
) | ||
} | ||
} | ||
export default Body; | ||
export default Body; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
|
||
### Full example | ||
Full fledged table: | ||
```js | ||
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js'); | ||
|
||
const [sorting, setSorting] = React.useState(); | ||
const [pagination, setPagination] = React.useState({ | ||
itemsPerPage: 10, | ||
totalItems: 1829, | ||
currentPage: 1 | ||
}); | ||
|
||
<Table | ||
tableId="1" | ||
columns={TABLE_MOCK_COLUMNS()} | ||
rows={TABLE_MOCK_ROWS.slice(0, 10)} | ||
filters={TABLE_MOCK_FILTER} | ||
sorting={sorting} | ||
sortingChanged={(e) => console.log('sorting changed', e) || setSorting(e)} | ||
paginationChanged={(e) => console.log('pagination changed', e) || setPagination(e)} | ||
filtersChanged={(e) => console.log('filters changed', e)} | ||
itemsPerPage={pagination.itemsPerPage} | ||
totalItems={pagination.totalItems} | ||
currentPage={pagination.currentPage} | ||
/> | ||
``` | ||
|
||
### Filter examples | ||
Filters values: | ||
|
||
| Key | Value | Description | | ||
|-------------|-----------------------------------------------------------|------------------------------------------------------------------| | ||
| id | _string_ | ID to identify the filter when returning data | | ||
| display | "generic" / "optional" | "generic" to show as the main filter, "optional" if the filter should appear under the extra filter dropdown | | ||
| type | "input" / "datepicker" / "select" / "telephone-number" | Type of field to show | | ||
| label | _string_ | Label of the field | | ||
| placeholder | _string_ | Placeholder of the field | | ||
| options | _{ id: string; label: string; }[]_ | Options to use if "select" type | | ||
|
||
Table with only 1 `generic` filter: | ||
```js static | ||
const FILTERS = [{ | ||
id: "smartfilter", | ||
display: "generic", | ||
type: "input", | ||
label: "Zoek op voornaam", | ||
placeholder: "Zoek op voornaam", | ||
}] | ||
``` | ||
|
||
```js | ||
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js'); | ||
|
||
<Table | ||
tableId="1" | ||
columns={TABLE_MOCK_COLUMNS()} | ||
rows={TABLE_MOCK_ROWS.slice(0, 2)} | ||
filters={[{ | ||
id: "smartfilter", | ||
display: "generic", | ||
type: "input", | ||
label: "Zoek op voornaam", | ||
placeholder: "Zoek op voornaam", | ||
}]} | ||
/> | ||
``` | ||
|
||
Only optional filters: | ||
```js static | ||
const FILTERS = [{ | ||
id: "firstName", | ||
type: "input", | ||
label: "Zoek op voornaam", | ||
placeholder: "Zoek op voornaam", | ||
}, { | ||
id: "lastName", | ||
type: "input", | ||
label: "Zoek op achternaam", | ||
placeholder: "Zoek op achternaam", | ||
}] | ||
``` | ||
|
||
```js | ||
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js'); | ||
|
||
<Table | ||
tableId="1" | ||
columns={TABLE_MOCK_COLUMNS()} | ||
rows={TABLE_MOCK_ROWS.slice(0, 2)} | ||
filters={[{ | ||
id: "firstName", | ||
type: "input", | ||
label: "Zoek op voornaam", | ||
placeholder: "Zoek op voornaam", | ||
}, { | ||
id: "lastName", | ||
type: "input", | ||
label: "Zoek op achternaam", | ||
placeholder: "Zoek op achternaam", | ||
}]} | ||
/> | ||
``` | ||
|
||
### State examples | ||
Loading table | ||
```js | ||
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS } = require('./src/mocks/Table.mock.js'); | ||
|
||
<Table tableId="2" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 5)} loading={true} /> | ||
``` | ||
|
||
Without column sorting | ||
```js | ||
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS } = require('./src/mocks/Table.mock.js'); | ||
|
||
<Table tableId="2" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 2)} disableColumnSorting={true} /> | ||
``` | ||
|
||
Styles | ||
```js | ||
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS } = require('./src/mocks/Table.mock.js'); | ||
|
||
<> | ||
<div className="u-margin-bottom"> | ||
<Table tableId="3" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 4)} striped={false} /> | ||
</div> | ||
|
||
<div className="u-margin-bottom"> | ||
<Table tableId="4" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 2)} type="primary" /> | ||
</div> | ||
|
||
<Table tableId="5" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 2)} type="secondary" /> | ||
</> | ||
``` | ||
|
||
Extra table actions | ||
```js | ||
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js'); | ||
const Button = require('../button').default; | ||
|
||
<Table | ||
tableId="5" | ||
columns={TABLE_MOCK_COLUMNS()} | ||
rows={TABLE_MOCK_ROWS.slice(0, 2)} | ||
extraTableActions={( | ||
<Button icon="ai-pencil-1" className="u-margin-right-xs" /> | ||
)} | ||
filters={TABLE_MOCK_FILTER} | ||
/> | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "table", | ||
"version": "0.0.1-0", | ||
"description": "", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"rc-slider": "~8.6.1", | ||
"classnames": "~2.2.6", | ||
"moment": "^2.24.0", | ||
"react-input-mask": "^2.0.4", | ||
"icon": "0.0.1-0" | ||
} | ||
} |
Oops, something went wrong.