-
Notifications
You must be signed in to change notification settings - Fork 5
Add useQRCode hook #134
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
Add useQRCode hook #134
Conversation
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.
This hook+component pair seems a bit too specific for me, especially because of the saveOnClick
effect the hook returns. I feel like a more general approach would be to have it return an effect that produces the SVG blob/data URL, so the consumer can choose what to do with it, be it saving to a file, printing it, or whatever.
src/Lumi/Components2/QRCode.purs
Outdated
, level: errorCorrectLevelToString level | ||
, renderAs: "svg" | ||
, xmlns: "http://www.w3.org/2000/svg" | ||
, size: 126 |
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.
I feel like the size
should be configurable here.
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.
I ended up removing it which leaves the hard-coded sizing off of the svg element. The size can still be specified with styles, allowing other units or relative sizing.
Hmm, maybe. You mean more like |
I'd actually thought of still returning the |
Got it. I'm going to try a variation in a bit using a different library and see how that feels. I like the library better overall, especially when we get to future requirements like logo overlays. |
ready to re-review |
Feel free to ignore this, but in order to test the UI capabilities of this component I added an additional example in |
I ended up making this a hook which renders an svg in order to package up the rendering and "save on click" behavior into a single function without exposing the internal bits like refs. It leaves the style open for the consumer to control.