Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| import React, { useRef, useEffect, useState } from 'react' | |
| import { InformationCircleIcon, DocumentTextIcon } from '@heroicons/react/24/outline' | |
| import GitHubIcon from './icons/GitHubIcon' | |
| import { Tooltip as ReactTooltip } from 'react-tooltip' | |
| import 'react-tooltip/dist/react-tooltip.css' | |
| import Descriptions from '../Descriptions' | |
| interface DatasetInfoIconProps { | |
| datasetName: string | |
| } | |
| const DatasetInfoIcon: React.FC<DatasetInfoIconProps> = ({ datasetName }) => { | |
| const [descriptionsLoaded, setDescriptionsLoaded] = useState(false) | |
| const descriptions = useRef(Descriptions.getInstance()) | |
| useEffect(() => { | |
| descriptions.current.load().then(() => setDescriptionsLoaded(true)) | |
| }, []) | |
| const fullName = descriptions.current.getDatasetFullName(datasetName) || datasetName | |
| const description = descriptions.current.getDatasetDescription(datasetName) | |
| const paperUrl = descriptions.current.getDatasetPaperUrl(datasetName) | |
| const githubUrl = descriptions.current.getDatasetGithubUrl(datasetName) | |
| if (!description) return null | |
| return ( | |
| <> | |
| <span | |
| className="ml-1 cursor-pointer" | |
| data-tooltip-id={`tooltip-dataset-${datasetName}`} | |
| tabIndex={0} | |
| aria-label={`Show info for ${datasetName}`} | |
| role="button" | |
| > | |
| <InformationCircleIcon className="h-4 w-4 text-blue-400 hover:text-blue-600" /> | |
| </span> | |
| <ReactTooltip | |
| id={`tooltip-dataset-${datasetName}`} | |
| place="top" | |
| className="z-[10000] max-w-xs !opacity-100 bg-base-100 text-base-content" | |
| style={{ | |
| boxShadow: '0 0 10px rgba(0,0,0,0.2)', | |
| zIndex: 10000, // Ensure tooltips appear above sticky elements | |
| }} | |
| openOnClick={false} | |
| clickable={true} | |
| delayHide={200} | |
| positionStrategy="fixed" | |
| > | |
| <div className="p-2 text-xs text-left relative z-[10000]"> | |
| <div className="font-semibold mb-1">{fullName}</div> | |
| <div className="mb-2 whitespace-pre-line"> | |
| {description || 'No description available.'} | |
| </div> | |
| <div className="flex space-x-4"> | |
| {paperUrl && ( | |
| <div> | |
| <a | |
| href={paperUrl} | |
| target="_blank" | |
| rel="noopener noreferrer" | |
| className="text-blue-400 hover:text-blue-300 underline flex items-center" | |
| > | |
| <DocumentTextIcon className="h-3 w-3 mr-1" /> | |
| Paper | |
| </a> | |
| </div> | |
| )} | |
| {githubUrl && ( | |
| <div> | |
| <a | |
| href={githubUrl} | |
| target="_blank" | |
| rel="noopener noreferrer" | |
| className="text-blue-400 hover:text-blue-300 underline flex items-center" | |
| > | |
| <GitHubIcon className="h-3 w-3 mr-1" /> | |
| GitHub | |
| </a> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| </ReactTooltip> | |
| </> | |
| ) | |
| } | |
| export default DatasetInfoIcon | |