Model page: header, content and sidebar as consistent cards
Tabs become a segmented control in the content card header; drop the full-bleed header band and the page-wide tab line; files tab without nested boxes; download card heading matches the other sidebar cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1527fcd830
commit
5fadd64367
2 files changed
+106
-71
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { DownloadIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { cancelJob, startDownload } from "@/components/job-actions";
|
||||
@@ -37,7 +38,10 @@ export function DownloadCard({ modelId, status }: { modelId: string; status: Mod
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<h3 className="text-sm font-semibold">Download</h3>
|
||||
<h3 className="flex items-center gap-1.5 text-sm font-semibold">
|
||||
<DownloadIcon className="size-4 text-muted-foreground" />
|
||||
Download
|
||||
</h3>
|
||||
{latest && <JobStateBadge job={latest} />}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{hint}</p>
|
||||
|
||||
@@ -105,11 +105,12 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
const shown = new Set([...Object.keys(FORMATS), model.architecture, author.toLowerCase(), model.pipelineTag]);
|
||||
const extraTags = hubTags.filter((t) => !shown.has(t) && !languageName(t)).slice(0, 8);
|
||||
|
||||
const tabHref = (id: TabId) => (id === "card" ? `/${model.repoId}` : `/${model.repoId}?tab=${id}`);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
{/* Header, styled after the Hugging Face model page */}
|
||||
{/* Full-bleed background behind the header (the page itself is width-limited). */}
|
||||
<div className="relative isolate -mt-6 pt-6 before:absolute before:inset-y-0 before:left-1/2 before:-z-10 before:w-screen before:-translate-x-1/2 before:border-b before:border-border before:bg-gradient-to-b before:from-muted/70 before:to-background">
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* Header card, styled after the Hugging Face model page */}
|
||||
<Panel className="flex flex-col gap-4 p-5">
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-2">
|
||||
<Avatar url={model.authorAvatarUrl} name={author} />
|
||||
<Link href={`/?author=${encodeURIComponent(author)}`} className="text-muted-foreground hover:text-foreground hover:underline">
|
||||
@@ -126,7 +127,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-3 flex flex-wrap items-center gap-1.5">
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{model.pipelineTag && (
|
||||
<Pill icon={MessagesSquareIcon} accent>
|
||||
{titleCase(model.pipelineTag)}
|
||||
@@ -147,12 +148,12 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-3 flex flex-wrap items-center gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">Your tags</span>
|
||||
<TagEditor modelId={model.id} tags={tags} />
|
||||
</div>
|
||||
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<ExternalButton href={hub}>🤗 Hugging Face</ExternalButton>
|
||||
<ExternalButton href={`${hub}/tree/${model.pinnedSha}`}>Files @ {shortSha(model.pinnedSha)}</ExternalButton>
|
||||
<ExternalButton href={`${hub}/commits/${encodeURIComponent(model.trackedRevision)}`}>Commits</ExternalButton>
|
||||
@@ -161,44 +162,65 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
<ExternalButton href={`https://huggingface.co/${baseModels[0]}`}>Base: {baseModels[0]}</ExternalButton>
|
||||
)}
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
<nav className="mt-4 -mb-px flex gap-1">
|
||||
{TABS.map((t) => (
|
||||
<Link
|
||||
key={t.id}
|
||||
href={t.id === "card" ? `/${model.repoId}` : `/${model.repoId}?tab=${t.id}`}
|
||||
scroll={false}
|
||||
className={cn(
|
||||
"flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors",
|
||||
tab === t.id
|
||||
? "border-foreground font-medium text-foreground"
|
||||
: "border-transparent text-muted-foreground hover:text-foreground",
|
||||
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
|
||||
{/* Content card with the tabs as a segmented control in its header */}
|
||||
<Panel className="min-w-0 overflow-hidden">
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 border-b px-4 py-3">
|
||||
<nav className="inline-flex rounded-lg bg-muted p-1">
|
||||
{TABS.map((t) => (
|
||||
<Link
|
||||
key={t.id}
|
||||
href={tabHref(t.id)}
|
||||
scroll={false}
|
||||
className={cn(
|
||||
"flex items-center gap-1.5 rounded-md px-3 py-1 text-sm transition-colors",
|
||||
tab === t.id
|
||||
? "bg-background font-medium text-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
<t.icon className="size-4" />
|
||||
{t.label}
|
||||
{t.id === "files" && <span className="text-xs text-muted-foreground tabular-nums">{selected.length}</span>}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
{tab === "card" && card && (
|
||||
<a
|
||||
href={`${hub}/blob/${model.pinnedSha}/README.md`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
README.md @ {shortSha(model.pinnedSha)}
|
||||
<ExternalLinkIcon className="size-3" />
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{tab === "card" && (
|
||||
<div className="p-5 sm:p-6">
|
||||
{card ? (
|
||||
<ModelCard markdown={card} repoId={model.repoId} sha={model.pinnedSha} />
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{card === null ? "This repository has no model card." : "The model card could not be loaded."}{" "}
|
||||
<a href={hub} target="_blank" rel="noreferrer" className="underline">
|
||||
Open on Hugging Face
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
>
|
||||
<t.icon className="size-4" />
|
||||
{t.label}
|
||||
{t.id === "files" && <span className="text-xs text-muted-foreground tabular-nums">{selected.length}</span>}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-8 pt-6 lg:grid-cols-[minmax(0,1fr)_320px]">
|
||||
<section className="min-w-0">
|
||||
{tab === "card" &&
|
||||
(card ? (
|
||||
<ModelCard markdown={card} repoId={model.repoId} sha={model.pinnedSha} />
|
||||
) : (
|
||||
<p className="py-6 text-sm text-muted-foreground">
|
||||
{card === null ? "This repository has no model card." : "The model card could not be loaded."}{" "}
|
||||
<a href={hub} target="_blank" rel="noreferrer" className="underline">
|
||||
Open on Hugging Face
|
||||
</a>
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{tab === "files" && <FilesTab repoId={model.repoId} sha={model.pinnedSha} selected={selected} others={others} />}
|
||||
{tab === "jobs" && <JobsTab modelId={model.id} />}
|
||||
</section>
|
||||
{tab === "jobs" && (
|
||||
<div className="px-2 pb-2">
|
||||
<JobsTab modelId={model.id} />
|
||||
</div>
|
||||
)}
|
||||
</Panel>
|
||||
|
||||
<aside className="flex flex-col gap-4">
|
||||
<SideCard>
|
||||
@@ -320,6 +342,11 @@ function ExternalButton({ href, children }: { href: string; children: React.Reac
|
||||
);
|
||||
}
|
||||
|
||||
/** Card surface shared by header, content and sidebar. */
|
||||
function Panel({ className, children }: { className?: string; children: React.ReactNode }) {
|
||||
return <div className={cn("rounded-xl bg-card text-card-foreground ring-1 ring-foreground/10", className)}>{children}</div>;
|
||||
}
|
||||
|
||||
function SideCard({
|
||||
title,
|
||||
icon: Icon,
|
||||
@@ -330,7 +357,7 @@ function SideCard({
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="rounded-xl border bg-card p-4">
|
||||
<Panel className="p-4">
|
||||
{title && (
|
||||
<h3 className="mb-3 flex items-center gap-1.5 text-sm font-semibold">
|
||||
{Icon && <Icon className="size-4 text-muted-foreground" />}
|
||||
@@ -338,7 +365,7 @@ function SideCard({
|
||||
</h3>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -387,14 +414,14 @@ function FilesTab({
|
||||
}) {
|
||||
const blob = (path: string) => `https://huggingface.co/${repoId}/blob/${sha}/${path}`;
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="overflow-hidden rounded-xl border">
|
||||
<div className="border-b bg-muted/40 px-3 py-2 text-sm">
|
||||
<span className="font-medium">Selected files</span>{" "}
|
||||
<span className="text-muted-foreground">
|
||||
· {selected.length} · {formatBytes(selected.reduce((s, f) => s + f.size, 0))} · at {shortSha(sha)}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex flex-wrap items-baseline gap-x-2 px-5 pt-4 pb-2 text-sm">
|
||||
<span className="font-medium">Selected files</span>
|
||||
<span className="text-muted-foreground">
|
||||
{selected.length} · {formatBytes(selected.reduce((s, f) => s + f.size, 0))} · at {shortSha(sha)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="px-2">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
@@ -421,27 +448,31 @@ function FilesTab({
|
||||
</div>
|
||||
|
||||
{others.length > 0 && (
|
||||
<details className="overflow-hidden rounded-xl border">
|
||||
<summary className="cursor-pointer bg-muted/40 px-3 py-2 text-sm">
|
||||
<span className="font-medium">Other files in the repo</span>{" "}
|
||||
<details className="group mt-2 border-t">
|
||||
<summary className="flex cursor-pointer list-none flex-wrap items-baseline gap-x-2 px-5 py-3 text-sm hover:bg-muted/40">
|
||||
<span className="font-medium">Other files in the repo</span>
|
||||
<span className="text-muted-foreground">
|
||||
· {others.length} · {formatBytes(others.reduce((s, f) => s + f.size, 0))} · not downloaded
|
||||
{others.length} · {formatBytes(others.reduce((s, f) => s + f.size, 0))} · not downloaded
|
||||
</span>
|
||||
<span className="ml-auto text-xs text-muted-foreground group-open:hidden">Show</span>
|
||||
<span className="ml-auto hidden text-xs text-muted-foreground group-open:inline">Hide</span>
|
||||
</summary>
|
||||
<Table>
|
||||
<TableBody>
|
||||
{others.map((f) => (
|
||||
<TableRow key={f.id}>
|
||||
<TableCell className="font-mono text-xs break-all whitespace-normal text-muted-foreground">
|
||||
<a href={blob(f.path)} target="_blank" rel="noreferrer" className="hover:underline">
|
||||
{f.path}
|
||||
</a>
|
||||
</TableCell>
|
||||
<TableCell className="w-28 text-right text-muted-foreground tabular-nums">{formatBytes(f.size)}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div className="px-2 pb-2">
|
||||
<Table>
|
||||
<TableBody>
|
||||
{others.map((f) => (
|
||||
<TableRow key={f.id}>
|
||||
<TableCell className="font-mono text-xs break-all whitespace-normal text-muted-foreground">
|
||||
<a href={blob(f.path)} target="_blank" rel="noreferrer" className="hover:underline">
|
||||
{f.path}
|
||||
</a>
|
||||
</TableCell>
|
||||
<TableCell className="w-28 text-right text-muted-foreground tabular-nums">{formatBytes(f.size)}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user