Files
blitzkit/packages/website/src/components/Performance/RowLoader.tsx
T

31 lines
953 B
TypeScript
Raw Normal View History

2025-09-27 16:07:45 -05:00
import { Skeleton, Table } from "@radix-ui/themes";
import { times } from "lodash-es";
import { memo, useRef } from "react";
import { useIntersection } from "../../hooks/useIntersection";
import { TankPerformanceSortTypeNamesArray } from "../../stores/tankPerformanceSort/constants";
2024-06-30 19:59:32 -05:00
2024-07-06 20:32:41 -05:00
interface RowLoaderProps {
onIntersection?: () => void;
}
2024-07-07 18:48:32 -05:00
export const RowLoader = memo<RowLoaderProps>(({ onIntersection }) => {
2025-09-27 16:07:45 -05:00
const row = useRef<HTMLTableRowElement>(null!);
2024-07-06 20:32:41 -05:00
2024-07-07 18:01:56 -05:00
useIntersection(() => onIntersection?.(), row, {
disabled: onIntersection === undefined,
});
2024-07-06 20:32:41 -05:00
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-12 13:53:11 -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>
);
2024-07-07 18:48:32 -05:00
});