Sunflower UI
Search
Copy Code
Light Mode
qr-code-demo.tsx
qr-code.tsx
prompt.md
Collapse
Reset
Copy Code
Download
Run
1
"use client";
2
3
import { useState } from "react";
4
import { QRCodeDisplay } from "./qr-code";
5
import { ChevronDown } from "lucide-react";
6
import { motion, AnimatePresence } from "framer-motion";
7
8
// SVG Logos for Cryptocurrencies
9
const BitcoinIcon = () => (
10
<svg viewBox="0 0 32 32" className="w-8 h-8 text-[#F7931A]" fill="currentColor">
11
<path d="M16 32C24.8366 32 32 24.8366 32 16C32 7.16344 24.8366 0 16 0C7.16344 0 0 7.16344 0 16C0 24.8366 7.16344 32 16 32Z" />
12
<path fill="white" d="M23.189 13.021C23.605 10.231 21.467 8.7 18.665 7.734L19.223 5.488L17.848 5.146L17.3 7.359C16.94 7.27 16.574 7.185 16.208 7.103L16.764 4.875L15.39 4.533L14.828 6.797C14.512 6.726 14.2 6.657 13.882 6.58L11.516 5.992L11.062 7.822C11.062 7.822 12.336 8.106 12.308 8.17C13.003 8.343 13.129 8.814 13.102 9.175L12.023 13.52C12.08 13.534 12.167 13.561 12.261 13.61L12.014 14.597L10.518 20.612C10.373 21.054 10.05 21.218 9.387 21.052C9.418 21.119 8.144 20.803 8.144 20.803L7.309 22.825L9.553 23.383C9.9 23.469 10.24 23.559 10.577 23.64L10.015 25.908L11.39 26.25L11.946 24.004C12.316 24.098 12.68 24.185 13.037 24.269L12.479 26.522L13.854 26.864L14.417 24.582C17.653 25.204 20.07 24.819 20.916 21.849C21.602 19.444 20.764 18.064 19.063 17.157C20.354 16.859 21.328 15.932 21.579 14.168L23.189 13.021ZM18.257 21.134C17.618 23.709 13.315 22.42 11.533 21.977L12.348 18.704C14.13 19.146 18.924 19.957 18.257 21.134ZM18.966 14.629C18.388 16.953 14.778 15.91 13.298 15.542L14.032 12.593C15.512 12.96 19.569 13.67 18.966 14.629Z" />
13
</svg>
14
);
15
16
const EthereumIcon = () => (
17
<svg viewBox="0 0 32 32" className="w-8 h-8 text-[#627EEA]" fill="currentColor">
18
<path d="M16 32C24.8366 32 32 24.8366 32 16C32 7.16344 24.8366 0 16 0C7.16344 0 0 7.16344 0 16C0 24.8366 7.16344 32 16 32Z" />
19
<path fill="white" d="M15.86 21.688L7.69702 16.863L15.86 28.329L24.037 16.863L15.86 21.688ZM16.14 4.04102L7.97998 15.539L16.14 19.387L24.316 15.539L16.14 4.04102Z" />
20
</svg>
21
);
22
23
const SolanaIcon = () => (
24
<svg viewBox="0 0 32 32" className="w-8 h-8 text-[#14F195]" fill="currentColor">
25
<path fill="#9945FF" d="M16 32C24.8366 32 32 24.8366 32 16C32 7.16344 24.8366 0 16 0C7.16344 0 0 7.16344 0 16C0 24.8366 7.16344 32 16 32Z" />
26
<path fill="white" d="M22.569 13.911C22.251 13.526 21.776 13.313 21.275 13.313H8.36199C7.80199 13.313 7.42699 13.882 7.66999 14.394L9.19199 17.518C9.51099 17.902 9.98599 18.115 10.487 18.115H23.4C23.96 18.115 24.335 17.546 24.092 17.034L22.569 13.911ZM10.487 9.87805H23.4C23.96 9.87805 24.335 9.30905 24.092 8.79705L22.57 5.67405C22.251 5.28905 21.776 5.07605 21.275 5.07605H8.36199C7.80199 5.07605 7.42699 5.64505 7.66999 6.15705L9.19199 9.28105C9.51099 9.66405 9.98599 9.87805 10.487 9.87805ZM22.569 22.148C22.251 21.763 21.776 21.55 21.275 21.55H8.36199C7.80199 21.55 7.42699 22.119 7.66999 22.631L9.19199 25.755C9.51099 26.138 9.98599 26.351 10.487 26.351H23.4C23.96 26.351 24.335 25.782 24.092 25.27L22.569 22.148Z" />
27
</svg>
28
);
29
30
const TetherIcon = () => (
31
<svg viewBox="0 0 32 32" className="w-8 h-8 text-[#26A17B]" fill="currentColor">
32
<path d="M16 32C24.8366 32 32 24.8366 32 16C32 7.16344 24.8366 0 16 0C7.16344 0 0 7.16344 0 16C0 24.8366 7.16344 32 16 32Z" />
33
<path fill="white" d="M17.822 14.512V11.23H22.955V7.52502H9.034V11.23H14.167V14.502C10.59 14.685 8.11301 15.659 8.11301 16.822C8.11301 17.962 10.489 18.913 13.978 19.112V25.352H17.822V19.123C21.411 18.948 23.887 17.989 23.887 16.822C23.887 15.674 21.492 14.717 17.822 14.512ZM16 17.653C12.723 17.653 10.05 16.942 10.05 16.064C10.05 15.187 12.723 14.476 16 14.476C19.277 14.476 21.95 15.187 21.95 16.064C21.95 16.942 19.277 17.653 16 17.653Z" />
34
</svg>
35
);
36
37
const CRYPTO_OPTIONS = [
38
{
39
id: "bitcoin",
40
label: "Bitcoin (BTC)",
41
value: "bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
42
glowColor: "rgba(247, 147, 26, 0.4)", // orange
43
icon: <BitcoinIcon />
44
},
45
{
46
id: "ethereum",
47
label: "Ethereum (ETH)",
48
value: "ethereum:0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae",
49
glowColor: "rgba(98, 126, 234, 0.4)", // blue
50
icon: <EthereumIcon />
51
},
52
{
53
id: "solana",
54
label: "Solana (SOL)",
55
value: "solana:HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH",
56
glowColor: "rgba(153, 69, 255, 0.4)", // purple
57
icon: <SolanaIcon />
58
},
59
{
60
id: "tether",
61
label: "Tether (USDT)",
62
value: "ethereum:0xdac17f958d2ee523a2206206994597c13d831ec7",
63
glowColor: "rgba(38, 161, 123, 0.4)", // green
64
icon: <TetherIcon />
65
},
66
];
67
68
export function QRCodeDemo() {
69
const [selectedId, setSelectedId] = useState(CRYPTO_OPTIONS[0].id);
70
71
const selectedOption = CRYPTO_OPTIONS.find(opt => opt.id === selectedId) || CRYPTO_OPTIONS[0];
72
73
return (
74
<div className="w-full h-full min-h-[500px] flex flex-col items-center justify-center p-8 bg-transparent overflow-visible relative">
75
76
{/* Animated Glowing Background with soft natural falloff */}
77
<AnimatePresence mode="wait">
78
<motion.div
79
key={selectedOption.id}
80
initial={{ opacity: 0, scale: 0.8 }}
81
animate={{ opacity: 0.7, scale: 1 }}
82
exit={{ opacity: 0, scale: 1.15 }}
83
transition={{ duration: 0.8, ease: "easeInOut" }}
84
className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[420px] h-[420px] rounded-full blur-[100px] pointer-events-none"
85
style={{
86
background: "radial-gradient(circle closest-side, " + selectedOption.glowColor + " 0%, rgba(0,0,0,0) 80%)",
87
}}
88
/>
89
</AnimatePresence>
90
91
{/* Dropdown */}
92
<div className="relative z-10 mb-12">
93
<select
94
value={selectedId}
95
onChange={(e) => setSelectedId(e.target.value)}
96
className="bg-white/80 dark:bg-black/80 backdrop-blur-md border border-black/10 dark:border-white/10 rounded-full px-6 py-2.5 text-sm font-medium outline-none appearance-none pr-12 cursor-pointer hover:bg-white dark:hover:bg-zinc-900 transition-colors shadow-sm"
97
>
98
{CRYPTO_OPTIONS.map((opt) => (
99
<option key={opt.id} value={opt.id}>{opt.label}</option>
100
))}
101
</select>
102
<ChevronDown className="w-4 h-4 absolute right-4 top-1/2 -translate-y-1/2 pointer-events-none text-zinc-500" />
103
</div>
104
105
{/* QR Code */}
106
<div className="relative z-10 p-6 bg-white dark:bg-zinc-950/80 backdrop-blur-3xl rounded-3xl shadow-xl border border-black/5 dark:border-white/10">
107
<QRCodeDisplay
108
value={selectedOption.value}
109
size={240}
110
logo={selectedOption.icon}
111
logoSize={48}
112
/>
113
</div>
114
115
</div>
116
);
117
}
118