Model page: Files tab first with a new file list, colored tags, single Hub link
- Files is the default tab: icon/size/LFS/state per file, on-disk summary, unselected files collapsed - Custom tags color-coded by name (editor, library, filter chips and menu) - Header: only the Hugging Face link (top right); README link moved to the end of the model card - App icon; proxy lets /icon.svg through Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5fadd64367
commit
6dc9527682
9 files changed
+263
-119
No files matched your search
+8
-4
@@ -8,13 +8,17 @@ step 1 (Hugging Face downloader) is released as a minor version.
|
||||
|
||||
### Added
|
||||
|
||||
- Model pages modeled on Hugging Face: org avatar, `org / name` with copy button, pills for task,
|
||||
format, architecture, language and license, your tags, buttons to the repo on Hugging Face
|
||||
(files at the pinned commit, commits, community, base model), and tabs:
|
||||
- Model pages modeled on Hugging Face, built from cards: a header with org avatar, `org / name`
|
||||
with copy button, pills for task, format, architecture, language and license, your tags and a
|
||||
Hugging Face link; a content card with tabs:
|
||||
- **Files** (default): selected files with type icon, size, LFS marker and local state
|
||||
(downloaded, missing, size mismatch, …), a "on disk" progress summary, and the unselected repo
|
||||
files collapsed below; each file links to the Hub at the pinned commit
|
||||
- **Model card**: the repo's README at the pinned commit, rendered (sanitized HTML, relative
|
||||
links/images resolved to the Hub)
|
||||
- **Files**: selected files with local state and links, plus the other files in the repo
|
||||
- **Jobs**: download history
|
||||
- Custom tags are color-coded (color derived from the name, the same everywhere).
|
||||
- App icon (要).
|
||||
- Sidebar with download status/actions, local copy details (commit, path, patterns) and a model
|
||||
tree (base model → quantized/finetuned → this repo) listing other local models of the same base.
|
||||
- Hub metadata now includes the author's avatar and the relation to the base model; existing models
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
import {
|
||||
AlertTriangleIcon,
|
||||
BoxIcon,
|
||||
CheckCircle2Icon,
|
||||
ChevronRightIcon,
|
||||
CircleDashedIcon,
|
||||
FileIcon,
|
||||
FileImageIcon,
|
||||
FileJsonIcon,
|
||||
FileTextIcon,
|
||||
ShieldCheckIcon,
|
||||
XCircleIcon,
|
||||
} from "lucide-react";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import type { ModelFileState } from "@/lib/db/schema";
|
||||
import { formatBytes, percent, shortSha } from "@/lib/format";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type FileRow = { id: string; path: string; size: number; lfsSha256: string | null; state: ModelFileState };
|
||||
|
||||
const STATE: Record<ModelFileState, { label: string; icon: React.ReactNode; className: string }> = {
|
||||
pending: { label: "Not downloaded", icon: <CircleDashedIcon className="size-3.5" />, className: "text-muted-foreground" },
|
||||
present: { label: "Downloaded", icon: <CheckCircle2Icon className="size-3.5" />, className: "text-emerald-600 dark:text-emerald-400" },
|
||||
verified: { label: "Verified", icon: <ShieldCheckIcon className="size-3.5" />, className: "text-emerald-600 dark:text-emerald-400" },
|
||||
missing: { label: "Missing", icon: <XCircleIcon className="size-3.5" />, className: "text-destructive" },
|
||||
size_mismatch: { label: "Size mismatch", icon: <AlertTriangleIcon className="size-3.5" />, className: "text-amber-600 dark:text-amber-400" },
|
||||
hash_mismatch: { label: "Hash mismatch", icon: <AlertTriangleIcon className="size-3.5" />, className: "text-amber-600 dark:text-amber-400" },
|
||||
};
|
||||
|
||||
function FileTypeIcon({ path }: { path: string }) {
|
||||
const ext = path.toLowerCase().split(".").pop() ?? "";
|
||||
const cls = "size-4 text-muted-foreground";
|
||||
if (["gguf", "safetensors", "bin", "pt", "onnx"].includes(ext)) return <BoxIcon className={cls} />;
|
||||
if (ext === "json") return <FileJsonIcon className={cls} />;
|
||||
if (["md", "txt"].includes(ext)) return <FileTextIcon className={cls} />;
|
||||
if (["png", "jpg", "jpeg", "gif", "webp", "svg"].includes(ext)) return <FileImageIcon className={cls} />;
|
||||
return <FileIcon className={cls} />;
|
||||
}
|
||||
|
||||
function FileName({ path }: { path: string }) {
|
||||
const slash = path.lastIndexOf("/");
|
||||
return (
|
||||
<span className="min-w-0 truncate font-mono text-[13px]" title={path}>
|
||||
{slash >= 0 && <span className="text-muted-foreground">{path.slice(0, slash + 1)}</span>}
|
||||
{path.slice(slash + 1)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function Row({ file, href, muted, showState }: { file: FileRow; href: string; muted?: boolean; showState: boolean }) {
|
||||
const state = STATE[file.state];
|
||||
return (
|
||||
<li>
|
||||
<a
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className={cn(
|
||||
// Fixed status column so sizes line up between selected and unselected rows.
|
||||
"grid grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-3 px-5 py-2.5 transition-colors hover:bg-muted/50 sm:grid-cols-[1rem_minmax(0,1fr)_5rem_1rem] md:grid-cols-[1rem_minmax(0,1fr)_5rem_7.5rem]",
|
||||
muted && "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
<FileTypeIcon path={file.path} />
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<FileName path={file.path} />
|
||||
{file.lfsSha256 && (
|
||||
<span className="shrink-0 rounded border px-1 text-[10px] leading-4 text-muted-foreground">LFS</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="hidden text-right text-sm tabular-nums sm:block">{formatBytes(file.size)}</span>
|
||||
{showState ? (
|
||||
<span className={cn("flex items-center justify-end gap-1.5 text-xs whitespace-nowrap", state.className)}>
|
||||
{state.icon}
|
||||
<span className="hidden md:inline">{state.label}</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-right text-sm tabular-nums sm:hidden">{formatBytes(file.size)}</span>
|
||||
)}
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
/** "Files and versions"-style list: selected files with their local state, the rest collapsed. */
|
||||
export function FilesTab({
|
||||
repoId,
|
||||
sha,
|
||||
selected,
|
||||
others,
|
||||
}: {
|
||||
repoId: string;
|
||||
sha: string;
|
||||
selected: FileRow[];
|
||||
others: FileRow[];
|
||||
}) {
|
||||
const blob = (path: string) => `https://huggingface.co/${repoId}/blob/${sha}/${path}`;
|
||||
const totalBytes = selected.reduce((s, f) => s + f.size, 0);
|
||||
const local = selected.filter((f) => f.state === "present" || f.state === "verified");
|
||||
const localBytes = local.reduce((s, f) => s + f.size, 0);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex flex-col gap-2 px-5 py-4">
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 text-sm">
|
||||
<span>
|
||||
<span className="font-medium">{selected.length} selected file{selected.length === 1 ? "" : "s"}</span>
|
||||
<span className="text-muted-foreground"> · {formatBytes(totalBytes)} · commit {shortSha(sha)}</span>
|
||||
</span>
|
||||
<span className="text-muted-foreground">
|
||||
{local.length} of {selected.length} on disk · {formatBytes(localBytes)}
|
||||
</span>
|
||||
</div>
|
||||
<Progress value={percent(localBytes, totalBytes)} />
|
||||
</div>
|
||||
|
||||
<ul className="divide-y border-t">
|
||||
{selected.map((f) => (
|
||||
<Row key={f.id} file={f} href={blob(f.path)} showState />
|
||||
))}
|
||||
</ul>
|
||||
|
||||
{others.length > 0 && (
|
||||
<details className="group border-t">
|
||||
<summary className="flex cursor-pointer list-none items-center gap-2 px-5 py-3 text-sm hover:bg-muted/50">
|
||||
<ChevronRightIcon className="size-4 text-muted-foreground transition-transform group-open:rotate-90" />
|
||||
<span className="font-medium">Not selected</span>
|
||||
<span className="text-muted-foreground">
|
||||
{others.length} file{others.length === 1 ? "" : "s"} · {formatBytes(others.reduce((s, f) => s + f.size, 0))}
|
||||
</span>
|
||||
</summary>
|
||||
<ul className="divide-y border-t">
|
||||
{others.map((f) => (
|
||||
<Row key={f.id} file={f} href={blob(f.path)} muted showState={false} />
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import { CopyButton } from "@/components/copy-button";
|
||||
import { LocalTime } from "@/components/local-time";
|
||||
import { ModelStatusBadge } from "@/components/model-status-badge";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { formatBytes, shortSha } from "@/lib/format";
|
||||
import { fetchModelCard } from "@/lib/hub/client";
|
||||
@@ -28,6 +27,7 @@ import { getModelByRepo, relatedModels } from "@/lib/library";
|
||||
import { quantGroup } from "@/lib/selection";
|
||||
import { modelTagList } from "@/lib/tags";
|
||||
import { DownloadCard } from "./download-card";
|
||||
import { FilesTab } from "./files-tab";
|
||||
import { JobsTab } from "./jobs-tab";
|
||||
import { ModelCard } from "./model-card";
|
||||
import { RemoveModelButton } from "./remove-model-button";
|
||||
@@ -36,8 +36,8 @@ import { TagEditor } from "./tag-editor";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const TABS = [
|
||||
{ id: "card", label: "Model card", icon: FileTextIcon },
|
||||
{ id: "files", label: "Files", icon: FolderIcon },
|
||||
{ id: "card", label: "Model card", icon: FileTextIcon },
|
||||
{ id: "jobs", label: "Jobs", icon: HistoryIcon },
|
||||
] as const;
|
||||
type TabId = (typeof TABS)[number]["id"];
|
||||
@@ -83,7 +83,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
const { model, files } = data;
|
||||
if (model.repoId !== `${org}/${repo}`) redirect(`/${model.repoId}`); // canonical spelling
|
||||
|
||||
const tab: TabId = TABS.some((t) => t.id === sp.tab) ? (sp.tab as TabId) : "card";
|
||||
const tab: TabId = TABS.some((t) => t.id === sp.tab) ? (sp.tab as TabId) : "files";
|
||||
const [author, name] = model.repoId.split("/");
|
||||
const hub = `https://huggingface.co/${model.repoId}`;
|
||||
const baseModels = model.baseModels ?? [];
|
||||
@@ -105,7 +105,7 @@ 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}`);
|
||||
const tabHref = (id: TabId) => (id === "files" ? `/${model.repoId}` : `/${model.repoId}?tab=${id}`);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
@@ -120,11 +120,10 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
<h1 className="text-xl font-semibold break-all">{name}</h1>
|
||||
<CopyButton value={model.repoId} label="Copy repo ID" />
|
||||
<ModelStatusBadge status={model.status} />
|
||||
{model.status === "pending" && (
|
||||
<div className="ml-auto">
|
||||
<RemoveModelButton id={model.id} />
|
||||
</div>
|
||||
)}
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
{model.status === "pending" && <RemoveModelButton id={model.id} />}
|
||||
<ExternalButton href={hub}>🤗 Hugging Face</ExternalButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
@@ -153,15 +152,6 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
<TagEditor modelId={model.id} tags={tags} />
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<ExternalButton href={`${hub}/discussions`}>Community</ExternalButton>
|
||||
{baseModels[0] && (
|
||||
<ExternalButton href={`https://huggingface.co/${baseModels[0]}`}>Base: {baseModels[0]}</ExternalButton>
|
||||
)}
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
|
||||
@@ -187,23 +177,25 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
|
||||
</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} />
|
||||
<>
|
||||
<ModelCard markdown={card} repoId={model.repoId} sha={model.pinnedSha} />
|
||||
<div className="mt-6 flex justify-end">
|
||||
<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>
|
||||
</>
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{card === null ? "This repository has no model card." : "The model card could not be loaded."}{" "}
|
||||
@@ -400,81 +392,3 @@ function ModelTree({
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
|
||||
function FilesTab({
|
||||
repoId,
|
||||
sha,
|
||||
selected,
|
||||
others,
|
||||
}: {
|
||||
repoId: string;
|
||||
sha: string;
|
||||
selected: { id: string; path: string; size: number; lfsSha256: string | null; state: string }[];
|
||||
others: { id: string; path: string; size: number; lfsSha256: string | null }[];
|
||||
}) {
|
||||
const blob = (path: string) => `https://huggingface.co/${repoId}/blob/${sha}/${path}`;
|
||||
return (
|
||||
<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>
|
||||
<TableHead>File</TableHead>
|
||||
<TableHead className="text-right">Size</TableHead>
|
||||
<TableHead>Local</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{selected.map((f) => (
|
||||
<TableRow key={f.id}>
|
||||
<TableCell className="font-mono text-xs break-all whitespace-normal">
|
||||
<a href={blob(f.path)} target="_blank" rel="noreferrer" className="hover:underline">
|
||||
{f.path}
|
||||
</a>
|
||||
{f.lfsSha256 && <span className="ml-2 rounded border px-1 text-[10px] text-muted-foreground">LFS</span>}
|
||||
</TableCell>
|
||||
<TableCell className="text-right tabular-nums">{formatBytes(f.size)}</TableCell>
|
||||
<TableCell className="text-sm text-muted-foreground">{f.state}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
{others.length > 0 && (
|
||||
<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
|
||||
</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>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { XIcon } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useId, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { TagBadge } from "@/components/tag-badge";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import type { Tag } from "@/lib/tags";
|
||||
|
||||
@@ -51,12 +51,11 @@ export function TagEditor({ modelId, tags }: { modelId: string; tags: Tag[] }) {
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{tags.map((t) => (
|
||||
<Badge key={t.id} variant="secondary" className="gap-1">
|
||||
{t.name}
|
||||
<button type="button" aria-label={`Remove tag ${t.name}`} onClick={() => remove(t)}>
|
||||
<TagBadge key={t.id} name={t.name}>
|
||||
<button type="button" aria-label={`Remove tag ${t.name}`} onClick={() => remove(t)} className="opacity-60 hover:opacity-100">
|
||||
<XIcon className="size-3" />
|
||||
</button>
|
||||
</Badge>
|
||||
</TagBadge>
|
||||
))}
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
|
||||
@@ -16,12 +16,15 @@ export function FacetFilter({
|
||||
selected,
|
||||
onChange,
|
||||
format = (v) => v,
|
||||
marker,
|
||||
}: {
|
||||
label: string;
|
||||
values: [string, number][];
|
||||
selected: string[];
|
||||
onChange: (next: string[]) => void;
|
||||
format?: (value: string) => string;
|
||||
/** Optional element before each value, e.g. a tag's color dot. */
|
||||
marker?: (value: string) => React.ReactNode;
|
||||
}) {
|
||||
const active = selected.length > 0;
|
||||
return (
|
||||
@@ -41,6 +44,7 @@ export function FacetFilter({
|
||||
closeOnClick={false}
|
||||
onCheckedChange={(on) => onChange(on ? [...selected, value] : selected.filter((v) => v !== value))}
|
||||
>
|
||||
{marker?.(value)}
|
||||
<span className="flex-1">{format(value)}</span>
|
||||
<span className="ml-4 text-xs text-muted-foreground tabular-nums">{count}</span>
|
||||
</DropdownMenuCheckboxItem>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useMemo, useState } from "react";
|
||||
import { JobProgress, JobStateBadge } from "@/components/job-progress";
|
||||
import { LocalTime } from "@/components/local-time";
|
||||
import { MODEL_STATUS, ModelStatusBadge } from "@/components/model-status-badge";
|
||||
import { TagBadge, TagDot } from "@/components/tag-badge";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
@@ -122,6 +123,7 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
|
||||
selected={filters[facet]}
|
||||
onChange={(v) => updateFilter(facet, v)}
|
||||
format={facet === "status" ? statusLabel : undefined}
|
||||
marker={facet === "tag" ? (v) => <TagDot name={v} /> : undefined}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -134,6 +136,7 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
|
||||
{FACETS.flatMap((facet) =>
|
||||
filters[facet].map((v) => (
|
||||
<Badge key={`${facet}:${v}`} variant="secondary" className="gap-1">
|
||||
{facet === "tag" && <TagDot name={v} />}
|
||||
{FACET_LABEL[facet]}: {facet === "status" ? statusLabel(v) : v}
|
||||
<button
|
||||
type="button"
|
||||
@@ -190,7 +193,7 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
|
||||
type="button"
|
||||
onClick={() => !filters.tag.includes(t.name) && updateFilter("tag", [...filters.tag, t.name])}
|
||||
>
|
||||
<Badge variant="outline">{t.name}</Badge>
|
||||
<TagBadge name={t.name} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<defs>
|
||||
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#7c5cff"/>
|
||||
<stop offset="1" stop-color="#14b8a6"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="64" height="64" rx="14" fill="url(#g)"/>
|
||||
<text x="32" y="45" text-anchor="middle" font-size="38" font-weight="700" fill="#fff"
|
||||
font-family="'Yu Gothic','Meiryo','Noto Sans JP','Hiragino Sans',sans-serif">要</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 497 B |
@@ -0,0 +1,68 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
// Fixed palette (full class strings so Tailwind picks them up). A tag's color is derived from its
|
||||
// name, so the same tag has the same color everywhere without storing anything.
|
||||
const PALETTE = [
|
||||
"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",
|
||||
"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",
|
||||
"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",
|
||||
"border-rose-500/30 bg-rose-500/10 text-rose-700 dark:text-rose-300",
|
||||
"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",
|
||||
"border-cyan-500/30 bg-cyan-500/10 text-cyan-700 dark:text-cyan-300",
|
||||
"border-lime-500/30 bg-lime-500/10 text-lime-700 dark:text-lime-300",
|
||||
"border-orange-500/30 bg-orange-500/10 text-orange-700 dark:text-orange-300",
|
||||
"border-fuchsia-500/30 bg-fuchsia-500/10 text-fuchsia-700 dark:text-fuchsia-300",
|
||||
"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",
|
||||
];
|
||||
|
||||
const DOTS = [
|
||||
"bg-sky-500",
|
||||
"bg-emerald-500",
|
||||
"bg-amber-500",
|
||||
"bg-rose-500",
|
||||
"bg-violet-500",
|
||||
"bg-cyan-500",
|
||||
"bg-lime-500",
|
||||
"bg-orange-500",
|
||||
"bg-fuchsia-500",
|
||||
"bg-teal-500",
|
||||
];
|
||||
|
||||
function colorIndex(name: string): number {
|
||||
let h = 0;
|
||||
for (const ch of name.trim().toLowerCase()) h = (h * 31 + ch.codePointAt(0)!) >>> 0;
|
||||
return h % PALETTE.length;
|
||||
}
|
||||
|
||||
export function tagColorClass(name: string): string {
|
||||
return PALETTE[colorIndex(name)];
|
||||
}
|
||||
|
||||
/** Small colored dot for a tag (e.g. in filter menus). */
|
||||
export function TagDot({ name }: { name: string }) {
|
||||
return <span className={cn("inline-block size-2 shrink-0 rounded-full", DOTS[colorIndex(name)])} />;
|
||||
}
|
||||
|
||||
/** A user tag, colored by its name. */
|
||||
export function TagBadge({
|
||||
name,
|
||||
className,
|
||||
children,
|
||||
}: {
|
||||
name: string;
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex h-5 items-center gap-1 rounded-full border px-2 text-xs font-medium whitespace-nowrap",
|
||||
tagColorClass(name),
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{name}
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -28,5 +28,5 @@ export async function proxy(req: NextRequest, event: NextFetchEvent) {
|
||||
export const config = {
|
||||
// Everything except the Auth.js endpoints, the login page and static assets.
|
||||
// Exact exclusions only: an org like "loginx" must still go through the gate.
|
||||
matcher: ["/((?!api/auth/|login$|_next/static/|_next/image/|favicon\\.ico$).*)"],
|
||||
matcher: ["/((?!api/auth/|login$|_next/static/|_next/image/|favicon\\.ico$|icon\\.svg$).*)"],
|
||||
};
|
||||
Reference in new issue
Block a user