From b2bd3587bfd42ec8efdab12f090996f600720c0d Mon Sep 17 00:00:00 2001 From: Leo Goetz Date: Fri, 8 May 2026 15:43:50 +0200 Subject: inital commit --- src/components/VCardExport.tsx | 88 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/components/VCardExport.tsx (limited to 'src/components/VCardExport.tsx') diff --git a/src/components/VCardExport.tsx b/src/components/VCardExport.tsx new file mode 100644 index 0000000..82afa59 --- /dev/null +++ b/src/components/VCardExport.tsx @@ -0,0 +1,88 @@ +import { Button } from "@/components/ui/button"; +import { + Card, + CardDescription, + CardHeader, + CardTitle, + CardFooter, +} from "@/components/ui/card"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { useEffect, useRef, useState } from "react"; +import QRCode from "qrcode"; + +interface VCardExportProps { + sectionChange: (section: string) => void; + vcardText: any; +} + +export default function VCardExport({ + sectionChange, + vcardText, +}: VCardExportProps) { + const canvasRef = useRef(null); + const [resolution, setResolution] = useState("512"); + + useEffect(() => { + if (canvasRef.current) { + QRCode.toCanvas(canvasRef.current, vcardText, { + width: 256, + margin: 2, + }).catch(console.error); + } + }, [vcardText]); + + const downloadQRCode = () => { + const offscreenCanvas = document.createElement("canvas"); + QRCode.toCanvas(offscreenCanvas, vcardText, { + width: Number(resolution), + margin: 2, + }) + .then(() => { + const pngUrl = offscreenCanvas.toDataURL("image/png"); + const link = document.createElement("a"); + link.href = pngUrl; + link.download = "vcard_qrcode.png"; + link.click(); + }) + .catch(console.error); + }; + + return ( + + + VCard Qrcode + + Sie können nun die Größe (Standard = 512x512px) auswählen und den + QRCode downloaden. + + + + + + + + + + + + 1024x1024 + + 512x512 + 256x256 + + + {" "} + + + + ); +} -- cgit v1.3.1