ui: 房间页布局优化 — TopNav 重排、进度贴近卡片、按钮间距收紧
- TopNav: 退出按钮移到最左侧,房间号合并到邀请按钮,移除右侧内容避免与全局徽章重叠 - SwipeDeck: 移除绿色进度条,UserProgressBar 始终显示并贴在卡片正上方 - ActionButtons: 缩小与卡片的垂直间距
This commit is contained in:
@@ -14,7 +14,7 @@ export default function ActionButtons({
|
|||||||
disabled,
|
disabled,
|
||||||
}: ActionButtonsProps) {
|
}: ActionButtonsProps) {
|
||||||
return (
|
return (
|
||||||
<div className="relative z-10 flex items-center justify-center gap-6 pb-5 pt-3">
|
<div className="relative z-10 -mt-2 flex items-center justify-center gap-4 pb-5">
|
||||||
<motion.button
|
<motion.button
|
||||||
className="flex h-13 w-13 items-center justify-center rounded-full bg-surface shadow-lg shadow-rose-500/10 ring-1 ring-rose-500/20 disabled:opacity-40"
|
className="flex h-13 w-13 items-center justify-center rounded-full bg-surface shadow-lg shadow-rose-500/10 ring-1 ring-rose-500/20 disabled:opacity-40"
|
||||||
whileTap={{ scale: 0.85 }}
|
whileTap={{ scale: 0.85 }}
|
||||||
|
|||||||
@@ -16,22 +16,24 @@ function UserProgressBar({
|
|||||||
localIndex,
|
localIndex,
|
||||||
total,
|
total,
|
||||||
userProfiles,
|
userProfiles,
|
||||||
|
onUndo,
|
||||||
}: {
|
}: {
|
||||||
userId: string;
|
userId: string;
|
||||||
swipeCounts: Record<string, number>;
|
swipeCounts: Record<string, number>;
|
||||||
localIndex: number;
|
localIndex: number;
|
||||||
total: number;
|
total: number;
|
||||||
userProfiles: Record<string, UserProfile>;
|
userProfiles: Record<string, UserProfile>;
|
||||||
|
onUndo: () => void;
|
||||||
}) {
|
}) {
|
||||||
const others = Object.entries(swipeCounts).filter(([id]) => id !== userId);
|
const others = Object.entries(swipeCounts).filter(([id]) => id !== userId);
|
||||||
if (others.length === 0) return null;
|
|
||||||
|
|
||||||
const myProfile = userProfiles[userId];
|
const myProfile = userProfiles[userId];
|
||||||
const myAvatar = myProfile?.avatar ?? getAvatar(userId).emoji;
|
const myAvatar = myProfile?.avatar ?? getAvatar(userId).emoji;
|
||||||
const myAvatarBg = myProfile ? getAvatarBg(myProfile.avatar) : "bg-emerald-500/20";
|
const myAvatarBg = myProfile ? getAvatarBg(myProfile.avatar) : "bg-emerald-500/20";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1">
|
<div className="flex items-center gap-x-3">
|
||||||
|
<div className="flex flex-1 flex-wrap items-center gap-x-3 gap-y-1">
|
||||||
<span className="flex items-center gap-1 text-[11px] tabular-nums text-accent">
|
<span className="flex items-center gap-1 text-[11px] tabular-nums text-accent">
|
||||||
<span className={`inline-flex h-4 w-4 items-center justify-center rounded-full ${myAvatarBg} text-[10px] leading-none`}>
|
<span className={`inline-flex h-4 w-4 items-center justify-center rounded-full ${myAvatarBg} text-[10px] leading-none`}>
|
||||||
{myAvatar}
|
{myAvatar}
|
||||||
@@ -59,6 +61,15 @@ function UserProgressBar({
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={onUndo}
|
||||||
|
disabled={localIndex === 0}
|
||||||
|
className="flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[11px] font-medium text-amber-400 transition-colors active:bg-amber-500/15 disabled:opacity-0"
|
||||||
|
>
|
||||||
|
<Undo2 size={12} />
|
||||||
|
撤回
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,43 +334,20 @@ export default function SwipeDeck({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div className="relative flex flex-1 items-center justify-center px-4">
|
||||||
|
<div className="relative h-[60vh] w-full max-w-sm">
|
||||||
{!allSwiped && !resolvedMatchId && (
|
{!allSwiped && !resolvedMatchId && (
|
||||||
<div className="mx-auto w-full max-w-sm px-4 pb-1">
|
<div className="absolute inset-x-0 bottom-full mb-2">
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<div className="h-1 flex-1 overflow-hidden rounded-full bg-elevated">
|
|
||||||
<motion.div
|
|
||||||
className="h-full rounded-full bg-emerald-400"
|
|
||||||
initial={{ width: 0 }}
|
|
||||||
animate={{
|
|
||||||
width: `${((currentIndex) / restaurants.length) * 100}%`,
|
|
||||||
}}
|
|
||||||
transition={{ type: "spring", stiffness: 300, damping: 30 }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<span className="shrink-0 text-[11px] tabular-nums text-muted">
|
|
||||||
{currentIndex}/{restaurants.length}
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
onClick={handleUndo}
|
|
||||||
disabled={currentIndex === 0}
|
|
||||||
className="flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[11px] font-medium text-amber-400 transition-colors active:bg-amber-500/15 disabled:opacity-0"
|
|
||||||
>
|
|
||||||
<Undo2 size={12} />
|
|
||||||
撤回
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<UserProgressBar
|
<UserProgressBar
|
||||||
userId={userId}
|
userId={userId}
|
||||||
swipeCounts={swipeCounts}
|
swipeCounts={swipeCounts}
|
||||||
localIndex={currentIndex}
|
localIndex={currentIndex}
|
||||||
total={restaurants.length}
|
total={restaurants.length}
|
||||||
userProfiles={userProfiles}
|
userProfiles={userProfiles}
|
||||||
|
onUndo={handleUndo}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="relative flex flex-1 items-center justify-center px-4">
|
|
||||||
<div className="relative h-[60vh] w-full max-w-sm">
|
|
||||||
{currentIndex === 0 && !resolvedMatchId && guideVisible && (
|
{currentIndex === 0 && !resolvedMatchId && guideVisible && (
|
||||||
<SwipeGuide onDismiss={() => setGuideVisible(false)} />
|
<SwipeGuide onDismiss={() => setGuideVisible(false)} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
+13
-25
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useCallback } from "react";
|
import { useState, useCallback } from "react";
|
||||||
import { Users, QrCode, LogOut, Crown, Lock } from "lucide-react";
|
import { QrCode, LogOut, Crown, Lock } from "lucide-react";
|
||||||
import { motion, AnimatePresence } from "framer-motion";
|
import { motion, AnimatePresence } from "framer-motion";
|
||||||
import QrInviteModal from "./QrInviteModal";
|
import QrInviteModal from "./QrInviteModal";
|
||||||
import RoomManageModal from "./RoomManageModal";
|
import RoomManageModal from "./RoomManageModal";
|
||||||
@@ -10,7 +10,7 @@ import { getSceneConfig } from "@/lib/sceneConfig";
|
|||||||
|
|
||||||
interface TopNavProps {
|
interface TopNavProps {
|
||||||
roomId: string;
|
roomId: string;
|
||||||
userCount: number;
|
userCount?: number;
|
||||||
onExit?: () => void;
|
onExit?: () => void;
|
||||||
isCreator?: boolean;
|
isCreator?: boolean;
|
||||||
userId?: string;
|
userId?: string;
|
||||||
@@ -47,14 +47,21 @@ export default function TopNav({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<nav className="relative z-10 flex h-14 items-center justify-between pl-4 pr-24">
|
<nav className="relative z-10 flex h-14 items-center px-4">
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
|
<button
|
||||||
|
onClick={onExit}
|
||||||
|
className="flex items-center justify-center rounded-full p-1.5 text-muted transition-colors active:bg-elevated active:text-secondary"
|
||||||
|
aria-label="退出房间"
|
||||||
|
>
|
||||||
|
<LogOut size={15} />
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowQr(true)}
|
onClick={() => setShowQr(true)}
|
||||||
className="flex items-center gap-1 rounded-full bg-accent/15 px-2.5 py-1 text-xs font-semibold text-accent transition-colors active:bg-accent/25"
|
className="flex items-center gap-1 rounded-full bg-accent/15 px-2.5 py-1 text-xs font-semibold text-accent transition-colors active:bg-accent/25"
|
||||||
>
|
>
|
||||||
<QrCode size={13} />
|
<QrCode size={13} />
|
||||||
邀请
|
邀请({roomId})
|
||||||
</button>
|
</button>
|
||||||
{isCreator && (
|
{isCreator && (
|
||||||
<button
|
<button
|
||||||
@@ -63,36 +70,17 @@ export default function TopNav({
|
|||||||
>
|
>
|
||||||
<Crown size={13} />
|
<Crown size={13} />
|
||||||
管理
|
管理
|
||||||
|
{locked && <Lock size={11} />}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1 className="text-center text-base font-bold tracking-tight text-heading">
|
<h1 className="pointer-events-none absolute inset-x-0 text-center text-base font-bold tracking-tight text-heading">
|
||||||
<span className="block leading-tight">NoWhatever</span>
|
<span className="block leading-tight">NoWhatever</span>
|
||||||
<span className="block text-[10px] font-medium tracking-widest text-muted">
|
<span className="block text-[10px] font-medium tracking-widest text-muted">
|
||||||
别说随便
|
别说随便
|
||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div className="flex items-center justify-end gap-1.5 text-xs text-muted">
|
|
||||||
{locked && (
|
|
||||||
<Lock size={12} className="text-amber-500" />
|
|
||||||
)}
|
|
||||||
<span className="rounded-full bg-surface px-2 py-0.5 font-medium text-tertiary">
|
|
||||||
{roomId}
|
|
||||||
</span>
|
|
||||||
<div className="flex items-center gap-0.5">
|
|
||||||
<Users size={13} />
|
|
||||||
<span className="font-semibold text-accent">{userCount}</span>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
onClick={onExit}
|
|
||||||
className="ml-1 flex items-center justify-center rounded-full p-1 text-muted transition-colors active:bg-elevated active:text-secondary"
|
|
||||||
aria-label="退出房间"
|
|
||||||
>
|
|
||||||
<LogOut size={15} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
|
|||||||
Reference in New Issue
Block a user