mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-14 21:26:08 +01:00
fix: faster search
This commit is contained in:
1 parent
5866072aa7
commit
88acf6bce6
3 files changed
+78
-22
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { Flex, Skeleton, Text } from '@radix-ui/themes';
|
||||
import { useRef } from 'react';
|
||||
import { useIntersection } from '../../hooks/useIntersection';
|
||||
import type { MaybeSkeletonComponentProps } from '../../types/maybeSkeletonComponentProps';
|
||||
|
||||
type GalleryCardProps = MaybeSkeletonComponentProps<{
|
||||
id: string;
|
||||
name: string;
|
||||
}>;
|
||||
|
||||
export function GalleryCard(props: GalleryCardProps) {
|
||||
const card = useRef<HTMLDivElement>(null);
|
||||
|
||||
useIntersection(() => props.skeleton && props.onIntersection?.(), card, {
|
||||
disabled: !props.skeleton || props.onIntersection === undefined,
|
||||
});
|
||||
|
||||
return (
|
||||
<Flex direction="column" align="center" width="6rem" gap="1" ref={card}>
|
||||
{props.skeleton && (
|
||||
<>
|
||||
<Skeleton width="100%" height="4.57rem" />
|
||||
<Skeleton width="100%" height="1em" />
|
||||
</>
|
||||
)}
|
||||
|
||||
{!props.skeleton && (
|
||||
<>
|
||||
<img
|
||||
style={{
|
||||
width: '4rem',
|
||||
height: '4.57rem',
|
||||
// aspect ratio 7 / 8
|
||||
objectFit: 'cover',
|
||||
}}
|
||||
src={`/api/gallery/${props.id}.webp`}
|
||||
/>
|
||||
|
||||
<Text align="center" style={{ maxWidth: '100%' }}>
|
||||
{props.name}
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user