Skip to content

Commit

Permalink
refactor: add svg example
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Oct 1, 2023
1 parent 2b9846e commit d626f0c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/browser-pre-built-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "browser-pre-built-bundle",
"author": "Roger Schönbächler",
"scripts": {
"start": "serve index.html"
"start": "serve"
},
"devDependencies": {
"serve": "^14.2.1"
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions examples/browser-pre-built-bundle/src/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const data = {
creditor: {
account: "CH58 0079 1123 0008 8901 2",
address: "Creditor Address",
city: "Creditor City",
country: "CH",
name: "Creditor FirstName LastName",
zip: 1234
},
currency: "CHF"
};
18 changes: 6 additions & 12 deletions examples/browser-pre-built-bundle/src/pdf.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
const data = {
creditor: {
account: "CH58 0079 1123 0008 8901 2",
address: "Creditor Address",
city: "Creditor City",
country: "CH",
name: "Creditor FirstName LastName",
zip: 1234
},
currency: "CHF"
};
import { data } from "./data.js";

const pdf = new PDFDocument({ size: "A4" });

const width = SwissQRBill.utils.mm2pt(210);

Check failure on line 4 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined

Check failure on line 4 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined
const height = SwissQRBill.utils.mm2pt(105);

Check failure on line 5 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined

Check failure on line 5 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined

const pdf = new PDFDocument({ size: [width, height] });

Check failure on line 7 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'PDFDocument' is not defined

Check failure on line 7 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'PDFDocument' is not defined
const stream = pdf.pipe(blobStream());

Check failure on line 8 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'blobStream' is not defined

Check failure on line 8 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'blobStream' is not defined
const qrBill = new SwissQRBill.PDF(data);

Check failure on line 9 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined

Check failure on line 9 in examples/browser-pre-built-bundle/src/pdf.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined

Expand Down
5 changes: 5 additions & 0 deletions examples/browser-pre-built-bundle/src/svg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { data } from "./data.js";


const qrBill = new SwissQRBill.SVG(data);

Check failure on line 4 in examples/browser-pre-built-bundle/src/svg.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined

Check failure on line 4 in examples/browser-pre-built-bundle/src/svg.js

View workflow job for this annotation

GitHub Actions / lint

'SwissQRBill' is not defined
document.body.appendChild(qrBill);
14 changes: 14 additions & 0 deletions examples/browser-pre-built-bundle/svg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/swissqrbill@alpha/lib/bundle/swissqrbill.js"
></script>
<script type="module" src="./src/svg.js"></script>
</head>
<body>
<iframe id="iframe"></iframe>
</body>
</html>

0 comments on commit d626f0c

Please sign in to comment.