-
Notifications
You must be signed in to change notification settings - Fork 48
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
Client-side printing with Vue #3532
Conversation
e5c05b0
to
d2a6438
Compare
Deployment is generating errors: https://github.com/ecamp/ecamp3/actions/runs/5431444930 |
⛔ Feature branch deployment currently inactive.If the PR is still open, you can add the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you very much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions for the CoreMeeting:
- Does nodeOps.js need to be complete?
- How big do we estimate the maintenance effort?
- How do we determine if there are additional requirements for nodeOps.js in the future?
This makes us more robust against new elements which react-pdf might introduce in the future.
In a nutshell: Replaces React with Vue 3, but keeps the client-side printing capabilities of react-pdf. It looks and feels exactly like the existing react-pdf implementation, but is implemented using Vue components instead of React JSX files.
How does this work?
React-pdf consists of several modules:
Only the first module (@react-pdf/renderer) actually has anything to do with React. All the other modules are framework-agnostic.
This PR adds a Vue 3 custom renderer which does the same as @react-pdf/renderer does, but with Vue 3. There have been several attempts at similar renderers documented on the internet [1] [2], although none of them went far enough to be really practical.
The biggest hurdle I had to overcome was that we cannot install Vue 2 and Vue 3 alongside each other in our frontend. For this reason, I created a new separate
pdf
module as a Vue 3 project. This module is built usingvite build --watch
whenever some PDF code is changed, and the resulting output file is imported in our normal frontend code. The bundled pdf module code is ~400KB and is typically rebuilt within less than a second. This way, we can develop with hot module reloading on the PDF preview.Additional features
<pdf-style></pdf-style>
blocks in the .vue files<Text>
tags, global helpers such asthis.$date
orthis.$tc
orthis.api
are more natural to use in Vue than in React/JSX)Open TODOs
Auto-remove optionalnot doing that for now, to avoid cascading style issuesdisplay: flex
statements during compile time (flex is the default display in react-pdf)htmlToPdfElementMap
, and see how that feels for devs