SPB Git

Repository Public

WalletCard.tsx 5.5 KB 95 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : ORIX App Universe8 * File             : src/components/support/WalletCard.tsx9 * Module           : components10 * Repository       : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website  : https://www.orixlab.dev12 * Created          : 2026-11-2513 * Last Modified    : 2026-11-2514 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243"use client";44import Image from "next/image";45import { useState, type CSSProperties } from "react";4647export type WalletView = { id: string; network: string; asset: string; color: string; address: string; explorer: string; note: string };48type Labels = { copy: string; copied: string; tap: string; qr: string; explorer: string; qrAlt: string };4950/** One address: its QR code (the file published on spboucher.ai), the network logo, and the address, copied with one tap. */51export function WalletCard({ wallet, labels }: { wallet: WalletView; labels: Labels }) {52  const [copied, setCopied] = useState(false);53  const copy = async () => {54    try { await navigator.clipboard.writeText(wallet.address); setCopied(true); window.setTimeout(() => setCopied(false), 1800); }55    catch { /* no clipboard (insecure context): the address stays selectable */ }56  };57  const qr = `/support/qr-${wallet.id}.svg`;58  return (59    <article className="card tilt wallet group relative flex h-full flex-col overflow-hidden" style={{ "--accent": wallet.color, "--chain": wallet.color } as CSSProperties} data-testid="wallet-card" data-wallet={wallet.id}>60      <div aria-hidden className="wallet-wash" />61      <div aria-hidden className="h-1 w-full" style={{ background: wallet.color }} />62      <header className="relative flex items-center gap-3 px-6 pt-6">63        <span className="grid h-11 w-11 shrink-0 place-items-center rounded-[0.8rem] bg-white shadow-[0_0_0_1px_rgb(0_0_0/0.08)]"><Image src={`/support/${wallet.id}.svg`} alt="" width={28} height={28} unoptimized /></span>64        <div className="min-w-0">65          <h3 className="h3">{wallet.network}</h3>66          <p className="mono text-[0.66rem] font-medium uppercase tracking-[0.18em] text-ink3">{wallet.asset}</p>67        </div>68      </header>69      <div className="relative px-6 pt-5">70        <div className="wallet-qr mx-auto w-full max-w-[17rem] rounded-[1.15rem] bg-white p-2">71          <Image src={qr} alt={labels.qrAlt} width={272} height={272} unoptimized className="block h-auto w-full" />72        </div>73      </div>74      <div className="relative flex flex-1 flex-col gap-3 p-6">75        <p className="text-[0.92rem] leading-relaxed text-ink2">{wallet.note}</p>76        <button type="button" onClick={copy} aria-label={labels.copy} className="mt-auto flex w-full items-start gap-3 rounded-[0.8rem] border border-line2 bg-bg px-3.5 py-3 text-left transition-colors hover:border-ink3" data-testid="wallet-copy">77          <span className="mono min-w-0 flex-1 select-all break-all text-[0.74rem] leading-relaxed" data-testid="wallet-address">{wallet.address}</span>78          <span className="mt-0.5 grid h-6 w-6 shrink-0 place-items-center text-ink3" aria-hidden>79            {copied80              ? <svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="m3 8.5 3.2 3.2L13 5" stroke="var(--ok)" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" /></svg>81              : <svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="5.5" y="5.5" width="8" height="8" rx="1.6" stroke="currentColor" strokeWidth="1.4" /><path d="M10.5 3.5v-.4A1.1 1.1 0 0 0 9.4 2H3.1A1.1 1.1 0 0 0 2 3.1v6.3a1.1 1.1 0 0 0 1.1 1.1h.4" stroke="currentColor" strokeWidth="1.4" /></svg>}82          </span>83        </button>84        <div className="mono flex items-center justify-between text-[0.66rem] uppercase tracking-[0.14em] text-ink3">85          <span aria-live="polite" style={copied ? { color: "var(--ok)" } : undefined}>{copied ? labels.copied : labels.tap}</span>86          <span className="flex items-center gap-4">87            <a href={qr} download={`orix-${wallet.id}-qr.svg`} className="hover:text-ink">{labels.qr} ↓</a>88            <a href={wallet.explorer} target="_blank" rel="noopener noreferrer" className="hover:text-ink">{labels.explorer} ↗</a>89          </span>90        </div>91      </div>92    </article>93  );94}95
Files main
Menu

Theme