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

Sidebar optimisation as separate panel instead of overlay #289

Merged
merged 7 commits into from
Oct 27, 2023

Conversation

peteward
Copy link
Collaborator

@peteward peteward commented Oct 25, 2023

implements #248

IMPROVEMENTS:

  • Use a dedicated panel for the sidebar, instead of an overlay, to give more effective use of space.

Screenshot 2023-10-26 at 13 26 31

Screenshot 2023-10-26 at 13 26 38

  • Fix a bug where the container would not appropriately resize (with the correct canvas size for scrollbars) after zooming until an element was selected.
Screen.Recording.2023-10-26.at.13.22.34.mov
  • Fix a bug where the left-hand side of content will be cropped:
Screen.Recording.2023-10-26.at.13.20.58.mov
  • Fix double (and sometimes triple) scrollbar issues:

Screenshot 2023-10-26 at 13 19 01

@@ -35,10 +35,7 @@ const CtlBar = (props: Props) => {
}}
>
{pageNum > 1 && (
<>
<Pager pageCursor={pageCursor} pageNum={pageNum} setPageCursor={setPageCursor} />
<strong style={{ color: 'white', fontSize: '0.9rem', padding: 0 }}>|</strong>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the | separator as I thought it looked better with just space but I can re-add

@@ -247,12 +253,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
onEditEnd();
}}
zoomLevel={zoomLevel}
setZoomLevel={(zoom) => {
if (mainRef.current) {
mainRef.current.scrollTop = getPagesScrollTopByIndex(pageSizes, pageCursor, scale);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to align the left scroll centrally but this did not seem worth the effort.
Similarly, I didn't think pulling the viewport to the top was good UX, it felt OK to just zoom in / out from where you were.

...size,
transformOrigin: 'top left',
// NOTE: These values do not apply, but changing them with scale ensures the
// container is updated to show appropriately sized scrollbars when you zoom in/out.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there is probably a better way of doing this

@hand-dot
Copy link
Collaborator

test and reviewing

@hand-dot
Copy link
Collaborator

Also, I'll fix main branch failing test. sorry

@hand-dot
Copy link
Collaborator

hand-dot commented Oct 26, 2023

Very cool. this is a ideal sidebar position...! thank you.

designer


but i fond bug, when i set multi page pdf template to form or viewer, PDF pages overflow the root element.
I gonna investigate code changes.

CleanShot 2023-10-26 at 09 30 21

also, when i set multi page pdf as besePdf to designer, we can see wrong position CtlBar.

CleanShot 2023-10-26 at 09 40 41@2x

you can reproduce from this template.json.


This behavior should be maintained.

1026.1.mov

So, we need check this pattern

  • Designer
    • Single page basePdf template
    • Multi page basePdf template
  • Form
    • Single page basePdf template
    • Multi page basePdf template
  • Viewer
    • Single page basePdf template
    • Multi page basePdf template

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please explain the changes to this file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The CtlBar is absolutely positioned to its container.
The outer div places the CtrlBar in the correct place.
The inner div no longer needs any special positioning. Sticky is not required because the div is absolute to the parent and does not move.

@hand-dot
Copy link
Collaborator

hand-dot commented Oct 26, 2023

↑ Pulled the main branch and incorporated fixes for tests and rotation.
@peteward can you pull latest 248-sidebar-optimisation?

@peteward
Copy link
Collaborator Author

I'm looking into this now 👀

consolidate use of sizeExclSizebar
@peteward
Copy link
Collaborator Author

I think this is all working fine now - I have updated the PR description with information about the changes.

I didn't have any problem with the position of the CtrlBar though on the Designer, I'm not sure how you were seeing that 🤔

Single Page Designer:

Screen.Recording.2023-10-26.at.14.39.22.mov

@peteward
Copy link
Collaborator Author

Single Page Viewer:

Screen.Recording.2023-10-26.at.14.40.45.mov

@peteward
Copy link
Collaborator Author

Multi-page Designer:

Screen.Recording.2023-10-26.at.14.46.01.mov

@peteward
Copy link
Collaborator Author

Multi-page Viewer:

Screen.Recording.2023-10-26.at.14.47.08.mov

}

const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I renamed this to Canvas as it felt more specific than Main, but I will revert if you disagree.

@@ -247,7 +253,15 @@ const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
.every((schema) => schema.rotate !== undefined);

return (
<div ref={ref} style={{ overflow: 'overlay' }}>
Copy link
Collaborator Author

@peteward peteward Oct 26, 2023

Choose a reason for hiding this comment

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

overflow: overlay was deprecated a while ago and does not have consistent support. We're using overflow: scroll or auto now where needed.

);
}}
/>
<div ref={containerRef} style={{ ...size, position: 'relative', overflow: 'auto' }}>
Copy link
Collaborator Author

@peteward peteward Oct 26, 2023

Choose a reason for hiding this comment

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

I have changed Preview to be consistent with the Designer, with a wrapping Div which is the viewport/canvas for scrolling.

@peteward
Copy link
Collaborator Author

Hi @hand-dot,

Are these tests failing because it's taking a long time to run the generator integration tests?

I don't think I have made any changes here that would impact this... 🤔

@hand-dot
Copy link
Collaborator

Hi @hand-dot,

Are these tests failing because it's taking a long time to run the generator integration tests?

I don't think I have made any changes here that would impact this... 🤔

Sometime it occurs. Let's run again

@hand-dot
Copy link
Collaborator

Okay test is passing, I gonna check code tomorrow

Copy link
Collaborator

@hand-dot hand-dot left a comment

Choose a reason for hiding this comment

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

The UX of pdfme has significantly improved.

It's Saturday night in Japan right now, and I can enjoy a beer in the best mood.
Thank you for the amazing PR.

@hand-dot hand-dot merged commit 36041d8 into main Oct 27, 2023
2 checks passed
@hand-dot hand-dot deleted the 248-sidebar-optimisation branch November 9, 2023 00:35
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.

None yet

2 participants