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

resizable stage #9753

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Conversation

DanFessler
Copy link

Recording.2024-11-26.045749.mp4

Proposed Changes

This PR implements a drag-resizable stage panel which is also used as the "large" stage toggle. This is a purely additive quality-of-life feature that shouldn't change any behaviors users expect.

Reason for Changes

With higher DPI displays becoming more common on PCs and Tablets, the stage size options are a less-than-ideal "small" or "tiny." Often this means users rely on full-screen mode to check their work in more detail, but at the cost of losing the context of your code editor making iteration slow and annoying.

The solution is to have a more responsive user-customizable approach to displaying the stage. Users can set the stage size to whatever makes sense for their working environment. We can preserve the toggle functionality for users by allowing the "large" setting to be the user-defined draggable size.

This refactors some old code to be more flexible using react hooks to observe the size of the container elements to determine the necessary scale whereas the prior approach had a lot of hard-coded assumptions about the two size modes.

Resolves

While this PR isn't meant to be a bug-fix, it does address some undocumented issues:

  • Fixes dragging monitors in the "small" stage mode
  • Fixes the stage size when in full-screen mode to adapt to screen when resized

Browser Coverage

Check the OS/browser combinations tested (At least 2)

Mac

  • Chrome
  • Firefox
  • Safari

Windows

  • Chrome
  • Firefox
  • Edge

Chromebook

  • Chrome

iPad

  • Safari

Android Tablet

  • Chrome

no code changes
Copy link

github-actions bot commented Nov 26, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Author

Choose a reason for hiding this comment

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

This is a new "Box" wrapper which gives a drag-resizable handle on the left side of the container

@@ -207,9 +207,6 @@
/* pad entire wrapper to the left and right; allow children to fill width */
padding-left: $space;
padding-right: $space;

/* this will only ever be as wide as the stage */
flex-basis: 0;
Copy link
Author

Choose a reason for hiding this comment

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

needed to get rid of this to have dynamic sizing

}}
/>
);

Copy link
Author

Choose a reason for hiding this comment

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

react-draggable really did not like using a scaled container as the bounding reference, but we needed the scaling both visually as well as for proper drag deltas for the monitors. This dummy div of a constant width is a hacky solution that makes react-draggable happy. A better solution would likely be way more involved, perhaps replacing react-draggable entirely.

@@ -52,6 +52,7 @@ const MonitorComponent = props => (
defaultClassNameDragging={styles.dragging}
disabled={!props.draggable}
onStop={props.onDragEnd}
scale={props.scale}
Copy link
Author

Choose a reason for hiding this comment

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

drilling this scale prop to the draggable element corrects the drag deltas for different stage sizes

Copy link
Author

Choose a reason for hiding this comment

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

My changes to this file are purely superficial. now that the stage panel can get extra wide, it just looked silly to have the input fields spread across the entire width, so I made containers that act as a max-width for the controls

Copy link
Author

Choose a reason for hiding this comment

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

most of this work (and it's corresponding css) just enables the stage canvas to be the maximum size it can without overflowing its container.

Here we're also using the new useCanvasSize hook to get the dimensions we need

Copy link
Author

Choose a reason for hiding this comment

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

we need to update the canvas resolution when we resize the stage

Copy link
Author

Choose a reason for hiding this comment

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

replacing getStageDimensions with a more flexible react hook

@DanFessler
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

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