Skip to content

Commit 12df97b

Browse files
committed
feat: added tooltip to heatmap
1 parent 89ffdc7 commit 12df97b

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

bun.lockb

4.05 KB
Binary file not shown.

src/components/analytics/exif/AssetHeatMap.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React, { useEffect, useState } from "react";
22
import { getHeatMapData } from "@/handlers/api/analytics.handler";
33
import { useConfig } from "@/contexts/ConfigContext";
4+
import { Tooltip } from "@/components/ui/tooltip";
45

56
type HeatMapEntry = {
67
date: string;
78
count: number;
89
};
910

1011
export default function AssetHeatMap() {
11-
const { exImmichUrl } = useConfig();
12+
const { exImmichUrl } = useConfig();
1213

1314
const [heatMapData, setHeatMapData] = useState<HeatMapEntry[][]>([]);
1415
const [loading, setLoading] = useState(false);
@@ -117,18 +118,19 @@ export default function AssetHeatMap() {
117118
>
118119
{
119120
column[rowIndex]?.date ? (
120-
<a
121-
href={`${exImmichUrl}/search?query=%7B%22takenAfter%22%3A%22${column[rowIndex]?.date ?? "N/A"}T00%3A00%3A00.000Z%22%2C%22takenBefore%22%3A%22${column[rowIndex]?.date ?? "N/A"}T23%3A59%3A59.999Z%22%7D`}
122-
className="block h-full w-full"
123-
target="_blank"
124-
>
125-
<div
126-
className="h-full w-full"
127-
title={`Date: ${column[rowIndex]?.date ?? "N/A"}, Count: ${column[rowIndex]?.count ?? 0}`}
128-
/>
129-
</a>) : <div
121+
<Tooltip delayDuration={0} content={`Date: ${column[rowIndex]?.date ?? "N/A"} - Count: ${column[rowIndex]?.count ?? 0}`}>
122+
<a
123+
href={`${exImmichUrl}/search?query=%7B%22takenAfter%22%3A%22${column[rowIndex]?.date ?? "N/A"}T00%3A00%3A00.000Z%22%2C%22takenBefore%22%3A%22${column[rowIndex]?.date ?? "N/A"}T23%3A59%3A59.999Z%22%7D`}
124+
className="block h-full w-full"
125+
target="_blank"
126+
>
127+
<div
128+
className="h-full w-full"
129+
/>
130+
</a></Tooltip>) : <div
130131
className="h-full w-full"
131132
/>
133+
132134
}
133135
</td>
134136
))}

src/components/ui/tooltip.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@ const TooltipContent = React.forwardRef<
2626
TooltipContent.displayName = TooltipPrimitive.Content.displayName
2727

2828

29-
const Tooltip: React.FC<React.ComponentProps<typeof TooltipRoot>> = ({
29+
export interface ITooltipProps extends React.ComponentProps<typeof TooltipRoot> {
30+
content: string
31+
}
32+
const Tooltip: React.FC<ITooltipProps> = ({
3033
children,
34+
content,
3135
...props
3236
}) => (
3337
<TooltipProvider>
3438
<TooltipRoot {...props}>
35-
{children}
36-
<TooltipContent />
39+
<TooltipTrigger asChild>
40+
{children}
41+
</TooltipTrigger>
42+
<TooltipContent>
43+
<p>{content}</p>
44+
</TooltipContent>
3745
</TooltipRoot>
3846
</TooltipProvider>
3947
)

0 commit comments

Comments
 (0)