Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(side-panels): Added resize handle interactive feedback for side panels #4734

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jbocce
Copy link
Collaborator

@jbocce jbocce commented Jan 24, 2025

Context

Provide some feedback that indicates the side panels are resizable. In particular change the colour of the divider separating the side panel from the viewport grid on hover and while dragging to resize the side panel.

Special thanks to @dan-rukas for input on the design and to @IbrahimCSAE for the refactoring that preceded this PR. The code , functionality and design are all much better thanks to you.

Changes & Results

handle.styling.mp4

Testing

Hover over the area between either side panel and the viewport grid. That area should change colour and show a thin rectangle with rounded corners. Drag that area/rectangle to resize the side panel. @dan-rukas please provide feedback on the colour, it sometimes feels a little muted next to the bright border of the viewport grid. Thanks.

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • OS: Windows 11
  • Node version: 20.9.0
  • Browser: Chrome 131.0.6778.265

Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for ohif-platform-docs canceled.

Name Link
🔨 Latest commit b4aa64b
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/67938f50fe767600082188a5

@@ -34,7 +34,7 @@ const useResizablePanels = (
);
const [leftResizablePanelMinimumSize, setLeftResizablePanelMinimumSize] = useState(0);
const [rightResizablePanelMinimumSize, setRightResizablePanelMinimumSize] = useState(0);
const [leftResizeablePanelCollapsedSize, setLeftResizePanelCollapsedSize] = useState(0);
const [leftResizablePanelCollapsedSize, setLeftResizePanelCollapsedSize] = useState(0);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling police. 🤣

Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/6793b0764e0ff976d111068a
😎 Deploy Preview https://deploy-preview-4734--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chunk of code is from an earlier implementation and is no longer needed. It was an attempt to handle an extreme edge case when the viewport grid is zero width. However it is such an extreme edge case that actually is handled fairly well by the underlying library now that we respond better to window resizing.

}, []);

/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nice utility functions for converting between pixels and percentages. Much more important now that we have handles of width > 0.

@@ -1,6 +1,6 @@
const expandedInsideBorderSize = 4;
const expandedInsideBorderSize = 0;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Former borders are now used by the handles.

@@ -27,7 +27,7 @@ const ResizableHandle = ({
}) => (
<ResizablePrimitive.PanelResizeHandle
className={cn(
'bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90',
"[&[data-resize-handle-state='hover']]:bg-primary/40 [&[data-resize-handle-state='drag']]:bg-primary/40 focus-visible:ring-ring relative flex w-1 items-center justify-center rounded-full after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",
Copy link
Collaborator Author

@jbocce jbocce Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put styling that will likely apply to ANY/ALL resize handles that will be used in OHIF here. I put width in here too, but it can be moved out as well. Let me know.

@@ -9,6 +9,8 @@ import SidePanelWithServices from '../Components/SidePanelWithServices';
import { Onboarding, ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@ohif/ui-next';
import useResizablePanels from './ResizablePanelsHook';

const resizableHandleClassName = 'mt-[1px] bg-black';
Copy link
Collaborator Author

@jbocce jbocce Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Styling for handles particular to the side panels use of the resizable panels library.

@@ -136,7 +136,7 @@ const createStyleMap = (
collapsedInsideBorderSize: number,
collapsedOutsideBorderSize: number
): StyleMap => {
const collapsedHideWidth = expandedWidth - collapsedWidth - collapsedInsideBorderSize;
const collapsedHideWidth = expandedWidth - collapsedWidth - collapsedOutsideBorderSize;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, I had the collapsed inside and outside borders swapped. Silly me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant