Spaces:
Running
Running
Download components/AssetSelector.js from powerllm/anycoder-cf48624d: direct link, hf CLI and curl.
- Browser
- Download file 2.58 kB
-
https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/AssetSelector.js
- Command line
-
hf download hf://spaces/powerllm/anycoder-cf48624d/components/AssetSelector.js
-
curl -L -o AssetSelector.js https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/AssetSelector.js
2.58 kB
| import { ChevronDown } from 'lucide-react' | |
| import { useState } from 'react' | |
| const ASSETS = [ | |
| { id: 'bitcoin', symbol: 'BTC', name: 'Bitcoin' }, | |
| { id: 'ethereum', symbol: 'ETH', name: 'Ethereum' }, | |
| { id: 'solana', symbol: 'SOL', name: 'Solana' }, | |
| ] | |
| export default function AssetSelector({ selected, onChange }) { | |
| const [isOpen, setIsOpen] = useState(false) | |
| const currentAsset = ASSETS.find(a => a.id === selected) || ASSETS[0] | |
| return ( | |
| <div className="relative"> | |
| <button | |
| onClick={() => setIsOpen(!isOpen)} | |
| className="flex items-center space-x-2 bg-dark-800 hover:bg-dark-700 border border-white/10 px-4 py-2.5 rounded-xl transition-all group shadow-lg shadow-black/20" | |
| > | |
| <div className="w-6 h-6 rounded-full bg-dark-900 flex items-center justify-center text-[10px] font-bold text-white border border-white/10"> | |
| {currentAsset.symbol[0]} | |
| </div> | |
| <span className="font-bold text-white">{currentAsset.symbol}</span> | |
| <span className="text-dark-400 text-sm hidden sm:inline">{currentAsset.name}</span> | |
| <ChevronDown className={`w-4 h-4 text-dark-400 transition-transform ${isOpen ? 'rotate-180' : ''}`} /> | |
| </button> | |
| {isOpen && ( | |
| <> | |
| <div className="fixed inset-0 z-10" onClick={() => setIsOpen(false)} /> | |
| <div className="absolute right-0 mt-2 w-48 bg-dark-800 border border-white/10 rounded-xl shadow-2xl z-20 overflow-hidden backdrop-blur-xl"> | |
| {ASSETS.map((asset) => ( | |
| <button | |
| key={asset.id} | |
| onClick={() => { | |
| onChange(asset.id) | |
| setIsOpen(false) | |
| className="w-full text-left px-4 py-3 hover:bg-white/5 flex items-center justify-between group transition-colors" | |
| > | |
| <div className="flex items-center space-x-3"> | |
| <div className="w-5 h-5 rounded-full bg-dark-900 flex items-center justify-center text-[8px] font-bold text-white border border-white/10"> | |
| {asset.symbol[0]} | |
| </div> | |
| <div> | |
| <div className="font-medium text-white text-sm">{asset.symbol}</div> | |
| <div className="text-[10px] text-dark-400">{asset.name}</div> | |
| </div> | |
| </div> | |
| {asset.id === selected && ( | |
| <div className="w-1.5 h-1.5 rounded-full bg-primary-500" /> | |
| )} | |
| </button> | |
| ))} | |
| </div> | |
| </> | |
| )} | |
| </div> | |
| ) | |
| } |