Skip to content

Commit 8a7b246

Browse files
committed
feat(neuron-ui): add a blank margin around the QRCode for improving recognization
1 parent 7db3a9b commit 8a7b246

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

packages/neuron-ui/src/components/Receive/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const Receive = ({
6363
onQRCodeClick={() => setShowLargeQRCode(true)}
6464
size={256}
6565
exportable
66+
includeMargin
6667
dispatch={dispatch}
6768
/>
6869
</Stack>

packages/neuron-ui/src/widgets/QRCode/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,18 @@ const QRCode = ({
102102
qrcode.make()
103103

104104
const cells = qrcode.modules || []
105-
const margin = includeMargin ? 4 : 0
105+
const margin = includeMargin ? 1 : 0
106106
const fgPath = generatePath(cells, margin)
107107
const numCells = cells.length + margin * 2
108108

109-
const svgStr = `<svg shapeRendering="crispEdges" height="${scale * size}" width="${scale *
110-
size}" viewBox="0 0 ${numCells} ${numCells}" ><path fill="${bgColor}" d="M0, 0 h${numCells} v${numCells} H0z" /><path fill="${fgColor}" d="${fgPath}" /></svg>`
109+
const svgStr = `<svg shapeRendering="crispEdges"
110+
width="${scale * size}"
111+
height="${scale * size}"
112+
viewBox="0 0 ${numCells} ${numCells}"
113+
>
114+
<path fill="${bgColor}" d="M0, 0 h${numCells} v${numCells} H0z" />
115+
<path fill="${fgColor}" d="${fgPath}" />
116+
</svg>`
111117

112118
const onDownload = useCallback(() => {
113119
if (canvasRef.current === null) {
@@ -147,7 +153,7 @@ const QRCode = ({
147153
}, [svgStr, size])
148154

149155
return (
150-
<Stack tokens={{ childrenGap: 15 }}>
156+
<Stack tokens={{ childrenGap: 15 }} horizontalAlign="center" verticalAlign="center">
151157
<Stack.Item>
152158
<canvas ref={canvasRef} width={size} height={size} onClick={onQRCodeClick} />
153159
</Stack.Item>

0 commit comments

Comments
 (0)