Skip to content

Commit

Permalink
feat: added tooltip to heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
varun-raj committed Nov 23, 2024
1 parent 89ffdc7 commit 12df97b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
Binary file modified bun.lockb
Binary file not shown.
24 changes: 13 additions & 11 deletions src/components/analytics/exif/AssetHeatMap.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useEffect, useState } from "react";
import { getHeatMapData } from "@/handlers/api/analytics.handler";
import { useConfig } from "@/contexts/ConfigContext";
import { Tooltip } from "@/components/ui/tooltip";

type HeatMapEntry = {
date: string;
count: number;
};

export default function AssetHeatMap() {
const { exImmichUrl } = useConfig();
const { exImmichUrl } = useConfig();

const [heatMapData, setHeatMapData] = useState<HeatMapEntry[][]>([]);
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -117,18 +118,19 @@ export default function AssetHeatMap() {
>
{
column[rowIndex]?.date ? (
<a
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`}
className="block h-full w-full"
target="_blank"
>
<div
className="h-full w-full"
title={`Date: ${column[rowIndex]?.date ?? "N/A"}, Count: ${column[rowIndex]?.count ?? 0}`}
/>
</a>) : <div
<Tooltip delayDuration={0} content={`Date: ${column[rowIndex]?.date ?? "N/A"} - Count: ${column[rowIndex]?.count ?? 0}`}>
<a
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`}
className="block h-full w-full"
target="_blank"
>
<div
className="h-full w-full"
/>
</a></Tooltip>) : <div
className="h-full w-full"
/>

}
</td>
))}
Expand Down
14 changes: 11 additions & 3 deletions src/components/ui/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ const TooltipContent = React.forwardRef<
TooltipContent.displayName = TooltipPrimitive.Content.displayName


const Tooltip: React.FC<React.ComponentProps<typeof TooltipRoot>> = ({
export interface ITooltipProps extends React.ComponentProps<typeof TooltipRoot> {
content: string
}
const Tooltip: React.FC<ITooltipProps> = ({
children,
content,
...props
}) => (
<TooltipProvider>
<TooltipRoot {...props}>
{children}
<TooltipContent />
<TooltipTrigger asChild>
{children}
</TooltipTrigger>
<TooltipContent>
<p>{content}</p>
</TooltipContent>
</TooltipRoot>
</TooltipProvider>
)
Expand Down

0 comments on commit 12df97b

Please sign in to comment.