2024-06-30 19:59:32 -05:00
|
|
|
import { Skeleton, Table } from '@radix-ui/themes';
|
|
|
|
|
import { times } from 'lodash';
|
2024-07-06 20:32:41 -05:00
|
|
|
import { useEffect, useRef } from 'react';
|
2024-07-06 20:07:46 -05:00
|
|
|
import { tankPerformanceSortTypeNamesArray } from '../../../../stores/tankPerformanceSort';
|
2024-06-30 19:59:32 -05:00
|
|
|
|
2024-07-06 20:32:41 -05:00
|
|
|
interface RowLoaderProps {
|
|
|
|
|
onIntersection?: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function RowLoader({ onIntersection }: RowLoaderProps) {
|
|
|
|
|
const row = useRef<HTMLTableRowElement>(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!onIntersection || !row.current) return;
|
|
|
|
|
|
|
|
|
|
const observer = new IntersectionObserver(onIntersection);
|
|
|
|
|
observer.observe(row.current);
|
|
|
|
|
|
|
|
|
|
return () => observer.disconnect();
|
|
|
|
|
}, []);
|
|
|
|
|
|
2024-06-30 19:59:32 -05:00
|
|
|
return (
|
2024-07-06 20:32:41 -05:00
|
|
|
<Table.Row ref={row}>
|
2024-06-30 20:34:22 -05:00
|
|
|
<Table.RowHeaderCell align="center">
|
2024-06-30 19:59:32 -05:00
|
|
|
<Skeleton height="100%" width="128px" />
|
|
|
|
|
</Table.RowHeaderCell>
|
|
|
|
|
|
2024-07-06 20:07:46 -05:00
|
|
|
{times(tankPerformanceSortTypeNamesArray.length, (index) => (
|
2024-06-30 20:34:22 -05:00
|
|
|
<Table.Cell key={index} align="center">
|
2024-06-30 19:59:32 -05:00
|
|
|
<Skeleton height="1em" width="32px" />
|
|
|
|
|
</Table.Cell>
|
|
|
|
|
))}
|
|
|
|
|
</Table.Row>
|
|
|
|
|
);
|
|
|
|
|
}
|