Files
ohif-viewer/platform/ui/src/components/StudyListTable/StudyListTableRow.js
T

97 lines
3.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Icon } from '@ohif/ui';
const StudyListTableRow = props => {
const { tableData } = props;
const { row, expandedContent, onClickRow, isExpanded } = tableData;
return (
<>
<tr className="select-none">
<td
className={classnames('border-0 p-0', {
2020-04-02 17:09:38 -03:00
'border-b border-secondary-light bg-primary-dark': isExpanded,
})}
>
<div
className={classnames(
'w-full transition border-transparent duration-300',
{
'border border-primary-light rounded overflow-hidden mb-2 hover:border-secondary-light': isExpanded,
}
)}
>
<table className={classnames('w-full p-4')}>
<tbody>
<tr
className={classnames(
2020-04-02 17:09:38 -03:00
'cursor-pointer hover:bg-secondary-main transition duration-300 bg-black',
{
2020-04-02 17:09:38 -03:00
'bg-primary-dark': !isExpanded,
},
2020-04-02 17:09:38 -03:00
{ 'bg-secondary-dark': isExpanded }
)}
onClick={onClickRow}
>
{row.map((cell, index) => {
2020-05-11 21:36:51 -04:00
const { content, title, gridCol, name } = cell;
return (
<td
2020-05-12 15:10:26 -04:00
key={index}
className={classnames(
2020-05-11 21:36:51 -04:00
'px-4 py-2 text-base truncate',
2020-04-02 17:09:38 -03:00
{ 'border-b border-secondary-light': !isExpanded },
`w-${gridCol}/24` || ''
)}
style={{
maxWidth: 0,
}}
2020-05-11 21:36:51 -04:00
title={title}
>
{index === 0 && (
<Icon
name={isExpanded ? 'chevron-down' : 'chevron-right'}
className="mr-4 inline-flex"
/>
)}
{content}
</td>
);
})}
</tr>
{isExpanded && (
<tr className="w-full bg-black select-text max-h-0 overflow-hidden">
<td colSpan={row.length}>{expandedContent}</td>
</tr>
)}
</tbody>
</table>
</div>
</td>
</tr>
</>
);
};
StudyListTableRow.propTypes = {
tableData: PropTypes.shape({
2020-05-12 00:05:15 -04:00
/** A table row represented by an array of "cell" objects */
row: PropTypes.arrayOf(
PropTypes.shape({
key: PropTypes.string.isRequired,
2020-05-12 00:05:15 -04:00
/** Optional content to render in row's cell */
content: PropTypes.node,
2020-05-11 21:36:51 -04:00
/** Title attribute to use for provided content */
title: PropTypes.string,
gridCol: PropTypes.number.isRequired,
})
).isRequired,
expandedContent: PropTypes.node.isRequired,
onClickRow: PropTypes.func.isRequired,
isExpanded: PropTypes.bool.isRequired,
}),
};
export default StudyListTableRow;