-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImageCard.tsx
More file actions
51 lines (46 loc) · 1.68 KB
/
Copy pathImageCard.tsx
File metadata and controls
51 lines (46 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Card, Group, Tooltip } from '@mantine/core';
import { useOpenSpaceApi } from '@/api/hooks';
import { TruncatedText } from '@/components/TruncatedText/TruncatedText';
import { PlusIcon } from '@/icons/icons';
import { useAppSelector } from '@/redux/hooks';
import { IconImage } from '../components/IconImage';
import { ImageInfoPopover } from '../components/ImageInfoPopover';
import { useActiveImage, useBrowserColorString } from '../hooks';
import { SkyBrowserImage } from '../types';
interface Props {
image: SkyBrowserImage;
}
export function ImageCard({ image }: Props) {
const [activeImage, setActiveImage] = useActiveImage();
const luaApi = useOpenSpaceApi();
const isActive = activeImage === image.url;
const selectedBrowserId = useAppSelector((state) => state.skybrowser.selectedBrowserId);
const color = useBrowserColorString(selectedBrowserId);
function select() {
luaApi?.skybrowser.selectImage(image.url);
setActiveImage(image.url);
}
return (
<Card withBorder shadow={'sm'} style={{ borderColor: isActive ? color : undefined }}>
<Card.Section>
<IconImage
url={image.thumbnail}
onClick={select}
onHover={() => luaApi?.skybrowser.moveIndicatorToHoverImage(image.url)}
onLeave={() => luaApi?.skybrowser.disableHoverIndicator()}
icon={<PlusIcon />}
h={'100%'}
w={'100%'}
/>
</Card.Section>
<Card.Section p={'xs'}>
<Group wrap={'nowrap'}>
<Tooltip label={image.name}>
<TruncatedText>{image.name}</TruncatedText>
</Tooltip>
<ImageInfoPopover image={image} />
</Group>
</Card.Section>
</Card>
);
}