feat(sidebar): add wallet top up card
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
export * from "./back-bar";
|
||||
export * from "./sidebar-wallet-card";
|
||||
export * from "./user-header";
|
||||
export * from "./vip-benefits-card";
|
||||
export * from "./voice-package-card";
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
.card {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 18px;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 18px;
|
||||
border: 1px solid rgba(246, 87, 160, 0.16);
|
||||
border-radius: 24px;
|
||||
background:
|
||||
linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 239, 246, 0.94) 100%),
|
||||
#ffffff;
|
||||
box-shadow: 0 16px 38px rgba(55, 36, 44, 0.08);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.leftColumn {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 9px;
|
||||
}
|
||||
|
||||
.titleRow {
|
||||
display: inline-flex;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.iconWrap {
|
||||
display: inline-flex;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(180deg, #ffe89c 0%, #f8b83e 100%);
|
||||
color: #8f5400;
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.75),
|
||||
0 8px 18px rgba(216, 132, 22, 0.2);
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0;
|
||||
color: #191316;
|
||||
font-size: 18px;
|
||||
font-weight: 800;
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
.balance {
|
||||
margin: 0;
|
||||
color: #21191d;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.balanceValue {
|
||||
font-size: 22px;
|
||||
font-weight: 850;
|
||||
letter-spacing: -0.4px;
|
||||
}
|
||||
|
||||
.balanceUnit {
|
||||
color: #4f4449;
|
||||
font-size: 16px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.rulesButton {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 28px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: #2e6eea;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 15px;
|
||||
font-weight: 760;
|
||||
line-height: 1.2;
|
||||
text-align: left;
|
||||
transition: color 0.16s ease, transform 0.16s ease;
|
||||
}
|
||||
|
||||
.rulesButton:hover {
|
||||
color: #174fbd;
|
||||
}
|
||||
|
||||
.rulesButton:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.topUpButton {
|
||||
display: inline-flex;
|
||||
min-width: 92px;
|
||||
min-height: 48px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 18px;
|
||||
border: 0;
|
||||
border-radius: 18px;
|
||||
background:
|
||||
linear-gradient(135deg, #f657a0 0%, #ff7ac3 100%),
|
||||
#f657a0;
|
||||
color: #ffffff;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 16px;
|
||||
font-weight: 850;
|
||||
letter-spacing: 0.1px;
|
||||
box-shadow: 0 12px 26px rgba(246, 87, 160, 0.28);
|
||||
transition: box-shadow 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
|
||||
}
|
||||
|
||||
.topUpButton:hover {
|
||||
box-shadow: 0 16px 30px rgba(246, 87, 160, 0.34);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.topUpButton:active {
|
||||
opacity: 0.92;
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.rulesButton:focus-visible,
|
||||
.topUpButton:focus-visible {
|
||||
outline: 2px solid #f657a0;
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
@media (max-width: 360px) {
|
||||
.card {
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.topUpButton {
|
||||
min-width: 78px;
|
||||
min-height: 44px;
|
||||
padding: 0 14px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.balanceValue {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.balanceUnit,
|
||||
.rulesButton {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -10,9 +10,9 @@ import { useUserDispatch, useUserState } from "@/stores/user/user-context";
|
||||
|
||||
import {
|
||||
BackBar,
|
||||
SidebarWalletCard,
|
||||
UserHeader,
|
||||
type SidebarUserState,
|
||||
VipBenefitsCard,
|
||||
} from "./components";
|
||||
|
||||
import styles from "./components/sidebar-screen.module.css";
|
||||
@@ -74,9 +74,9 @@ export function SidebarScreen() {
|
||||
</section>
|
||||
|
||||
<section className={styles.cardSlot}>
|
||||
<VipBenefitsCard
|
||||
state={sidebarState}
|
||||
onActivate={() => router.push(VIP_SUBSCRIPTION_URL)}
|
||||
<SidebarWalletCard
|
||||
creditBalance={user.creditBalance}
|
||||
onTopUp={() => router.push(VIP_SUBSCRIPTION_URL)}
|
||||
/>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user