File size: 3,991 Bytes
2471af3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { ArrowUpRight, ChevronDown } 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"

/** Sits on the dark stage of every page: the MiniMax mark home, and every model page in a menu. */
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="flex items-center gap-3 rounded-lg text-white focus-visible:outline-2 focus-visible:outline-white/60">
        {site.org.a && <img src={site.org.a} alt="" className="size-9 rounded-[10px]" />}
        <span className="font-display text-[18px] leading-none font-semibold tracking-[-0.01em] whitespace-nowrap sm:text-[20px]">
          MiniMax
        </span>
      </a>
      <DropdownMenu modal={false}>
        <DropdownMenuTrigger className="group inline-flex h-10 items-center gap-2 rounded-full border border-white/15 bg-white/[0.06] px-4 text-[15px] font-medium text-white backdrop-blur transition-colors hover:border-white/35 hover:bg-white/12 focus-visible:outline-2 focus-visible:outline-white/60 data-[state=open]:bg-white/15">
          Models
          <ChevronDown className="size-4 transition-transform duration-200 group-data-[state=open]:rotate-180" />
        </DropdownMenuTrigger>
        <DropdownMenuContent align="end" sideOffset={10}
                             className="dark w-[300px] rounded-2xl border border-white/10 bg-[#16161d]/95 p-2 text-[#ededed] shadow-[0_24px_60px_rgba(0,0,0,0.5)] backdrop-blur-xl">
          {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-white/8" />}
                <DropdownMenuItem asChild className="rounded-lg px-2.5 py-2 text-[15px] focus:bg-white/8">
                  <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">{c.name}</span>
                    <span className="ml-auto font-display text-white/55 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-white/80 focus:bg-white/8 focus:text-white">
                    <a href={href(c.key, r.key)} className="flex items-center">
                      {r.name}
                      <span className="ml-auto font-display text-white/45 tabular-nums">{full(r.n)}</span>
                    </a>
                  </DropdownMenuItem>
                ))}
              </DropdownMenuGroup>
            )
          })}
          <DropdownMenuSeparator className="my-1.5 bg-white/8" />
          <DropdownMenuLabel className="sr-only">Elsewhere</DropdownMenuLabel>
          <DropdownMenuItem asChild className="rounded-lg px-2.5 py-2 text-[15px] text-white/80 focus:bg-white/8 focus:text-white">
            <a href="https://huggingface.co/MiniMaxAI" target="_blank" rel="noopener" className="flex items-center gap-2">
              MiniMaxAI on Hugging Face <ArrowUpRight className="ml-auto size-4 text-white/50" />
            </a>
          </DropdownMenuItem>
        </DropdownMenuContent>
      </DropdownMenu>
    </header>
  )
}