Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Fixes EddieHubCommunity/BioDrop#8640 Updated QR to use next-qrcode. #9196

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions components/user/UserProfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useRef, useState } from "react";
import { FaShare } from "react-icons/fa6";
import { QRCodeCanvas } from "qrcode.react";
import { useQRCode } from "next-qrcode";
import { saveAs } from "file-saver";
import { useRouter } from "next/router";

Expand All @@ -25,6 +25,8 @@ function UserProfile({ BASE_URL, data }) {
//Declared Ref object for QR
const qrRef = useRef(null);

const { Canvas } = useQRCode();

//qrRef.current is pointing to the DOM node and firstChild to its canvas
const downloadQR = () =>
qrRef.current.firstChild.toBlob((blob) =>
Expand Down Expand Up @@ -132,10 +134,21 @@ function UserProfile({ BASE_URL, data }) {
<div>
<div className="flex justify-center my-4" ref={qrRef}>
{qrShow && (
<QRCodeCanvas
<Canvas
text={`${BASE_URL}/${data.username}`}
className="border border-white"
value={`${BASE_URL}/${data.username}`}
size={fallbackImageSize * 2}
logo={{
src: `${BASE_URL}/logo192.png`,
options: { width: 50 },
}}
options={{
margin: 1,
width: fallbackImageSize * 2,
color: {
dark: "#122640",
light: "#f2f7ff",
},
}}
/>
)}
</div>
Expand All @@ -156,7 +169,7 @@ function UserProfile({ BASE_URL, data }) {
href={`${SOCIAL_SHARE_LINK}${BASE_URL}/${data.username}${
includeText
? `&text=${encodeURIComponent(
`Check out ${data.name}'s profile on BioDrop.io`
`Check out ${data.name}'s profile on BioDrop.io`,
)}`
: ""
}`}
Expand Down
222 changes: 214 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"mongoose": "^7.5.0",
"next": "^13.4.12",
"next-auth": "^4.22.3",
"next-qrcode": "^2.5.1",
"next-themes": "^0.2.1",
"pino": "^8.14.1",
"pino-pretty": "^10.1.0",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-children-utilities": "^2.9.0",
"react-dom": "^18.2.0",
Expand Down Expand Up @@ -117,4 +117,4 @@
"bugs": {
"url": "https://github.com/EddieHubCommunity/BioDrop/issues"
}
}
}