The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/client/components/GenericTable/HeaderCell.tsx

31 lines
720 B

import { Box, Table } from '@rocket.chat/fuselage';
import React, { FC, useCallback } from 'react';
import SortIcon from './SortIcon';
type HeaderCellProps = {
active?: boolean;
direction?: 'asc' | 'desc';
sort?: string;
onClick?: (sort: string) => void;
};
const HeaderCell: FC<HeaderCellProps> = ({
children,
active,
direction,
sort,
onClick,
...props
}) => {
const fn = useCallback(() => onClick && sort && onClick(sort), [sort, onClick]);
return <Table.Cell clickable={!!sort} onClick={fn} { ...props }>
<Box display='flex' alignItems='center' wrap='no-wrap'>
{children}
{sort && <SortIcon direction={active ? direction : undefined} />}
</Box>
</Table.Cell>;
};
export default HeaderCell;