Open person from thumbnail

This commit is contained in:
Jack Brown committed 2024-12-16 00:13:30 +00:00
1 parent 7639de9e45
commit c86d644a02
1 file changed
+21 -16
+21 -16
View File
@@ -1,6 +1,7 @@
import { Avatar } from "@/components/ui/avatar";
import { cn } from "@/lib/utils";
import { IPerson } from "@/types/person";
import { useConfig } from "@/contexts/ConfigContext";
interface FaceThumbnailProps {
person: IPerson;
@@ -8,10 +9,11 @@ interface FaceThumbnailProps {
selected?: boolean;
}
const FaceThumbnail = ({ person, onSelect, selected }: FaceThumbnailProps) => {
const { exImmichUrl } = useConfig();
return (
<div
className={cn(
" col-span-1 group flex flex-col items-center p-2 border-2 text-center rounded-lg dark:hover:bg-zinc-900 hover:bg-zinc-100 gap-2 justify-center",
"col-span-1 group flex flex-col items-center p-2 border-2 text-center rounded-lg dark:hover:bg-zinc-900 hover:bg-zinc-100 gap-2 justify-center",
{
"border-zinc-500": selected,
}
@@ -19,22 +21,25 @@ const FaceThumbnail = ({ person, onSelect, selected }: FaceThumbnailProps) => {
onClick={() => onSelect(person)}
>
<div className="relative">
<Avatar
src={person.thumbnailPath}
alt={person.name}
className="w-full h-full rounded-lg"
/>
<p className="absolute text-[9px] top-1 right-1 bg-amber-300 px-1 text-zinc-900 rounded-lg group-hover:hidden">
{person.similarity ? `${Math.round(person.similarity * 100)}%` : ""}
</p>
<Avatar
src={person.thumbnailPath}
alt={person.name}
className="w-full h-full rounded-lg"
/>
<p className="absolute text-[9px] top-1 right-1 bg-amber-300 px-1 text-zinc-900 rounded-lg group-hover:hidden">
{person.similarity ? `${Math.round(person.similarity * 100)}%` : ""}
</p>
</div>
{person.name ? (
<p className="text-[12px]">{person.name}</p>
) : (
<p className="text-[12px] italic text-gray-400">Untagged Person</p>
)}
{/* Make name or "Untagged Person" clickable to open the person's page */}
<a
href={`${exImmichUrl}/people/${person.id}`} // Use exImmichUrl
className="text-[12px] cursor-pointer"
target="_blank"
rel="noopener noreferrer"
>
{person.name ? person.name : <span className="italic text-gray-400">Untagged Person</span>}
</a>
</div>
);
};