ohif-viewer/platform/ui/src/components/TableCell/TableCell.jsx

63 lines
1.2 KiB
React
Raw Normal View History

2020-03-20 22:56:27 +01:00
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
2020-03-23 19:04:44 +01:00
const TableCell = ({
children,
className,
2020-03-26 00:03:29 +01:00
colSpan,
// ignored because we don't wan't to expose this prop
// eslint-disable-next-line react/prop-types
cellsNum,
2020-03-23 19:04:44 +01:00
isTableHead,
align,
style,
}) => {
const classes = {
align: {
left: 'text-left',
center: 'text-center',
right: 'text-right',
justify: 'text-justify',
},
2020-03-25 22:14:43 +01:00
isTableHead: {
true: '',
2020-04-02 20:52:41 +02:00
false: 'border-r border-secondary-light',
2020-03-25 22:14:43 +01:00
},
2020-03-20 22:56:27 +01:00
};
return (
<div
className={classnames(
'px-2 last:border-r-0 break-all',
2020-03-26 00:03:29 +01:00
`w-${colSpan}/${cellsNum}`,
2020-03-23 19:04:44 +01:00
classes.align[align],
2020-03-25 22:14:43 +01:00
classes.isTableHead[isTableHead],
2020-03-20 22:56:27 +01:00
className
)}
style={style}
>
{children}
</div>
);
};
TableCell.defaultProps = {
2020-03-26 00:03:29 +01:00
align: 'left',
2020-03-20 22:56:27 +01:00
className: '',
2020-03-26 00:03:29 +01:00
colSpan: 1,
2020-03-20 22:56:27 +01:00
isTableHead: false,
style: {},
};
TableCell.propTypes = {
2020-03-26 00:03:29 +01:00
align: PropTypes.oneOf(['left', 'center', 'right', 'justify']),
2020-03-20 22:56:27 +01:00
children: PropTypes.node.isRequired,
className: PropTypes.string,
2020-03-26 00:03:29 +01:00
colSpan: PropTypes.number,
isTableHead: PropTypes.bool,
2020-03-20 22:56:27 +01:00
style: PropTypes.object,
};
export default TableCell;