ohif-viewer/platform/ui/src/components/ThumbnailTracked/ThumbnailTracked.jsx

112 lines
3.3 KiB
React
Raw Normal View History

2020-04-21 17:44:19 +02:00
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
2020-04-24 00:23:37 +02:00
import { Icon, Thumbnail, Tooltip } from '@ohif/ui';
2020-04-21 17:44:19 +02:00
const ThumbnailTracked = ({
className,
imageSrc,
imageAltText,
2020-04-21 20:12:46 +02:00
description,
2020-04-21 17:44:19 +02:00
seriesNumber,
2020-04-21 20:12:46 +02:00
numInstances,
dragData,
2020-04-21 17:44:19 +02:00
onClick,
onClickUntrack,
2020-04-21 17:44:19 +02:00
viewportIdentificator,
isTracked,
2020-04-21 20:12:46 +02:00
isActive,
2020-04-21 17:44:19 +02:00
}) => {
const trackedIcon = isTracked ? 'circled-checkmark' : 'dotted-circle';
return (
<div
className={classnames(
'flex flex-row flex-1 px-3 py-2 cursor-pointer outline-none',
2020-04-21 17:44:19 +02:00
className
)}
>
<div className="flex flex-col items-center flex-2">
2020-04-21 17:44:19 +02:00
<div
className={classnames(
'flex flex-col items-center justify-start p-2 mb-2 relative cursor-pointer',
2020-04-24 00:23:37 +02:00
isTracked && 'rounded-sm hover:bg-gray-900'
2020-04-21 17:44:19 +02:00
)}
>
2020-04-24 00:23:37 +02:00
<Tooltip
position="right"
content={
<div className="flex flex-row flex-1">
<div className="flex flex-col flex-1 pr-4">
2020-04-21 17:44:19 +02:00
<span>
2020-04-24 00:23:37 +02:00
Series is <span className="text-white">tracked</span>
2020-04-21 17:44:19 +02:00
</span>
2020-04-24 00:23:37 +02:00
{viewportIdentificator && (
<span>
in viewport
<span className="ml-1 text-white">
{viewportIdentificator}
</span>
</span>
)}
</div>
<div className="flex items-center justify-center flex-2">
2020-04-24 00:23:37 +02:00
<Icon name="info-link" className="text-primary-active" />
</div>
2020-04-21 17:44:19 +02:00
</div>
2020-04-24 00:23:37 +02:00
}
>
<Icon name={trackedIcon} className="w-4 mb-2 text-primary-light" />
<div className="h-5 text-xl leading-tight text-white">
2020-04-24 00:23:37 +02:00
{viewportIdentificator}
2020-04-21 17:44:19 +02:00
</div>
2020-04-24 00:23:37 +02:00
</Tooltip>
2020-04-21 17:44:19 +02:00
</div>
{isTracked && (
<div onClick={onClickUntrack}>
<Icon name="cancel" className="w-4 text-primary-active" />
</div>
2020-04-21 17:44:19 +02:00
)}
</div>
<Thumbnail
imageSrc={imageSrc}
imageAltText={imageAltText}
dragData={dragData}
2020-04-21 20:12:46 +02:00
description={description}
2020-04-21 17:44:19 +02:00
seriesNumber={seriesNumber}
2020-04-21 20:12:46 +02:00
numInstances={numInstances}
2020-04-21 17:44:19 +02:00
isActive={isActive}
onClick={onClick}
/>
</div>
);
};
ThumbnailTracked.propTypes = {
/**
* Data the thumbnail should expose to a receiving drop target. Use a matching
* `dragData.type` to identify which targets can receive this draggable item.
* If this is not set, drag-n-drop will be disabled for this thumbnail.
*
* Ref: https://react-dnd.github.io/react-dnd/docs/api/use-drag#specification-object-members
*/
dragData: PropTypes.shape({
/** Must match the "type" a dropTarget expects */
type: PropTypes.string.isRequired,
}),
2020-04-21 17:44:19 +02:00
className: PropTypes.string,
imageSrc: PropTypes.string,
imageAltText: PropTypes.string,
2020-04-21 20:12:46 +02:00
description: PropTypes.string.isRequired,
2020-04-21 17:44:19 +02:00
seriesNumber: PropTypes.number.isRequired,
2020-04-21 20:12:46 +02:00
numInstances: PropTypes.number.isRequired,
2020-04-21 17:44:19 +02:00
onClick: PropTypes.func.isRequired,
onClickUntrack: PropTypes.func.isRequired,
2020-04-21 17:44:19 +02:00
viewportIdentificator: PropTypes.string,
2020-04-21 20:12:46 +02:00
isTracked: PropTypes.bool,
isActive: PropTypes.bool.isRequired,
2020-04-21 17:44:19 +02:00
};
export default ThumbnailTracked;