File tree Expand file tree Collapse file tree 5 files changed +112
-134
lines changed Expand file tree Collapse file tree 5 files changed +112
-134
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ import React from 'react';
3
3
import './styles.scss' ;
4
4
5
5
import Navigation from './Navigation' ;
6
- import DataGrid from './DataGrid ' ;
6
+ import Table from './Table ' ;
7
7
8
8
function App ( ) {
9
9
return (
10
10
< div className = "App" >
11
11
< Navigation />
12
- < DataGrid />
12
+ < Table />
13
13
</ div >
14
14
) ;
15
15
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { Table } from 'reactstrap' ;
3
+ import { useTable , useSortBy } from 'react-table' ;
4
+
5
+ function ReactTable ( { columns, data } ) {
6
+ const {
7
+ getTableProps,
8
+ getTableBodyProps,
9
+ headerGroups,
10
+ rows,
11
+ prepareRow,
12
+ } = useTable (
13
+ {
14
+ columns,
15
+ data,
16
+ } ,
17
+ useSortBy ,
18
+ ) ;
19
+
20
+ return (
21
+ < Table align = "center" { ...getTableProps ( ) } >
22
+ < thead >
23
+ { headerGroups . map ( headerGroup => (
24
+ < tr { ...headerGroup . getHeaderGroupProps ( ) } >
25
+ { headerGroup . headers . map ( column => (
26
+ < th { ...column . getHeaderProps ( column . getSortByToggleProps ( ) ) } >
27
+ { column . render ( 'Header' ) }
28
+ < span >
29
+ { column . isSorted ? ( column . isSortedDesc ? ' 🔽' : ' 🔼' ) : '' }
30
+ </ span >
31
+ </ th >
32
+ ) ) }
33
+ </ tr >
34
+ ) ) }
35
+ </ thead >
36
+
37
+ < tbody { ...getTableBodyProps ( ) } >
38
+ { rows . map ( row => {
39
+ prepareRow ( row ) ;
40
+ return (
41
+ < tr { ...row . getRowProps ( ) } >
42
+ { row . cells . map ( cell => {
43
+ return < td { ...cell . getCellProps ( ) } > { cell . render ( 'Cell' ) } </ td > ;
44
+ } ) }
45
+ </ tr >
46
+ ) ;
47
+ } ) }
48
+ </ tbody >
49
+ </ Table >
50
+ ) ;
51
+ }
52
+
53
+ export default ReactTable ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { Container , Row , Col } from 'reactstrap' ;
3
+ import ReactTable from '../ReactTable' ;
4
+
5
+ import questionList from '../../data' ;
6
+
7
+ import './styles.scss' ;
8
+
9
+ const Table = ( ) => {
10
+ const data = React . useMemo ( ( ) => questionList , [ ] ) ;
11
+
12
+ const columns = React . useMemo (
13
+ ( ) => [
14
+ {
15
+ Header : 'Name' ,
16
+ columns : [
17
+ {
18
+ Header : '#' ,
19
+ accessor : 'id' ,
20
+ } ,
21
+ {
22
+ Header : 'Question Name' ,
23
+ accessor : 'name' ,
24
+ } ,
25
+ {
26
+ Header : 'URL' ,
27
+ accessor : 'url' ,
28
+ } ,
29
+ {
30
+ Header : 'Pattern' ,
31
+ accessor : 'pattern' ,
32
+ } ,
33
+ {
34
+ Header : 'Companies' ,
35
+ accessor : 'companies' ,
36
+ } ,
37
+ ] ,
38
+ } ,
39
+ ] ,
40
+ [ ] ,
41
+ ) ;
42
+
43
+ return (
44
+ < Container className = "table" >
45
+ < Col >
46
+ < Row >
47
+ < Col >
48
+ < ReactTable columns = { columns } data = { data } />
49
+ </ Col >
50
+ </ Row >
51
+ </ Col >
52
+ </ Container >
53
+ ) ;
54
+ } ;
55
+
56
+ export default Table ;
Original file line number Diff line number Diff line change 1
- .datagrid {
2
- display : flex ;
3
- align-items : center ;
4
- justify-content : center ;
5
-
1
+ .table {
6
2
> .col {
7
3
padding : 100px 0 100px 0 ;
8
4
}
You can’t perform that action at this time.
0 commit comments