Skip to content

Commit f717364

Browse files
committed
Update to lean-qr 2
1 parent c85ade8 commit f717364

File tree

8 files changed

+17
-34
lines changed

8 files changed

+17
-34
lines changed

src/frontend/package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@openfonts/open-sans_all": "1.x",
1616
"classnames": "2.x",
1717
"json-immutability-helper": "3.x",
18-
"lean-qr": "1.x",
18+
"lean-qr": "2.x",
1919
"react": "18.x",
2020
"react-dom": "18.x",
2121
"react-hook-awaited": "1.x",

src/frontend/src/components/common/QR.less

-4
This file was deleted.
+4-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
1-
import React, { useRef, useEffect, memo } from 'react';
1+
import React from 'react';
22
import { generate, correction } from 'lean-qr';
3-
import './QR.less';
3+
import { makeAsyncComponent } from 'lean-qr/extras/react';
44

5-
interface PropsT {
6-
content: string;
7-
}
8-
9-
export default memo(({ content }: PropsT) => {
10-
const canvasRef = useRef<HTMLCanvasElement>(null);
11-
12-
useEffect(() => {
13-
if (canvasRef.current) {
14-
try {
15-
const code = generate(content, { minCorrectionLevel: correction.Q });
16-
code.toCanvas(canvasRef.current);
17-
} catch (e) {
18-
canvasRef.current.width = 1;
19-
canvasRef.current.height = 1;
20-
console.warn('Failed to render QR code', content);
21-
}
22-
}
23-
}, [canvasRef]);
24-
25-
return <canvas className="qr-code" ref={canvasRef} />;
5+
export default makeAsyncComponent(React, generate, {
6+
minCorrectionLevel: correction.Q,
267
});

src/frontend/src/components/retro/InvitePopup.less

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
width: ~'calc(80vh - 52px - 3.2em)';
2222
min-width: 350px;
2323
max-width: ~'calc(100vw - 96px)';
24+
aspect-ratio: 1;
2425
margin: 0 auto;
2526
}
2627

src/frontend/src/components/retro/InvitePopup.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default memo(({ onClose }: PropsT) => {
1414
<div className="popup-invite">
1515
<p>Attendees can join on their computer or phone:</p>
1616
<p className="link">{url}</p>
17-
<QR content={url} />
17+
<QR className="qr-code" content={url} />
1818
<p className="dialog-options">
1919
<WrappedButton onClick={onClose} className="primary">
2020
Close

src/frontend/src/test-helpers/entrypoint.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ import './ws';
55
import './timers';
66
import './consoleCheck';
77
import './crypto';
8+
import './textEncoder';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { TextEncoder } from 'node:util';
2+
3+
// https://github.com/jsdom/jsdom/issues/2524
4+
global.TextEncoder = TextEncoder;

0 commit comments

Comments
 (0)