refactor: 提取 UserAvatar、Input、Card 三个可复用 UI 组件
- UserAvatar: 统一头像渲染(5 种尺寸),新增 resolveAvatar 工具函数,替换 SwipeDeck 和 RoomManageModal 中的重复逻辑 - Input: 统一表单输入样式(4 种尺寸 + default/purple 变体),替换 AuthModal、ProfilePage、BlindboxPage 共 12 处 - Card: 统一卡片容器样式 + 可选淡入动画和延迟,替换 ProfilePage 中 7 处重复的 motion.div
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { motion } from "framer-motion";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
interface CardProps {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
animated?: boolean;
|
||||
delay?: number;
|
||||
}
|
||||
|
||||
const fadeUp = {
|
||||
initial: { y: 10, opacity: 0 },
|
||||
animate: { y: 0, opacity: 1 },
|
||||
} as const;
|
||||
|
||||
export default function Card({
|
||||
children,
|
||||
className = "",
|
||||
animated = false,
|
||||
delay,
|
||||
}: CardProps) {
|
||||
const cls = `rounded-2xl bg-surface p-4 ring-1 ring-border ${className}`;
|
||||
|
||||
if (animated) {
|
||||
return (
|
||||
<motion.div
|
||||
className={cls}
|
||||
{...fadeUp}
|
||||
transition={delay ? { delay } : undefined}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
|
||||
return <div className={cls}>{children}</div>;
|
||||
}
|
||||
Reference in New Issue
Block a user