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";
|
"use client";
|
||||||
|
|
||||||
|
import { DownloadIcon } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { cancelJob, startDownload } from "@/components/job-actions";
|
import { cancelJob, startDownload } from "@/components/job-actions";
|
||||||
@@ -37,7 +38,10 @@ export function DownloadCard({ modelId, status }: { modelId: string; status: Mod
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<div className="flex items-center justify-between gap-2">
|
<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} />}
|
{latest && <JobStateBadge job={latest} />}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-muted-foreground">{hint}</p>
|
<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 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 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 (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col gap-4">
|
||||||
{/* Header, styled after the Hugging Face model page */}
|
{/* Header card, styled after the Hugging Face model page */}
|
||||||
{/* Full-bleed background behind the header (the page itself is width-limited). */}
|
<Panel className="flex flex-col gap-4 p-5">
|
||||||
<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-wrap items-center gap-x-2 gap-y-2">
|
<div className="flex flex-wrap items-center gap-x-2 gap-y-2">
|
||||||
<Avatar url={model.authorAvatarUrl} name={author} />
|
<Avatar url={model.authorAvatarUrl} name={author} />
|
||||||
<Link href={`/?author=${encodeURIComponent(author)}`} className="text-muted-foreground hover:text-foreground hover:underline">
|
<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>
|
||||||
|
|
||||||
<div className="mt-3 flex flex-wrap items-center gap-1.5">
|
<div className="flex flex-wrap items-center gap-1.5">
|
||||||
{model.pipelineTag && (
|
{model.pipelineTag && (
|
||||||
<Pill icon={MessagesSquareIcon} accent>
|
<Pill icon={MessagesSquareIcon} accent>
|
||||||
{titleCase(model.pipelineTag)}
|
{titleCase(model.pipelineTag)}
|
||||||
@@ -147,12 +148,12 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
|||||||
))}
|
))}
|
||||||
</div>
|
</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>
|
<span className="text-xs text-muted-foreground">Your tags</span>
|
||||||
<TagEditor modelId={model.id} tags={tags} />
|
<TagEditor modelId={model.id} tags={tags} />
|
||||||
</div>
|
</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}>🤗 Hugging Face</ExternalButton>
|
||||||
<ExternalButton href={`${hub}/tree/${model.pinnedSha}`}>Files @ {shortSha(model.pinnedSha)}</ExternalButton>
|
<ExternalButton href={`${hub}/tree/${model.pinnedSha}`}>Files @ {shortSha(model.pinnedSha)}</ExternalButton>
|
||||||
<ExternalButton href={`${hub}/commits/${encodeURIComponent(model.trackedRevision)}`}>Commits</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>
|
<ExternalButton href={`https://huggingface.co/${baseModels[0]}`}>Base: {baseModels[0]}</ExternalButton>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</Panel>
|
||||||
|
|
||||||
<nav className="mt-4 -mb-px flex gap-1">
|
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
|
||||||
{TABS.map((t) => (
|
{/* Content card with the tabs as a segmented control in its header */}
|
||||||
<Link
|
<Panel className="min-w-0 overflow-hidden">
|
||||||
key={t.id}
|
<div className="flex flex-wrap items-center justify-between gap-2 border-b px-4 py-3">
|
||||||
href={t.id === "card" ? `/${model.repoId}` : `/${model.repoId}?tab=${t.id}`}
|
<nav className="inline-flex rounded-lg bg-muted p-1">
|
||||||
scroll={false}
|
{TABS.map((t) => (
|
||||||
className={cn(
|
<Link
|
||||||
"flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors",
|
key={t.id}
|
||||||
tab === t.id
|
href={tabHref(t.id)}
|
||||||
? "border-foreground font-medium text-foreground"
|
scroll={false}
|
||||||
: "border-transparent text-muted-foreground hover:text-foreground",
|
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>
|
||||||
)}
|
)}
|
||||||
>
|
</div>
|
||||||
<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>
|
|
||||||
))}
|
|
||||||
{tab === "files" && <FilesTab repoId={model.repoId} sha={model.pinnedSha} selected={selected} others={others} />}
|
{tab === "files" && <FilesTab repoId={model.repoId} sha={model.pinnedSha} selected={selected} others={others} />}
|
||||||
{tab === "jobs" && <JobsTab modelId={model.id} />}
|
{tab === "jobs" && (
|
||||||
</section>
|
<div className="px-2 pb-2">
|
||||||
|
<JobsTab modelId={model.id} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Panel>
|
||||||
|
|
||||||
<aside className="flex flex-col gap-4">
|
<aside className="flex flex-col gap-4">
|
||||||
<SideCard>
|
<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({
|
function SideCard({
|
||||||
title,
|
title,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
@@ -330,7 +357,7 @@ function SideCard({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl border bg-card p-4">
|
<Panel className="p-4">
|
||||||
{title && (
|
{title && (
|
||||||
<h3 className="mb-3 flex items-center gap-1.5 text-sm font-semibold">
|
<h3 className="mb-3 flex items-center gap-1.5 text-sm font-semibold">
|
||||||
{Icon && <Icon className="size-4 text-muted-foreground" />}
|
{Icon && <Icon className="size-4 text-muted-foreground" />}
|
||||||
@@ -338,7 +365,7 @@ function SideCard({
|
|||||||
</h3>
|
</h3>
|
||||||
)}
|
)}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</Panel>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,14 +414,14 @@ function FilesTab({
|
|||||||
}) {
|
}) {
|
||||||
const blob = (path: string) => `https://huggingface.co/${repoId}/blob/${sha}/${path}`;
|
const blob = (path: string) => `https://huggingface.co/${repoId}/blob/${sha}/${path}`;
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4">
|
<div>
|
||||||
<div className="overflow-hidden rounded-xl border">
|
<div className="flex flex-wrap items-baseline gap-x-2 px-5 pt-4 pb-2 text-sm">
|
||||||
<div className="border-b bg-muted/40 px-3 py-2 text-sm">
|
<span className="font-medium">Selected files</span>
|
||||||
<span className="font-medium">Selected files</span>{" "}
|
<span className="text-muted-foreground">
|
||||||
<span className="text-muted-foreground">
|
{selected.length} · {formatBytes(selected.reduce((s, f) => s + f.size, 0))} · at {shortSha(sha)}
|
||||||
· {selected.length} · {formatBytes(selected.reduce((s, f) => s + f.size, 0))} · at {shortSha(sha)}
|
</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
<div className="px-2">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -421,27 +448,31 @@ function FilesTab({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{others.length > 0 && (
|
{others.length > 0 && (
|
||||||
<details className="overflow-hidden rounded-xl border">
|
<details className="group mt-2 border-t">
|
||||||
<summary className="cursor-pointer bg-muted/40 px-3 py-2 text-sm">
|
<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="font-medium">Other files in the repo</span>
|
||||||
<span className="text-muted-foreground">
|
<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>
|
||||||
|
<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>
|
</summary>
|
||||||
<Table>
|
<div className="px-2 pb-2">
|
||||||
<TableBody>
|
<Table>
|
||||||
{others.map((f) => (
|
<TableBody>
|
||||||
<TableRow key={f.id}>
|
{others.map((f) => (
|
||||||
<TableCell className="font-mono text-xs break-all whitespace-normal text-muted-foreground">
|
<TableRow key={f.id}>
|
||||||
<a href={blob(f.path)} target="_blank" rel="noreferrer" className="hover:underline">
|
<TableCell className="font-mono text-xs break-all whitespace-normal text-muted-foreground">
|
||||||
{f.path}
|
<a href={blob(f.path)} target="_blank" rel="noreferrer" className="hover:underline">
|
||||||
</a>
|
{f.path}
|
||||||
</TableCell>
|
</a>
|
||||||
<TableCell className="w-28 text-right text-muted-foreground tabular-nums">{formatBytes(f.size)}</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
<TableCell className="w-28 text-right text-muted-foreground tabular-nums">{formatBytes(f.size)}</TableCell>
|
||||||
))}
|
</TableRow>
|
||||||
</TableBody>
|
))}
|
||||||
</Table>
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
</details>
|
</details>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user