-
-
{shareUrl}
-
+
+
+
diff --git a/examples/buddybook/src/components/QRCode.tsx b/examples/buddybook/src/components/QRCode.tsx
index 889f6d5..98c3974 100644
--- a/examples/buddybook/src/components/QRCode.tsx
+++ b/examples/buddybook/src/components/QRCode.tsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import { QRCodeSVG } from 'qrcode.react';
import { Button } from "@/components/ui/button";
import { Check, Copy } from "lucide-react";
@@ -7,11 +7,37 @@ interface QRCodeProps {
text: string;
width?: number;
height?: number;
+ showCopyButton?: 'icon' | 'text' | 'both';
+ title?: string;
+ description?: string;
}
-const QRCode: React.FC
= ({ text, width = 256, height = 256 }) => {
+const QRCode: React.FC = ({
+ text,
+ width = 256,
+ height = 256,
+ showCopyButton = 'both',
+ title,
+ description
+}) => {
const [copied, setCopied] = useState(false);
- const isMobile = window.innerWidth < 640;
+ const [isMobile, setIsMobile] = useState(false);
+ const [qrSize, setQrSize] = useState(Math.min(width, height));
+
+ useEffect(() => {
+ const checkMobile = () => {
+ setIsMobile(window.innerWidth < 640);
+ setQrSize(
+ window.innerWidth < 640
+ ? Math.min(window.innerWidth - 80, 200)
+ : Math.min(width, height)
+ );
+ };
+
+ checkMobile();
+ window.addEventListener('resize', checkMobile);
+ return () => window.removeEventListener('resize', checkMobile);
+ }, [width, height]);
const handleCopy = async () => {
await navigator.clipboard.writeText(text);
@@ -19,28 +45,66 @@ const QRCode: React.FC = ({ text, width = 256, height = 256 }) => {
setTimeout(() => setCopied(false), 2000);
};
+ const handleShare = async () => {
+ if (navigator.share) {
+ try {
+ await navigator.share({
+ title: title || 'Share Chain',
+ text: description || 'Sign this chain',
+ url: text
+ });
+ } catch (error) {
+ if (error instanceof Error && error.name !== 'AbortError') {
+ console.error('Error sharing:', error);
+ }
+ }
+ } else {
+ handleCopy();
+ }
+ };
+
return (
-
-
-
-
+
+
-
+
+ {showCopyButton !== 'text' && (
+
+
+
+
+ )}
+
+ {showCopyButton === 'text' && (
+
+ )}
);
};
diff --git a/examples/buddybook/src/components/ui/dialog.tsx b/examples/buddybook/src/components/ui/dialog.tsx
index 0e36c68..0946c1b 100644
--- a/examples/buddybook/src/components/ui/dialog.tsx
+++ b/examples/buddybook/src/components/ui/dialog.tsx
@@ -35,14 +35,12 @@ const DialogContent = React.forwardRef<