Download code/web/src/components/site-header.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 4.69 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/e02a36ecf3673d4b2e88ef0bd4eeabf2f6116e46/code/web/src/components/site-header.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@e02a36ecf3673d4b2e88ef0bd4eeabf2f6116e46/code/web/src/components/site-header.tsx
-
curl -L -o site-header.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/e02a36ecf3673d4b2e88ef0bd4eeabf2f6116e46/code/web/src/components/site-header.tsx
4.69 kB
| import { ArrowUpRight, ChevronDown, Globe } from "lucide-react" | |
| import { | |
| DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, | |
| DropdownMenuSeparator, DropdownMenuTrigger, | |
| } from "@/components/ui/dropdown-menu" | |
| import type { Site } from "@/lib/types" | |
| import { catColor } from "@/lib/category" | |
| import { full } from "@/lib/format" | |
| import { href } from "@/lib/route" | |
| import { Logo } from "@/components/logo" | |
| import { OFFICIAL_LINKS } from "@/lib/links" | |
| import { catName, getLang, setLang, T } from "@/lib/i18n" | |
| /** Sits on the hero video of every page: the MiniMax logo home, the language switch, and every | |
| * model page in a menu (minimax.io's pages at its foot). */ | |
| export function SiteHeader({ site }: { site: Site }) { | |
| const rel = (k: string) => site.releases.find((r) => r.key === k)! | |
| return ( | |
| <header className="relative z-20 mx-auto flex w-full max-w-[1200px] items-center justify-between gap-4 px-4 py-5 sm:px-8 sm:py-6"> | |
| <a href={href()} className="-m-1.5 rounded-lg p-1.5 text-white focus-visible:outline-2 focus-visible:outline-white"> | |
| <Logo className="h-8 w-auto sm:h-9" /> | |
| </a> | |
| <div className="flex items-center gap-1 sm:gap-2"> | |
| <button type="button" onClick={() => setLang(getLang() === "zh" ? "en" : "zh")} | |
| lang={getLang() === "zh" ? "en" : "zh"} aria-label={T.switchLang} title={T.switchLang} | |
| className="inline-flex h-10 items-center gap-1.5 rounded-full px-3.5 text-[15px] font-medium text-white transition-colors hover:bg-white/15 focus-visible:outline-2 focus-visible:outline-white"> | |
| <Globe className="size-4 opacity-85" />{T.otherLang} | |
| </button> | |
| <DropdownMenu modal={false}> | |
| <DropdownMenuTrigger className="group inline-flex h-10 items-center gap-1.5 rounded-full bg-white px-4.5 text-[15px] font-medium text-[#171717] transition-colors hover:bg-white/85 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white data-[state=open]:bg-white/85"> | |
| {T.menu} | |
| <ChevronDown className="size-4 transition-transform duration-200 group-data-[state=open]:rotate-180" /> | |
| </DropdownMenuTrigger> | |
| <DropdownMenuContent align="end" sideOffset={10} | |
| className="w-[300px] rounded-2xl border border-border bg-white p-2 text-foreground shadow-[0_24px_60px_-12px_rgba(23,23,23,0.25)]"> | |
| {site.categories.map((c, i) => { | |
| const pages = c.releases.map(rel).filter((r) => r.page) | |
| const total = c.releases.reduce((a, k) => a + rel(k).n, 0) | |
| return ( | |
| <DropdownMenuGroup key={c.key}> | |
| {i > 0 && <DropdownMenuSeparator className="my-1.5 bg-border" />} | |
| <DropdownMenuItem asChild className="rounded-lg px-2.5 py-2 text-[15px] focus:bg-muted"> | |
| <a href={href(c.key)} className="flex items-center gap-2.5"> | |
| <span className="size-2.5 rounded-full" style={{ background: catColor(c.key) }} /> | |
| <span className="font-semibold">{catName(c)}</span> | |
| <span className="ml-auto font-display text-muted-foreground tabular-nums">{full(total)}</span> | |
| </a> | |
| </DropdownMenuItem> | |
| {pages.length > 1 && pages.map((r) => ( | |
| <DropdownMenuItem key={r.key} asChild className="rounded-lg py-1.5 pr-2.5 pl-7 text-[15px] text-foreground/80 focus:bg-muted focus:text-foreground"> | |
| <a href={href(c.key, r.key)} className="flex items-center"> | |
| {r.name} | |
| <span className="ml-auto font-display text-muted-foreground tabular-nums">{full(r.n)}</span> | |
| </a> | |
| </DropdownMenuItem> | |
| ))} | |
| </DropdownMenuGroup> | |
| ) | |
| })} | |
| <DropdownMenuSeparator className="my-1.5 bg-border" /> | |
| <DropdownMenuLabel className="sr-only">{T.elsewhere}</DropdownMenuLabel> | |
| {[...OFFICIAL_LINKS.map((l) => ({ label: T.officialLink(l.label), href: l.href })), | |
| { label: T.hfOrg, href: "https://huggingface.co/MiniMaxAI" }].map((l) => ( | |
| <DropdownMenuItem key={l.href} asChild className="rounded-lg px-2.5 py-2 text-[15px] text-foreground/80 focus:bg-muted focus:text-foreground"> | |
| <a href={l.href} target="_blank" rel="noopener" className="flex items-center gap-2"> | |
| {l.label} <ArrowUpRight className="ml-auto size-4 text-muted-foreground" /> | |
| </a> | |
| </DropdownMenuItem> | |
| ))} | |
| </DropdownMenuContent> | |
| </DropdownMenu> | |
| </div> | |
| </header> | |
| ) | |
| } | |