ohif-viewer/platform/ui/src/components/Thumbnail/Thumbnail.jsx
Rodrigo Antinarelli 491afaa43d
fix: UI tweaks to satisfy OHIF-161, OHIF-254, OHIF-167, OHIF-249, OHIF-170, OHIF-162
* add group hover for borderColor

* measurements action buttons hover state

* fixes and button/buttongroup/iconButton refactor

* OHIF-161: Fix Tracked/Untracked Text in Thumbnail's Tooltip

* OHIF-254: Format SR series date

* OHIF-167 - Fix Study Date Time format

* OHIF-249: Fix viewport border thickness and action bar min height

* pass viewportIdentificator to SR Thumbnail

* show tooltip when hover over the SR thumbnail

* OHIF-170: Display tooltip when hovering over an untracked series in the Viewport Action Bar

* Undo accidental date change

* Sneak in "Create Report" messaging for createReport notifications

* Fix text clipping

* Add no-select text styles for action bar, thumbnail, and thumbnail no image (sr)

* fix for OHIF-162

Modified to remove Viewport Identifier. Text now only reads: “Structured Report”This was partly to address a bug where the Viewport Identifier was incorrect for all but the first displayed SR. Component API changed for ThumbnailNoImage to accomodate any generic “modalityTooltip”

* Some ViewportPane resize magic

Co-authored-by: dannyrb <danny.ri.brown@gmail.com>
2020-07-02 21:41:55 -04:00

113 lines
3.3 KiB
JavaScript

import React, { useRef } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { useDrag } from 'react-dnd';
import { Icon } from '@ohif/ui';
import blurHandlerListener from '../../utils/blurHandlerListener';
/**
*
*/
const Thumbnail = ({
displaySetInstanceUID,
className,
imageSrc,
imageAltText,
description,
seriesNumber,
numInstances,
dragData,
isActive,
onClick,
onDoubleClick,
}) => {
// TODO: We should wrap our thumbnail to create a "DraggableThumbnail", as
// this will still allow for "drag", even if there is no drop target for the
// specified item.
const [collectedProps, drag, dragPreview] = useDrag({
item: { ...dragData },
canDrag: function(monitor) {
return Object.keys(dragData).length !== 0;
},
});
const thumbnailElement = useRef(null);
return (
<div
onFocus={() => blurHandlerListener(thumbnailElement)}
ref={thumbnailElement}
className={classnames(
className,
'flex flex-col flex-1 px-3 mb-8 cursor-pointer outline-none select-none group'
)}
id={`thumbnail-${displaySetInstanceUID}`}
onClick={onClick}
onDoubleClick={onDoubleClick}
role="button"
tabIndex="0"
>
<div ref={drag}>
<div
className={classnames(
'flex flex-1 items-center justify-center rounded-md bg-black text-base text-white overflow-hidden mb-2 min-h-32',
isActive
? 'border-2 border-primary-light'
: 'border border-secondary-light group-focus:border-blue-300 hover:border-blue-300'
)}
>
{imageSrc ? (
<img
src={imageSrc}
alt={imageAltText}
className="object-none min-h-32"
/>
) : (
<div>{imageAltText}</div>
)}
</div>
<div className="flex flex-row items-center flex-1 text-base text-blue-300">
<div className="mr-4">
<span className="font-bold text-primary-main">{'S: '}</span>
{seriesNumber}
</div>
<div className="flex flex-row items-center flex-1">
<Icon name="group-layers" className="w-3 mr-2" /> {numInstances}
</div>
</div>
<div className="text-base text-white break-all">{description}</div>
</div>
</div>
);
};
Thumbnail.propTypes = {
displaySetInstanceUID: PropTypes.string.isRequired,
className: PropTypes.string,
imageSrc: PropTypes.string,
/**
* 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,
}),
imageAltText: PropTypes.string,
description: PropTypes.string.isRequired,
seriesNumber: PropTypes.number.isRequired,
numInstances: PropTypes.number.isRequired,
isActive: PropTypes.bool.isRequired,
onClick: PropTypes.func.isRequired,
onDoubleClick: PropTypes.func.isRequired,
};
Thumbnail.defaultProps = {
dragData: {},
};
export default Thumbnail;