forked from dptools/dpdash
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebdb0e6
commit dc4e4c5
Showing
6 changed files
with
193 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React from 'react' | ||
import { | ||
Table as MuiTable, | ||
TableBody, | ||
TableCell, | ||
TableContainer, | ||
TableHead, | ||
TableRow, | ||
Paper, | ||
Box, | ||
TableSortLabel, | ||
} from '@mui/material' | ||
import { visuallyHidden } from '@mui/utils' | ||
import { SORT_DIRECTION, fontSize } from '../../../constants' | ||
|
||
function EnhancedTableHead(props) { | ||
const { sortDirection, sortProperty, onRequestSort, headCells } = props | ||
const createSortHandler = (property) => (event) => { | ||
onRequestSort(event, property) | ||
} | ||
|
||
return ( | ||
<TableHead> | ||
<TableRow> | ||
{headCells.map((headCell) => ( | ||
<TableCell | ||
key={headCell.dataProperty} | ||
sortDirection={ | ||
sortProperty === headCell.dataProperty ? sortDirection : false | ||
} | ||
sx={{ fontSize: fontSize[12], fontWeight: 400 }} | ||
> | ||
{headCell.sortable ? ( | ||
<TableSortLabel | ||
active={sortProperty === headCell.dataProperty} | ||
direction={ | ||
sortProperty === headCell.dataProperty | ||
? sortDirection | ||
: SORT_DIRECTION.ASC | ||
} | ||
onClick={createSortHandler(headCell.dataProperty)} | ||
> | ||
{headCell.label} | ||
{sortProperty === headCell.dataProperty ? ( | ||
<Box component="span" sx={visuallyHidden}> | ||
{sortDirection === SORT_DIRECTION.DESC | ||
? 'sorted descending' | ||
: 'sorted ascending'} | ||
</Box> | ||
) : null} | ||
</TableSortLabel> | ||
) : ( | ||
headCell.label | ||
)} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
) | ||
} | ||
|
||
const Table = (props) => { | ||
const { | ||
cellRenderer, | ||
data, | ||
headers, | ||
sortDirection, | ||
sortProperty, | ||
handleRequestSort, | ||
} = props | ||
|
||
return ( | ||
<TableContainer component={Paper}> | ||
<MuiTable size="small"> | ||
<EnhancedTableHead | ||
sortDirection={sortDirection} | ||
sortProperty={sortProperty} | ||
onRequestSort={handleRequestSort} | ||
headCells={headers} | ||
/> | ||
<TableBody> | ||
{data.map((rowData) => ( | ||
<TableRow> | ||
{headers.map((header) => ( | ||
<TableCell key={header.dataProperty}> | ||
{cellRenderer(rowData, header.dataProperty)} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</MuiTable> | ||
</TableContainer> | ||
) | ||
} | ||
|
||
export default Table |
149 changes: 62 additions & 87 deletions
149
views/components/VirtualTables/ParticipantsTable/index.jsx
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.MainLayout_container { | ||
display: flex; | ||
} | ||
|
||
.MainLayout_main { | ||
flex-shrink: 0; | ||
flex: 1; | ||
} |
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
Oops, something went wrong.