feat(ViewportActionBar and CinePlayer): Add new design for action bar and cine player (#3204)

* feat(ViewportActionBar): OHIF issue #3123 (#3186)

* feat(ViewportActionBar): OHIF issue #3123

- Renamed previous viewport action bar to be LegacyViewportActionBar
- Components LegacyViewportActionBar depends on also renamed: LegacyCinePlayer and LegacyPatientInfo
- New Viewport coded to specs in issue
- added React hook useResizeObserver
- added some tailwind classes

* Updated tailwind to 3.2.7.
Put external imports like React at the top of the import list.

* feat(CinePlayer and ViewportActionBar) (#3198)

* feat(CinePlayer and ViewportActionBar)
- OHIF issue 3123

- new look cine control implemented
- new custom blue color in tailwind config for various hover backgrounds in the cine control
- new icons added for cine

- Tooltip component now can be placed top (center) on hover
- Tooltip component border colour now consistent with specs

- fixed NPE in ViewportActionBar

- upgraded tailwind to 3.2.7 in platform/ui
- fixed issues in various button components brought by tailwind 3.2.7 where classes now need important flag

- fixed issue with InputRange component so that the tracked value property can change externally
- InputRange component can now optionally show its label

- added new measurement tracking state service to hydrate SR without prompting
- segmentation can also now be hydrated without prompting

* PR feedback:
- cine centralized to OHIFCornerstoneViewport
- introduced a type for the CinePlayer properties

* Addressed PR comments and concerns...

The DOM ref for the root component of the ViewportActionBar is now added to state
so that the various callbacks and ResizeObserver are updated with it.
The CinePlayer FPS slider tooltip was moved up so that its arrow does not
intersect the FPS text.
The hover area for the CinePlayer slider tooltip is now the FPS < > buttons and text.
The tracked measurements are now filtered to only include those of the active
viewport series when the tracked measurement navigation arrows are used.

* Addressed PR comments...

The update to tailwind 3.2.7 caused several look-and-feel, UI regressions,
so we are rolling back to 3.2.4.
This commit is contained in:
Joe Boccanfuso authored and GitHub committed 2023-02-28 15:57:19 -05:00
1 parent c9125a0c0a
commit 35d0787211
55 files changed
+1205 -513

No files matched your search

@@ -0,0 +1,3 @@
.cine-fps-range-tooltip .tooltip.tooltip-top {
bottom: 85% !important;
}
@@ -1,11 +1,28 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import debounce from 'lodash.debounce';
import { IconButton, Icon } from '../';
import { Icon, Tooltip, InputRange } from '../';
import './CinePlayerCustomInputRange.css';
import './CinePlayer.css';
import classNames from 'classnames';
const CinePlayer = ({
export type CinePlayerProps = {
className: string;
isPlaying: boolean;
minFrameRate: number;
maxFrameRate: number;
stepFrameRate: number;
frameRate: number;
onFrameRateChange: (value: number) => void;
onPlayPauseChange: (value: boolean) => void;
onClose: () => void;
};
const fpsButtonClassNames =
'cursor-pointer text-primary-active active:text-primary-light hover:bg-customblue-300 w-4 flex items-center justify-center';
const CinePlayer: React.FC<CinePlayerProps> = ({
className,
isPlaying,
minFrameRate,
maxFrameRate,
@@ -18,52 +35,68 @@ const CinePlayer = ({
const [frameRate, setFrameRate] = useState(defaultFrameRate);
const debouncedSetFrameRate = debounce(onFrameRateChange, 300);
const onFrameRateChangeHandler = ({ target }) => {
const frameRate = parseFloat(target.value);
debouncedSetFrameRate(frameRate);
const getPlayPauseIconName = () => (isPlaying ? 'icon-pause' : 'icon-play');
const handleSetFrameRate = (frameRate: number) => {
if (frameRate < minFrameRate || frameRate > maxFrameRate) {
return;
}
setFrameRate(frameRate);
};
const onPlayPauseChangeHandler = () => onPlayPauseChange(!isPlaying);
const action = {
false: { icon: 'old-play' },
true: { icon: 'old-stop' },
debouncedSetFrameRate(frameRate);
};
return (
<div className="flex flex-row items-center justify-center h-10 border rounded-full CinePlayer border-primary-light">
<IconButton
variant="text"
color="inherit"
size="initial"
className="ml-4 mr-3 text-primary-active"
onClick={onPlayPauseChangeHandler}
<div
className={classNames(
className,
'select-none flex items-center gap-2 px-2 py-2 rounded border border-secondary-light/60 bg-primary-dark'
)}
>
<Icon
name={getPlayPauseIconName()}
className="cursor-pointer text-white active:text-primary-light hover:bg-customblue-300 hover:rounded"
onClick={() => onPlayPauseChange(!isPlaying)}
/>
<Tooltip
position="top"
className="group/fps cine-fps-range-tooltip"
tight={true}
content={
<InputRange
containerClassName="h-9 px-2"
inputClassName="w-40"
value={frameRate}
minValue={minFrameRate}
maxValue={maxFrameRate}
step={stepFrameRate}
onChange={handleSetFrameRate}
showLabel={false}
/>
}
>
<Icon width="15px" height="15px" name={action[isPlaying].icon} />
</IconButton>
<div className="flex flex-col justify-center h-full pt-2 pl-1 pr-1 mr-3">
<input
type="range"
name="frameRate"
min={minFrameRate}
max={maxFrameRate}
step={stepFrameRate}
value={frameRate}
onChange={onFrameRateChangeHandler}
/>
<p className="-mt-2 text-sm text-primary-light">{`${frameRate.toFixed(
1
)} fps`}</p>
</div>
<IconButton
color="inherit"
size="initial"
className="mr-3 border rounded-full text-primary-active border-primary-active"
<div className="border border-secondary-light flex h-6 items-stretch rounded gap-1">
<div
className={`${fpsButtonClassNames} rounded-l`}
onClick={() => handleSetFrameRate(frameRate - 1)}
>
<Icon name="arrow-left-small" />
</div>
<div className="w-11 text-sm text-white text-center group-hover/fps:text-primary-light leading-[22px]">
{`${frameRate} FPS`}
</div>
<div
className={`${fpsButtonClassNames} rounded-r`}
onClick={() => handleSetFrameRate(frameRate + 1)}
>
<Icon name="arrow-right-small" />
</div>
</div>
</Tooltip>
<Icon
name="icon-close"
className="cursor-pointer text-primary-active active:text-primary-light hover:bg-customblue-300 hover:rounded"
onClick={onClose}
>
<Icon name="close" width="15px" height="15px" />
</IconButton>
/>
</div>
);
};
@@ -1,107 +0,0 @@
/*
* This is a custom input style scoped specifically to CinePlayer
* written in plain CSS with color variables from tailwind
* to avoid complex compatibility configuration.
*/
.CinePlayer input[type='range'] {
-webkit-appearance: none;
background: transparent;
width: 100%;
height: 20px;
z-index: 5;
}
.CinePlayer input[type='range']:focus {
outline: none;
}
.CinePlayer input[type='range']::-webkit-slider-runnable-track {
width: 100%;
height: 2px;
cursor: pointer;
animate: 0.2s;
box-shadow: 0px 0px 0px #000000;
@apply bg-primary-light;
border-radius: 5px;
border: 0px solid #000000;
}
.CinePlayer input[type='range']::-webkit-slider-thumb {
box-shadow: 0px 0px 0px #000000;
border: 4px solid #000000;
height: 18px;
width: 17px;
border-radius: 50px;
@apply bg-primary-light;
cursor: pointer;
-webkit-appearance: none;
margin-top: -9px;
}
.CinePlayer input[type='range']:focus::-webkit-slider-runnable-track {
@apply bg-primary-light;
}
.CinePlayer input[type='range']::-moz-range-track {
width: 100%;
height: 2px;
cursor: pointer;
animate: 0.2s;
box-shadow: 0px 0px 0px #000000;
@apply bg-primary-light;
border-radius: 5px;
border: 0px solid #000000;
}
.CinePlayer input[type='range']::-moz-range-thumb {
box-shadow: 0px 0px 0px #000000;
border: 2px solid #000000;
height: 12px;
width: 12px;
border-radius: 50px;
@apply bg-primary-light;
cursor: pointer;
}
.CinePlayer input[type='range']::-ms-track {
width: 100%;
height: 2px;
cursor: pointer;
animate: 0.2s;
background: transparent;
border-color: transparent;
color: transparent;
}
.CinePlayer input[type='range']::-ms-fill-lower {
@apply bg-primary-light;
border: 0px solid #000000;
border-radius: 10px;
box-shadow: 0px 0px 0px #000000;
}
.CinePlayer input[type='range']::-ms-fill-upper {
@apply bg-primary-light;
border: 0px solid #000000;
border-radius: 10px;
box-shadow: 0px 0px 0px #000000;
}
.CinePlayer input[type='range']::-ms-thumb {
margin-top: 1px;
box-shadow: 0px 0px 0px #000000;
border: 4px solid #000000;
height: 18px;
width: 17px;
border-radius: 50px;
@apply bg-primary-light;
cursor: pointer;
}
.CinePlayer input[type='range']:focus::-ms-fill-lower {
@apply bg-primary-light;
}
.CinePlayer input[type='range']:focus::-ms-fill-upper {
@apply bg-primary-light;
}
@@ -1,32 +0,0 @@
import CinePlayer from '../CinePlayer';
import { ArgsTable, Story, Canvas, Meta } from '@storybook/addon-docs';
import { createComponentTemplate } from '../../../storybook/functions/create-component-story';
export const argTypes = {
component: CinePlayer,
title: 'Components/CinePlayer',
};
<Meta title="Components/CinePlayer" component={CinePlayer} />
export const cineTemplate = createComponentTemplate(CinePlayer);
<Heading title="CinePlayer" componentRelativePath="CinePlayer/CinePlayer.tsx" />
- [Overview](#overview)
- [Props](#props)
- [Contribute](#contribute)
## Overview
<Canvas>
<Story name="Overview">{cineTemplate.bind({})}</Story>
</Canvas>
## Props
<ArgsTable of={CinePlayer} />
## Contribute
<Footer componentRelativePath="CinePlayer/__stories__/cinePlayer.stories.mdx" />