refactor: 提取 Button 组件,统一按钮变体、尺寸和加载状态

新增 Button.tsx 支持 5 种变体(primary/secondary/danger/ghost/purple)、
3 种尺寸(sm/md/lg)、pill/rounded 形状及内置 loading 状态,
替换 8 个文件中 16 处重复的按钮样板代码。
This commit is contained in:
2026-02-26 18:39:14 +08:00
parent 19edcaeeb5
commit 455b9e04d8
9 changed files with 178 additions and 115 deletions
+10 -18
View File
@@ -9,11 +9,11 @@ import {
Heart,
Sparkles,
ChevronRight,
Loader2,
Coffee,
} from "lucide-react";
import { getUserId } from "@/lib/userId";
import { Skeleton, SkeletonCircle } from "@/components/Skeleton";
import Button from "@/components/Button";
import { getSceneConfig } from "@/lib/sceneConfig";
import type { SceneType } from "@/types";
@@ -93,12 +93,9 @@ export default function InvitePage() {
<p className="text-center text-sm text-muted">
</p>
<button
onClick={() => router.push("/")}
className="mt-2 rounded-xl bg-accent px-6 py-2.5 text-sm font-bold text-white shadow-lg shadow-accent/20 transition-colors hover:bg-accent-hover"
>
<Button onClick={() => router.push("/")} className="mt-2">
</button>
</Button>
</div>
);
}
@@ -194,20 +191,15 @@ export default function InvitePage() {
animate={{ y: 0, opacity: 1 }}
transition={{ duration: 0.5, delay: 0.3 }}
>
<button
<Button
onClick={handleJoin}
disabled={joining}
className="flex h-12 w-full items-center justify-center gap-2 rounded-xl bg-accent text-sm font-bold text-white shadow-lg shadow-accent/20 transition-colors hover:bg-accent-hover disabled:opacity-50"
size="lg"
fullWidth
loading={joining}
loadingText="加入中..."
>
{joining ? (
<>
<Loader2 size={18} className="animate-spin" />
...
</>
) : (
"加入房间"
)}
</button>
</Button>
</motion.div>
</div>
);