2020-11-29 01:25:48 -07:00
|
|
|
import { Box } from '@chakra-ui/react';
|
2020-11-03 01:51:41 -07:00
|
|
|
import { useColorValue } from '~/context';
|
|
|
|
|
2020-11-29 01:25:48 -07:00
|
|
|
import type { TTableCell } from './types';
|
2020-11-03 01:51:41 -07:00
|
|
|
|
2020-11-29 01:25:48 -07:00
|
|
|
export const TableCell = (props: TTableCell) => {
|
|
|
|
const { bordersVertical = [false, 0], align, ...rest } = props;
|
2020-11-03 01:51:41 -07:00
|
|
|
const [doVerticalBorders, index] = bordersVertical;
|
|
|
|
const borderLeftColor = useColorValue('blackAlpha.100', 'whiteAlpha.100');
|
|
|
|
|
|
|
|
let borderProps = {};
|
|
|
|
if (doVerticalBorders && index !== 0) {
|
|
|
|
borderProps = { borderLeft: '1px solid', borderLeftColor };
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
p={4}
|
|
|
|
m={0}
|
|
|
|
w="1%"
|
|
|
|
as="td"
|
|
|
|
textAlign={align}
|
|
|
|
whiteSpace="nowrap"
|
|
|
|
{...borderProps}
|
|
|
|
{...rest}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|