Skip to content

Commit

Permalink
added truncated table cells
Browse files Browse the repository at this point in the history
  • Loading branch information
hams7504 committed Nov 2, 2023
1 parent 6784bb6 commit 399b71b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/components/CollapsibleTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ const table = {
data: [
{
value: 'Row 1, Cell 1',
truncate: true,
},
{
value: 'Row 1, Cell 2',
truncate: false,
},
{
value: 'Row 1, Cell 3',
truncate: false,
}
],
subtable: {
Expand Down Expand Up @@ -114,6 +117,22 @@ const StyledTableCell = styled(TableCell)(() => ({
},
}));

const TruncatedTableCell = styled(StyledTableCell)(() => ({
[`&.${tableCellClasses.root}`]: {
padding: '8px',
maxWidth: '20ch',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
transition: 'max-width 0.5s',
'&:hover': {
whiteSpace: 'normal',
overflow: 'normal',
wordBreak: 'break-all'
},
},
}));

const CollapsibleRow = (props) => {
const { row, row: { subtable: { rows: subrows } }, selected, selectHandler } = props;

Expand Down Expand Up @@ -145,9 +164,14 @@ const CollapsibleRow = (props) => {
</IconButton>
</StyledTableCell>
{row.data.map((cell, i) => (
<StyledTableCell key={i}>
{cell.value}
</StyledTableCell>
cell.truncate ?
(<TruncatedTableCell key={i}>
{cell.value}
</TruncatedTableCell>
) : (
<StyledTableCell key={i}>
{cell.value}
</StyledTableCell>)
))}
</TableRow>
{/* subtable */}
Expand Down
9 changes: 9 additions & 0 deletions src/components/data_search/DatasetSearchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,39 @@ export const DatasetSearchTable = (props) => {
data: [
{
value: entry[0].study.studyName,
truncate: true,
},
{
value: entry[0].study.description,
truncate: false,
},
{
value: entry.length,
truncate: true,
},
{
value: isNaN(sum) ? undefined : sum,
truncate: true,
},
{
value: entry[0].study.phenotype,
truncate: true,
},
{
value: entry[0].study.species,
truncate: true,
},
{
value: entry[0].study.piName,
truncate: true,
},
{
value: entry[0].study.dataSubmitterEmail,
truncate: true,
},
{
value: entry[0].study.dataCustodianEmail.join(', '),
truncate: true,
},
],
subtable: {
Expand Down

0 comments on commit 399b71b

Please sign in to comment.