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.
portainer/app/react/components/datatables/ExpandingCell.tsx

37 lines
968 B

import { PropsWithChildren } from 'react';
import { Row } from 'react-table';
import styles from './ExpandingCell.module.css';
interface Props<D extends Record<string, unknown> = Record<string, unknown>> {
row: Row<D>;
showExpandArrow: boolean;
}
export function ExpandingCell<
D extends Record<string, unknown> = Record<string, unknown>
>({ row, showExpandArrow, children }: PropsWithChildren<Props<D>>) {
return (
<>
{showExpandArrow && (
<button type="button" className={styles.expandButton}>
<i
// eslint-disable-next-line react/jsx-props-no-spreading
{...row.getToggleRowExpandedProps()}
className={`fas ${arrowClass(row.isExpanded)} space-right`}
aria-hidden="true"
/>
</button>
)}
{children}
</>
);
function arrowClass(isExpanded: boolean) {
if (isExpanded) {
return 'fa-angle-down';
}
return 'fa-angle-right';
}
}