- 材质统一边光:slab / float / pill / pill-selected / seg-thumb / chrome-side 改为左上亮右下暗的 1px 边光 + 外侧暗线;新增 lens / field / chip 参数与 pg-float-modal - 主按钮:转动光谱环改为静态左上光谱高光,悬停沿边扫过一小段;次按钮同为 lens 玻璃 - Input / Textarea / SelectTrigger 挂 .field-glass,原生下拉与实体选择器同步;对话框按钮行 gap-3 - 提示条改 pg-float(状态色只在图标、展开不叠放);新增 GlassTooltip 接管 title 提示 - 触屏判断 input-modality.ts、touch / hover 自定义变体;animate-pg-pop 改 backwards;scroll-fade-end - 控制台外壳:侧栏无硬分隔线、折叠开关进标志行;顶栏去磨砂,右侧控件收进玻璃胶囊 - 登录页居中单卡 auth-card;详情头图「订阅」改回普通主按钮,删除 pill-solid;发现页海报角标改 glass-chip-media - 引入 simple-liquid-glass(liquid-surface.tsx);更新 docs/design 三份规范与 CHANGELOG Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
124 lines
4.5 KiB
TypeScript
124 lines
4.5 KiB
TypeScript
import { type DiscoverItem, tmdbImageUrl } from "@umt/contracts";
|
|
import { CalendarPlus, LoaderCircle, PackageSearch, Star } from "lucide-react";
|
|
import { useState } from "react";
|
|
import { StatusBadge } from "~/components/console/status-badge.tsx";
|
|
import { Button } from "~/components/ui/button.tsx";
|
|
import { cn } from "~/lib/utils.ts";
|
|
import { itemMeta, localBadges } from "./discover-state.ts";
|
|
|
|
// 发现卡片:海报(懒加载)、评分、本地状态、标题、年份 · 类型 · 风格;点海报 / 标题进作品,下面两个动作。
|
|
|
|
export type CardAction = "open" | "subscribe" | "search";
|
|
|
|
export function coverUrl(it: Pick<DiscoverItem, "cover" | "posterPath">): string | null {
|
|
return it.posterPath ? tmdbImageUrl(it.posterPath, "w342") : it.cover;
|
|
}
|
|
|
|
export function DiscoverCard({
|
|
item,
|
|
busy,
|
|
onAction,
|
|
className,
|
|
}: {
|
|
item: DiscoverItem;
|
|
/** 正在为这张卡匹配 TMDB */
|
|
busy: CardAction | null;
|
|
onAction: (a: CardAction) => void;
|
|
className?: string;
|
|
}) {
|
|
const [failed, setFailed] = useState(false);
|
|
const src = failed ? null : coverUrl(item);
|
|
const badges = localBadges(item);
|
|
const meta = itemMeta(item);
|
|
return (
|
|
<article className={cn("group flex min-w-0 flex-col", className)} aria-label={item.title}>
|
|
<button
|
|
type="button"
|
|
onClick={() => onAction("open")}
|
|
disabled={!!busy}
|
|
className="relative block aspect-[2/3] w-full cursor-pointer overflow-hidden rounded-xl border border-border/70 bg-foreground/[0.05] text-left transition-colors duration-base hover:border-foreground/40 disabled:cursor-wait"
|
|
>
|
|
{src ? (
|
|
<img
|
|
src={src}
|
|
alt=""
|
|
loading="lazy"
|
|
decoding="async"
|
|
referrerPolicy="no-referrer"
|
|
onError={() => setFailed(true)}
|
|
className="h-full w-full object-cover transition-transform duration-slow group-hover:scale-[1.03]"
|
|
/>
|
|
) : (
|
|
<span className="grid h-full w-full place-items-center px-2 text-center text-title font-semibold text-foreground/30">
|
|
{item.title.charAt(0)}
|
|
</span>
|
|
)}
|
|
{item.rating ? (
|
|
<span className="glass-chip-media absolute top-1.5 left-1.5 inline-flex items-center gap-0.5 px-1.5 py-0.5 text-micro font-medium">
|
|
<Star className="h-3 w-3" aria-hidden />
|
|
{item.rating.toFixed(1)}
|
|
</span>
|
|
) : null}
|
|
{badges.length ? (
|
|
<span className="absolute inset-x-1.5 bottom-1.5 flex flex-wrap gap-1">
|
|
{badges.map((b) => (
|
|
<StatusBadge key={b.label} tone={b.tone} onMedia>
|
|
{b.label}
|
|
</StatusBadge>
|
|
))}
|
|
</span>
|
|
) : null}
|
|
{busy ? (
|
|
<span className="absolute inset-0 grid place-items-center bg-background/60">
|
|
<LoaderCircle className="h-5 w-5 animate-spin" aria-label="匹配中" />
|
|
</span>
|
|
) : null}
|
|
</button>
|
|
<div className="min-w-0 pt-1.5">
|
|
<button
|
|
type="button"
|
|
onClick={() => onAction("open")}
|
|
disabled={!!busy}
|
|
className="block w-full cursor-pointer truncate text-left text-caption font-medium text-foreground hover:underline"
|
|
title={item.title}
|
|
>
|
|
{item.title}
|
|
</button>
|
|
<p className="truncate text-meta text-muted-foreground">{meta || "—"}</p>
|
|
<div className="mt-1 flex flex-wrap gap-1">
|
|
<Button
|
|
variant="ghost"
|
|
size="xs"
|
|
onClick={() => onAction("subscribe")}
|
|
disabled={!!busy}
|
|
aria-label={`订阅「${item.title}」`}
|
|
>
|
|
<CalendarPlus />
|
|
订阅
|
|
</Button>
|
|
<Button
|
|
variant="ghost"
|
|
size="xs"
|
|
onClick={() => onAction("search")}
|
|
disabled={!!busy}
|
|
aria-label={`搜索「${item.title}」的资源`}
|
|
>
|
|
<PackageSearch />
|
|
搜索资源
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
);
|
|
}
|
|
|
|
export function DiscoverCardSkeleton({ className }: { className?: string }) {
|
|
return (
|
|
<div className={cn("flex min-w-0 flex-col", className)} aria-hidden>
|
|
<div className="aspect-[2/3] w-full animate-pulse rounded-xl bg-foreground/[0.07]" />
|
|
<div className="mt-2 h-3.5 w-4/5 animate-pulse rounded-tight bg-foreground/[0.07]" />
|
|
<div className="mt-1.5 h-3 w-1/2 animate-pulse rounded-tight bg-foreground/[0.05]" />
|
|
</div>
|
|
);
|
|
}
|