ui(feat): Adds light/dark mode support for viewport overlay text and markers (#5041)
Co-authored-by: sedghi <ar.sedghi@gmail.com>
This commit is contained in:
1 parent
1fd39626e7
commit
04ab79f8fb
63 files changed
+65
-38
No files matched your search
@@ -10,6 +10,7 @@ import { utils } from '@ohif/core';
|
||||
import { StackViewportData, VolumeViewportData } from '../../types/CornerstoneCacheService';
|
||||
|
||||
import './CustomizableViewportOverlay.css';
|
||||
import { useViewportRendering } from '../../hooks';
|
||||
|
||||
const EPSILON = 1e-4;
|
||||
const { formatPN } = utils;
|
||||
@@ -67,6 +68,7 @@ function CustomizableViewportOverlay({
|
||||
servicesManager.services;
|
||||
const [voi, setVOI] = useState({ windowCenter: null, windowWidth: null });
|
||||
const [scale, setScale] = useState(1);
|
||||
const { isViewportBackgroundLight: isLight } = useViewportRendering(viewportId);
|
||||
const { imageIndex } = imageSliceData;
|
||||
|
||||
// Historical usage defined the overlays as separate items due to lack of
|
||||
@@ -170,6 +172,7 @@ function CustomizableViewportOverlay({
|
||||
viewportId,
|
||||
servicesManager,
|
||||
customization: item,
|
||||
isLight,
|
||||
formatters: {
|
||||
formatPN,
|
||||
formatDate: formatDICOMDate,
|
||||
@@ -219,6 +222,7 @@ function CustomizableViewportOverlay({
|
||||
instanceNumber,
|
||||
viewportId,
|
||||
toolGroupService,
|
||||
isLight,
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -241,6 +245,8 @@ function CustomizableViewportOverlay({
|
||||
topRight={getContent(topRightCustomization, 'topRightOverlayItem')}
|
||||
bottomLeft={getContent(bottomLeftCustomization, 'bottomLeftOverlayItem')}
|
||||
bottomRight={getContent(bottomRightCustomization, 'bottomRightOverlayItem')}
|
||||
color={isLight ? 'text-neutral-dark' : 'text-neutral-light'}
|
||||
shadowClass={isLight ? 'shadow-light' : 'shadow-dark'}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -375,6 +381,7 @@ function OverlayItem(props) {
|
||||
|
||||
/**
|
||||
* Window Level / Center Overlay item
|
||||
* //
|
||||
*/
|
||||
function VOIOverlayItem({ voi, customization }: OverlayItemProps) {
|
||||
const { windowWidth, windowCenter } = voi;
|
||||
@@ -387,9 +394,9 @@ function VOIOverlayItem({ voi, customization }: OverlayItemProps) {
|
||||
className="overlay-item flex flex-row"
|
||||
style={{ color: customization?.color }}
|
||||
>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.67]">W:</span>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.70]">W:</span>
|
||||
<span className="mr-2.5 shrink-0">{windowWidth.toFixed(0)}</span>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.67]">L:</span>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.70]">L:</span>
|
||||
<span className="shrink-0">{windowCenter.toFixed(0)}</span>
|
||||
</div>
|
||||
);
|
||||
@@ -404,7 +411,7 @@ function ZoomOverlayItem({ scale, customization }: OverlayItemProps) {
|
||||
className="overlay-item flex flex-row"
|
||||
style={{ color: (customization && customization.color) || undefined }}
|
||||
>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.67]">Zoom:</span>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.70]">Zoom:</span>
|
||||
<span>{scale.toFixed(2)}x</span>
|
||||
</div>
|
||||
);
|
||||
@@ -428,7 +435,7 @@ function InstanceNumberOverlayItem({
|
||||
<span>
|
||||
{instanceNumber !== undefined && instanceNumber !== null ? (
|
||||
<>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.67]">I:</span>
|
||||
<span className="mr-0.5 shrink-0 opacity-[0.70]">I:</span>
|
||||
<span>{`${instanceNumber} (${imageIndex + 1}/${numberOfSlices})`}</span>
|
||||
</>
|
||||
) : (
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import React, { useEffect, useState, useMemo, useRef } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { metaData, Enums, Types, getEnabledElement } from '@cornerstonejs/core';
|
||||
import {
|
||||
metaData,
|
||||
Enums,
|
||||
Types,
|
||||
getEnabledElement,
|
||||
utilities as coreUtilities,
|
||||
} from '@cornerstonejs/core';
|
||||
import { utilities } from '@cornerstonejs/tools';
|
||||
import { vec3 } from 'gl-matrix';
|
||||
|
||||
import './ViewportOrientationMarkers.css';
|
||||
|
||||
import { useViewportRendering } from '../../hooks';
|
||||
const { getOrientationStringLPS, invertOrientationStringLPS } = utilities.orientation;
|
||||
|
||||
function ViewportOrientationMarkers({
|
||||
@@ -20,6 +26,7 @@ function ViewportOrientationMarkers({
|
||||
const [rotation, setRotation] = useState(0);
|
||||
const [flipHorizontal, setFlipHorizontal] = useState(false);
|
||||
const [flipVertical, setFlipVertical] = useState(false);
|
||||
const { isViewportBackgroundLight: isLight } = useViewportRendering(viewportId);
|
||||
const { cornerstoneViewportService } = servicesManager.services;
|
||||
|
||||
// Store initial viewUp and viewRight for volume viewports
|
||||
@@ -151,7 +158,8 @@ function ViewportOrientationMarkers({
|
||||
className={classNames(
|
||||
'overlay-text',
|
||||
`${m}-mid orientation-marker`,
|
||||
'text-highlight/65',
|
||||
isLight ? 'text-neutral-dark/70' : 'text-neutral-light/70',
|
||||
isLight ? 'shadow-light' : 'shadow-dark',
|
||||
'text-base',
|
||||
'leading-5'
|
||||
)}
|
||||
@@ -168,6 +176,7 @@ function ViewportOrientationMarkers({
|
||||
flipHorizontal,
|
||||
orientationMarkers,
|
||||
element,
|
||||
isLight,
|
||||
]);
|
||||
|
||||
return <div className="ViewportOrientationMarkers select-none">{markers}</div>;
|
||||
|
||||
Reference in new issue
Block a user