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

qr-scanner component #248

Merged
merged 6 commits into from Jul 19, 2020
Merged

qr-scanner component #248

merged 6 commits into from Jul 19, 2020

Conversation

stepansnigirev
Copy link
Collaborator

@stepansnigirev stepansnigirev commented Jul 18, 2020

Another custom component - qr scanner.
You can use it as a normal html tag.
If you want to add a button to trigger scanner - put it into the button slot:

  <qr-scanner id="myscanner">
    <button class="btn" slot="button">Scan me!</button>
  </qr-scanner>

Then to trigger popup add attribute open. Or click on the elements placed to button slot.
When scan is complete or cancelled a custom event is triggered.
To get scanned data subscribe to scan event in your js code:

  document.getElementById('myscanner').addEventListener('scan', (e)=>{
    console.log(e.detail.result);
  });

e.detail.result is null if scan was cancelled, a string with data otherwise.

Copy link
Contributor

@ben-kaufman ben-kaufman left a comment

Choose a reason for hiding this comment

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

Looks good to me :) (tested with Specter DIY).

@stepansnigirev stepansnigirev merged commit 5e7c94a into cryptoadvance:master Jul 19, 2020
@stepansnigirev stepansnigirev deleted the qr-scanner branch July 19, 2020 15:36
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