ui(components): Viewport components updated to ui-next with design updates (#4886)

This commit is contained in:
Dan Rukas authored and GitHub committed 2025-04-07 16:45:05 -04:00
1 parent 4e09f85d5d
commit a8ac297e16
53 files changed
+933 -326

No files matched your search

@@ -0,0 +1,85 @@
/* Scrollbar container */
.scrollbarContainer {
position: absolute;
right: 0;
top: 0;
height: 100%;
padding: 5px 5px 0 5px;
z-index: 10;
}
.scrollbarInner {
position: relative;
height: 100%;
width: 11px;
}
/* Apply these styles to any range input inside our component */
.scrollbarInput {
position: absolute;
left: 12px;
top: 0;
height: 12px;
transform: rotate(90deg);
transform-origin: top left;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: transparent;
padding: 0;
}
/* Thumb styles for WebKit browsers - more specific selector */
input[type='range'].scrollbarInput::-webkit-slider-thumb {
-webkit-appearance: none !important;
background-color: hsl(var(--input));
border: none;
border-radius: 57px;
cursor: -webkit-grab;
height: 8px;
margin-top: -4px;
width: 32px;
}
input[type='range'].scrollbarInput::-webkit-slider-thumb:active,
input[type='range'].scrollbarInput::-webkit-slider-thumb:hover {
background-color: hsl(var(--primary));
cursor: -webkit-grabbing;
}
/* Thumb styles for Firefox - more specific selector */
input[type='range'].scrollbarInput::-moz-range-thumb {
background-color: hsl(var(--input));
border: none;
border-radius: 57px;
cursor: -moz-grab;
height: 12px;
width: 39px;
}
input[type='range'].scrollbarInput::-moz-range-thumb:active,
input[type='range'].scrollbarInput::-moz-range-thumb:hover {
background-color: hsl(var(--primary));
cursor: -moz-grabbing;
}
/* Track styles for WebKit browsers - more specific selector */
input[type='range'].scrollbarInput::-webkit-slider-runnable-track {
background-color: transparent;
border: none;
cursor: pointer;
height: 5px;
}
/* Track styles for Firefox - more specific selector */
input[type='range'].scrollbarInput::-moz-range-track {
background-color: transparent;
border: none;
cursor: pointer;
height: 2px;
}
/* Ensure focus doesn't show an outline */
.scrollbarInput:focus {
outline: none;
}
@@ -0,0 +1,72 @@
import React, { useCallback } from 'react';
import { cn } from '../../lib/utils';
import styles from './ImageScrollbar.module.css';
export interface ImageScrollbarProps {
value: number;
max: number;
height: string;
onChange: (value: number) => void;
onContextMenu?: (e: React.MouseEvent) => void;
className?: string;
}
export const ImageScrollbar: React.FC<ImageScrollbarProps> = ({
value,
max,
height,
onChange,
onContextMenu = e => e.preventDefault(),
className = '',
}) => {
if (max === 0) {
return null;
}
const style = {
width: height, // This is intentional for the rotation
};
const handleChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
const intValue = parseInt(event.target.value, 10);
onChange(intValue);
},
[onChange]
);
const handleKeyDown = useCallback((event: React.KeyboardEvent) => {
// We don't allow direct keyboard navigation (arrow keys)
const keys = {
DOWN: 40,
UP: 38,
};
if (event.which === keys.DOWN || event.which === keys.UP) {
event.preventDefault();
}
}, []);
return (
<div
className={cn(styles.scrollbarContainer, className)}
onContextMenu={onContextMenu}
>
<div className={styles.scrollbarInner}>
<input
className={cn(styles.scrollbarInput, 'mousetrap')}
style={style}
type="range"
min="0"
max={max}
step="1"
value={value}
onChange={handleChange}
onKeyDown={handleKeyDown}
aria-label="Image navigation scrollbar"
data-testid="image-scrollbar-input"
/>
</div>
</div>
);
};
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { Icons } from '@ohif/ui-next';
const arrowClasses =
'cursor-pointer flex items-center justify-center shrink-0 text-primary-light active:text-white hover:bg-secondary-light/60 rounded';
'cursor-pointer flex items-center justify-center shrink-0 text-highlight active:text-foreground hover:bg-primary/30 rounded';
/**
* A small set of left/right arrow icons for stepping through slices or series.
@@ -13,7 +13,7 @@ export enum ViewportActionCornersLocations {
bottomRight,
}
const commonClasses = 'pointer-events-auto flex items-center gap-1';
const commonClasses = 'pointer-events-auto flex items-center';
const locationClasses = {
[ViewportActionCornersLocations.topLeft]: classNames(
commonClasses,
@@ -21,7 +21,7 @@ const locationClasses = {
),
[ViewportActionCornersLocations.topRight]: classNames(
commonClasses,
'absolute top-[4px] right-[4px] right-viewport-scrollbar'
'absolute top-[4px] right-[16px] right-viewport-scrollbar'
),
[ViewportActionCornersLocations.bottomLeft]: classNames(
commonClasses,
@@ -64,4 +64,4 @@ ViewportActionCorners.propTypes = {
cornerComponents: PropTypes.object.isRequired,
};
export { ViewportActionCorners };
export { ViewportActionCorners };
@@ -2,7 +2,7 @@
display: none;
}
.ViewportOverlay {
color: #9ccef9;
color: hsl(var(--highlight));
}
.ViewportOverlay .overlay-element {
position: absolute;
@@ -11,12 +11,12 @@
pointer-events: none;
}
.overlay-top {
top: 28px;
top: 2.15rem;
}
.overlay-bottom {
bottom: 3px;
bottom: 1rem;
}
.overlay-text {
text-shadow: 0.8px 0.8px 0.5px rgba(0, 0, 0, 0.75);
text-shadow: 0.8px 0.8px 0.5px rgba(0, 0, 0, 0.65);
}
@@ -17,17 +17,11 @@ const classes = {
bottomLeft: 'overlay-bottom left-viewport',
};
function ViewportOverlay({
topLeft,
topRight,
bottomRight,
bottomLeft,
color = 'text-primary-light',
}) {
function ViewportOverlay({ topLeft, topRight, bottomRight, bottomLeft, color = 'text-highlight' }) {
const overlay = 'absolute pointer-events-none viewport-overlay';
return (
<div className={classNames(color, 'overlay-text text-[13px] leading-5')}>
<div className={classNames(color, 'overlay-text text-base leading-5')}>
<div
data-cy="viewport-overlay-top-left"
className={classNames(overlay, classes.topLeft)}
@@ -37,14 +31,14 @@ function ViewportOverlay({
<div
data-cy="viewport-overlay-top-right"
className={classNames(overlay, classes.topRight)}
style={{ transform: 'translateX(-8px)' }}
style={{ transform: 'translateX(9px)' }}
>
{topRight}
</div>
<div
data-cy="viewport-overlay-bottom-right"
className={classNames(overlay, classes.bottomRight)}
style={{ transform: 'translateX(-8px)' }}
style={{ transform: 'translateX(6px)' }}
>
{bottomRight}
</div>
@@ -68,8 +68,8 @@ function ViewportPane({
{/* Border overlay */}
<div
className={classNames('pointer-events-none absolute inset-0', {
'border-primary-light border': isActive,
'group-hover:border-primary-light/70 border border-transparent': !isActive,
'border-highlight rounded-md border': isActive,
'group-hover:border-highlight/50 rounded-md border border-transparent': !isActive,
})}
/>
</div>
@@ -6,3 +6,4 @@ export { ViewportPane } from './ViewportPane';
export { ViewportActionCorners, ViewportActionCornersLocations } from './ViewportActionCorners';
export { ViewportOverlay } from './ViewportOverlay';
export { ViewportGrid } from './ViewportGrid';
export { ImageScrollbar } from './ImageScrollbar';