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

Is there some way we could make a previewModo for react-to-print? #62

Closed
tnrich opened this issue Oct 29, 2018 · 5 comments
Closed

Is there some way we could make a previewModo for react-to-print? #62

tnrich opened this issue Oct 29, 2018 · 5 comments

Comments

@tnrich
Copy link

tnrich commented Oct 29, 2018

Hey there @gregnb,

I was thinking it might be cool to add a way to preview what exactly is going to be printed before actually getting to the print dialog. I was playing around with this a little bit on my own here: https://codesandbox.io/s/k28lq14z7o

I am not sure if this is really a good idea or not but I found it hard to mess around with how things looked jumping back and forth between the real print window. Just an idea.

@MatthewHerbst
Copy link
Owner

What's wrong with the preview dialog the browser gives you?

@tnrich
Copy link
Author

tnrich commented Nov 1, 2018

@MatthewHerbst thanks for getting back to me and for the nice work on the malformed links ;)

I don't think it is possible to change the css of the stuff being printed once you're in the browser dialog. Say you're trying to size an svg to fit nicely on the print window, it would be nicer to do that in a fake preview mode where you can play with the css in the devtools as opposed to opening and closing the print preview dialog over and over as you tweak the css. Does that make sense?

Maybe there is already a way to get what I want but I couldn't find one.

@MatthewHerbst
Copy link
Owner

Ah, got it. Hmm. Seems like this would be a good chance to investigate using React Portals, though that would require us forcing newer React 16 versions which I personally wouldn't love since my company is still on 15 😢 but maybe we could make it in a way where it just does a noop if you're still on a version that doesn't have portals?

@tnrich
Copy link
Author

tnrich commented Nov 1, 2018

@MatthewHerbst or we could just continue using the iframe approach? I think my codesandbox illustrates how that approach could work. It definitely needs some work to make it nicer.

@MatthewHerbst
Copy link
Owner

That works too! Just been reading about all the shiny things in React 16, and, they are shiny! Once concern: assuming the iframe should work and not just be static content, will app JS continue to function normally in iframes in all scenarios? I think there are ways to set it up properly, just have to be careful. Here's an example on SO: https://stackoverflow.com/questions/34743264/how-to-set-iframe-content-of-a-react-component

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

No branches or pull requests

2 participants