File size: 4,710 Bytes
2471af3
 
 
 
 
 
 
 
 
61db3dc
3c90ca7
2471af3
61db3dc
2471af3
 
 
 
61db3dc
 
2471af3
3c90ca7
 
 
 
 
 
 
 
 
 
2471af3
3c90ca7
2471af3
 
 
 
61db3dc
2471af3
 
 
 
 
61db3dc
 
2471af3
 
 
61db3dc
2471af3
 
 
61db3dc
2471af3
 
61db3dc
2471af3
 
 
 
 
 
61db3dc
2471af3
3c90ca7
 
 
 
 
 
 
 
2471af3
 
3c90ca7
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
66
67
68
69
70
71
72
73
74
75
76
77
78
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"
import { Logo } from "@/components/logo"
import { OFFICIAL_LINKS } from "@/lib/links"

/** Sits on the hero video of every page: the MiniMax logo 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="-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">
      {/* minimax.io's pages for the releases that have one, as its own header lists them */}
      <nav aria-label="On minimax.io" className="hidden items-center gap-1 md:flex">
        {OFFICIAL_LINKS.map((l) => (
          <a key={l.href} href={l.href} target="_blank" rel="noopener"
             className="inline-flex h-10 items-center gap-1 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">
            {l.label}<ArrowUpRight className="size-4 opacity-80" />
          </a>
        ))}
      </nav>
      <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">
          Models
          <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">{c.name}</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">Elsewhere</DropdownMenuLabel>
          {[...OFFICIAL_LINKS.map((l) => ({ label: `${l.label} on minimax.io`, href: l.href })),
            { label: "MiniMaxAI on Hugging Face", 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>
  )
}