feat(sidebar): add wallet top up card
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import { Coins } from "lucide-react";
|
||||
|
||||
import styles from "./sidebar-wallet-card.module.css";
|
||||
|
||||
export interface SidebarWalletCardProps {
|
||||
creditBalance: number;
|
||||
onTopUp: () => void;
|
||||
}
|
||||
|
||||
const formatCoins = (value: number): string =>
|
||||
new Intl.NumberFormat("en-US").format(Math.max(0, Math.trunc(value)));
|
||||
|
||||
export function SidebarWalletCard({
|
||||
creditBalance,
|
||||
onTopUp,
|
||||
}: SidebarWalletCardProps) {
|
||||
return (
|
||||
<section className={styles.card} aria-label="My wallet">
|
||||
<div className={styles.leftColumn}>
|
||||
<div className={styles.titleRow}>
|
||||
<span className={styles.iconWrap} aria-hidden="true">
|
||||
<Coins size={18} strokeWidth={2.4} />
|
||||
</span>
|
||||
<h2 className={styles.title}>My Wallet</h2>
|
||||
</div>
|
||||
|
||||
<p className={styles.balance}>
|
||||
<span className={styles.balanceValue}>{formatCoins(creditBalance)}</span>
|
||||
<span className={styles.balanceUnit}> coins</span>
|
||||
</p>
|
||||
|
||||
<button type="button" className={styles.rulesButton}>
|
||||
Coins 消耗规则
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button type="button" className={styles.topUpButton} onClick={onTopUp}>
|
||||
Top Up
|
||||
</button>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user