code: sync from git
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- code/README.md +4 -13
- code/dataset/README.md +77 -0
- code/hfeco/export.py +100 -0
- code/hfeco/hubstats.py +28 -15
- code/hfeco/org.py +11 -10
- code/scripts/backfill_hubstats.py +7 -7
- code/scripts/daily.py +11 -6
- code/scripts/push_code.py +4 -3
- code/space/README.md +14 -0
- code/web/.gitignore +24 -0
- code/web/.oxlintrc.json +8 -0
- code/web/README.md +32 -0
- code/web/components.json +25 -0
- code/web/index.html +15 -0
- code/web/package-lock.json +0 -0
- code/web/package.json +45 -0
- code/web/src/App.tsx +27 -0
- code/web/src/components/category-blocks.tsx +98 -0
- code/web/src/components/community-chart.tsx +325 -0
- code/web/src/components/daily.tsx +91 -0
- code/web/src/components/download-button.tsx +40 -0
- code/web/src/components/downloads.tsx +79 -0
- code/web/src/components/galaxy.tsx +401 -0
- code/web/src/components/growth.tsx +93 -0
- code/web/src/components/layout.tsx +91 -0
- code/web/src/components/model-table.tsx +86 -0
- code/web/src/components/octopus.tsx +16 -0
- code/web/src/components/rel.tsx +42 -0
- code/web/src/components/relation-table.tsx +64 -0
- code/web/src/components/release-rail.tsx +86 -0
- code/web/src/components/segmented.tsx +22 -0
- code/web/src/components/site-header.tsx +64 -0
- code/web/src/components/sparkline.tsx +68 -0
- code/web/src/components/top-lists.tsx +59 -0
- code/web/src/components/ui/avatar.tsx +111 -0
- code/web/src/components/ui/badge.tsx +48 -0
- code/web/src/components/ui/button.tsx +66 -0
- code/web/src/components/ui/card.tsx +102 -0
- code/web/src/components/ui/chart.tsx +370 -0
- code/web/src/components/ui/dropdown-menu.tsx +266 -0
- code/web/src/components/ui/hover-card.tsx +41 -0
- code/web/src/components/ui/input.tsx +18 -0
- code/web/src/components/ui/separator.tsx +27 -0
- code/web/src/components/ui/table.tsx +113 -0
- code/web/src/components/ui/toggle-group.tsx +89 -0
- code/web/src/components/ui/toggle.tsx +44 -0
- code/web/src/components/ui/tooltip.tsx +56 -0
- code/web/src/components/who.tsx +12 -0
- code/web/src/index.css +203 -0
- code/web/src/lib/category.ts +10 -0
code/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
# MiniMax
|
| 2 |
|
| 3 |
-
每天扫一遍 Hugging Face,找出 MiniMax 开
|
| 4 |
|
| 5 |
- 看板:公开 Space `MiniMaxAI/ecosystem`(2026-11-18 公开),英文落地页(静态页面,数据每天更新)。直接链接:https://minimaxai-ecosystem.static.hf.space/index.html
|
| 6 |
-
- 首页:全部开
|
| 7 |
- 分类页 `#/<模态>/<发布>`:社区模型增长、类型、作者、全部模型列表、气泡图
|
| 8 |
- H3、H3-Image 用本仓库的全量扫描和分类(含没声明 base_model 的仓库);其余发布沿 HF 的 base_model 标签逐层往下找(和 Model tree 一样,只算声明了的)
|
| 9 |
- 数据:私有数据集 `MiniMaxAI/oss-ecosystem-data`
|
|
@@ -62,21 +62,12 @@ raw/hubstats.parquet 历史累计下载(day, repo_id, d30, dla)
|
|
| 62 |
|
| 63 |
## 新发布
|
| 64 |
|
| 65 |
-
官方新
|
| 66 |
|
| 67 |
## 公开前要注意
|
| 68 |
|
| 69 |
看板 Space 以后会公开。页面数据只有页面用到的字段:没有分类依据、置信度、声明状态。成人内容(名字、HF 的成人标签、模型卡自述、同作者多个成人仓库、它们的复制和下游)照常计数,但不在页面上出现名字;`families/<key>.py` 的 `nsfw_author_exempt` 是例外名单。规则是尽力而为,公开前请人工过一遍"全部衍生模型"。
|
| 70 |
|
| 71 |
-
## 已知问题(记录,暂不处理)
|
| 72 |
-
|
| 73 |
-
2026-11-20 记下。都不影响数字正确性,先不动:
|
| 74 |
-
|
| 75 |
-
- **两种计数口径并列展示。** H3 / H3-Image 走全量扫描和分类(含没声明 `base_model` 的仓库),其余发布沿 HF 的 `base_model` 标签逐层往下找(只算声明了的)。所以 video 的 1323 和 language 的 578 不是同一种口径。这份 README 开头写了,页面上没写,外部读者容易当成可比数字。要么在落地页加一句说明,要么在分类页标注口径。
|
| 76 |
-
- **`raw/` 只追加,仓库会持续膨胀。** 现在 518 MB 里约 470 MB 是 git 历史(每天一份 parquet 的所有版本)。HF 私有仓库有存储配额,暂时不是问题。长期要么定期 squash,要么把 `raw/` 挪到仓库外、仓库里只留近期。
|
| 77 |
-
- **`cache/<family>/enrich.jsonl` 是单个文件。** 现在 43 MB,每次探测完整体重写,走 LFS 且每次 commit 存一版。仓库数翻倍后会有压力,可以按 sha 分片或换成 parquet。
|
| 78 |
-
- **每日任务依赖单个 token,且没有告警。** `HF_TOKEN` 是 saladday1 的写 token,过期或被撤销时 `job.sh` 会直接失败(`set -e`),但不会通知任何人,只能靠人主动看 HF Jobs 日志。
|
| 79 |
-
|
| 80 |
## 本地运行
|
| 81 |
|
| 82 |
```bash
|
|
|
|
| 1 |
+
# MiniMax Ecosystem:社区生态统计
|
| 2 |
|
| 3 |
+
每天扫一遍 Hugging Face,找出 MiniMax 公开发布的模型的下游仓库,判断每个仓库真正属于哪个官方模型、是什么关系,记录下载量,生成看板。
|
| 4 |
|
| 5 |
- 看板:公开 Space `MiniMaxAI/ecosystem`(2026-11-18 公开),英文落地页(静态页面,数据每天更新)。直接链接:https://minimaxai-ecosystem.static.hf.space/index.html
|
| 6 |
+
- 首页:全部公开发布的社区规模曲线(发布节点钉在曲线上)、发布卡片、按模态分块(Video / Language / Image / Music)
|
| 7 |
- 分类页 `#/<模态>/<发布>`:社区模型增长、类型、作者、全部模型列表、气泡图
|
| 8 |
- H3、H3-Image 用本仓库的全量扫描和分类(含没声明 base_model 的仓库);其余发布沿 HF 的 base_model 标签逐层往下找(和 Model tree 一样,只算声明了的)
|
| 9 |
- 数据:私有数据集 `MiniMaxAI/oss-ecosystem-data`
|
|
|
|
| 62 |
|
| 63 |
## 新发布
|
| 64 |
|
| 65 |
+
官方新发布一个模型时不用改代码:`org.py` 按 `RELEASES` 的名字规则归组,匹配不上的公开仓库自成一个发布、按 pipeline tag 归模态,日志里会提示。想合并进已有发布或换模态,就在 `RELEASES` 加一行。社区模型满 10 个(`PAGE_MIN`)的发布才有自己的分类页 tab。私有仓库永远不会出现:只取 `private is False` 的仓库,写出前 `check_public` 还会再查一遍。
|
| 66 |
|
| 67 |
## 公开前要注意
|
| 68 |
|
| 69 |
看板 Space 以后会公开。页面数据只有页面用到的字段:没有分类依据、置信度、声明状态。成人内容(名字、HF 的成人标签、模型卡自述、同作者多个成人仓库、它们的复制和下游)照常计数,但不在页面上出现名字;`families/<key>.py` 的 `nsfw_author_exempt` 是例外名单。规则是尽力而为,公开前请人工过一遍"全部衍生模型"。
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
## 本地运行
|
| 72 |
|
| 73 |
```bash
|
code/dataset/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: MiniMax Ecosystem Data
|
| 3 |
+
configs:
|
| 4 |
+
- config_name: models
|
| 5 |
+
data_files: tables/models.parquet
|
| 6 |
+
default: true
|
| 7 |
+
- config_name: releases
|
| 8 |
+
data_files: tables/releases.parquet
|
| 9 |
+
- config_name: downloads
|
| 10 |
+
data_files: tables/downloads.parquet
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# MiniMax Ecosystem · 数据
|
| 14 |
+
|
| 15 |
+
MiniMax 在 Hugging Face 上公开发布的模型,社区基于它们做的每一个模型(LoRA、微调、量化、合并……),以及它们的下载量。每天 00:30 UTC 自动更新。
|
| 16 |
+
|
| 17 |
+
看板:[huggingface.co/spaces/MiniMaxAI/ecosystem](https://huggingface.co/spaces/MiniMaxAI/ecosystem)
|
| 18 |
+
|
| 19 |
+
## 拿来就用
|
| 20 |
+
|
| 21 |
+
| 文件 | 一行是 | 适合回答 |
|
| 22 |
+
| --- | --- | --- |
|
| 23 |
+
| `tables/models.parquet` | 一个仓库(官方 + 社区) | 谁基于哪个模型做了什么、各有多少下载 |
|
| 24 |
+
| `tables/releases.parquet` | 一次官方发布 | 每个发布带出了多大的社区 |
|
| 25 |
+
| `tables/downloads.parquet` | 一个仓库的某一天 | 下载量怎么随时间涨起来 |
|
| 26 |
+
| `site/*.json` | 看板页面读的原始数据 | 想复刻看板上的某张图 |
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
import pandas as pd
|
| 30 |
+
|
| 31 |
+
repo = "hf://datasets/MiniMaxAI/oss-ecosystem-data"
|
| 32 |
+
models = pd.read_parquet(f"{repo}/tables/models.parquet")
|
| 33 |
+
releases = pd.read_parquet(f"{repo}/tables/releases.parquet")
|
| 34 |
+
downloads = pd.read_parquet(f"{repo}/tables/downloads.parquet")
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
三张表的列名统一:同名的列含义相同。
|
| 38 |
+
|
| 39 |
+
| 列 | 含义 |
|
| 40 |
+
| --- | --- |
|
| 41 |
+
| `repo_id` | 仓库,如 `unsloth/MiniMax-H3-GGUF` |
|
| 42 |
+
| `release` | 所属官方发布:`h3`、`h3-image`、`m3`、`m2.7`… |
|
| 43 |
+
| `modality` | `Video` / `Language` / `Image` / `Music` |
|
| 44 |
+
| `official` | 是否 MiniMaxAI 官方仓库 |
|
| 45 |
+
| `relation` | `adapter` `finetune` `quantized` `repackage` `merge` `mirror` `component`,官方为 `official` |
|
| 46 |
+
| `parent` | 直接基于的仓库(官方模型或另一个社区模型) |
|
| 47 |
+
| `day` | 数据日期(UTC,YYYY-MM-DD) |
|
| 48 |
+
| `downloads_all_time` | 累计下载 |
|
| 49 |
+
| `downloads_30d` | 近 30 天下载 |
|
| 50 |
+
| `downloads_1d` | 最近一天的下载(相邻两天快照之差) |
|
| 51 |
+
| `likes` | 点赞数 |
|
| 52 |
+
|
| 53 |
+
`downloads` 表里 `source` 标明来源:`hub-stats` 是 2025-01 起每周一个点的历史,`snapshot` 是我们自己的每日快照(2026-11-17 起)。
|
| 54 |
+
|
| 55 |
+
## 目录
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
README.md
|
| 59 |
+
tables/ ← 给人用的三张表,每天重建
|
| 60 |
+
site/ ← 看板页面数据,原样拷贝
|
| 61 |
+
raw/ ← 采集到的原始快照,只追加、不修改
|
| 62 |
+
h3/YYYY-MM-DD.parquet H3 家族全量扫描:所有候选仓库及分类用的证据字段
|
| 63 |
+
org/YYYY-MM-DD.parquet 全组织快照:官方仓库 + 声明了 base_model 的社区模型
|
| 64 |
+
hubstats/YYYY-MM-DD.parquet cfahlgren1/hub-stats 历史中我们仓库的下载,每周一份
|
| 65 |
+
labels/h3/latest.parquet H3 家族的分类结果(谱系、关系、置信度、证据)
|
| 66 |
+
cache/ 流水线缓存(作者信息、文件头证据)
|
| 67 |
+
code/ 全部源码:流水线 hfeco/ scripts/,看板前端 web/
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
`raw/` 下三个来源都按 `目录/日期.parquet` 存放,下载量列统一为 `downloads_all_time`、`downloads_30d`。
|
| 71 |
+
|
| 72 |
+
## 口径
|
| 73 |
+
|
| 74 |
+
- **社区模型**:model card 里 `base_model` 指向我们模型的仓库,逐层往下找(和 HF 的 Model tree 一致)。H3 与 H3-Image 另用分类器补上没写 `base_model` 的仓库。
|
| 75 |
+
- **下载量**:HF 自己的计数,每天批量刷新一次。没刷新的快照不计入每日下载(记为缺失,不是 0)。
|
| 76 |
+
- **2025-02-27 之前**:hub-stats 只有近 30 天下载,没有累计值。
|
| 77 |
+
- **`tables/` 与看板同一份白名单**:只有公开仓库;成人内容仓库计入看板合计,但不出现名字,所以 `models` 表的合计会比看板数字略小。
|
code/hfeco/export.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The part of the dataset meant for people: three tidy tables, the page's own data, a card.
|
| 2 |
+
|
| 3 |
+
tables/models.parquet one row per repo (official and community), as of the day
|
| 4 |
+
tables/releases.parquet one row per official release
|
| 5 |
+
tables/downloads.parquet every repo's downloads over time (hub-stats weekly, then daily)
|
| 6 |
+
site/*.json exactly what the public page reads, copied from the same run
|
| 7 |
+
README.md the dataset card (dataset/README.md in the code)
|
| 8 |
+
|
| 9 |
+
Rebuilt by every daily run from the same whitelisted data the page shows (no names of adult
|
| 10 |
+
repos, nothing private), so the files can be passed around. Column names are the same across
|
| 11 |
+
tables: repo_id, release, modality, day, downloads_30d, downloads_all_time, likes.
|
| 12 |
+
"""
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
import pandas as pd
|
| 16 |
+
|
| 17 |
+
from . import hubstats, org, store
|
| 18 |
+
from .hub import api
|
| 19 |
+
|
| 20 |
+
CARD = Path(__file__).resolve().parent.parent / "dataset" / "README.md"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def tables(site, repos):
|
| 24 |
+
"""(models, releases, downloads) DataFrames."""
|
| 25 |
+
rel = {r["key"]: r for r in site["releases"]}
|
| 26 |
+
modality = {c["key"]: c["name"] for c in site["categories"]}
|
| 27 |
+
day = site["today"]
|
| 28 |
+
rows = []
|
| 29 |
+
for r in site["releases"]:
|
| 30 |
+
for m in r["models"]:
|
| 31 |
+
rows.append({"repo_id": m["id"], "author": m["id"].split("/")[0], "release": r["key"],
|
| 32 |
+
"modality": modality[r["cat"]], "official": True, "relation": "official",
|
| 33 |
+
"parent": None, "created": m["created"], "downloads_30d": m["dl30"],
|
| 34 |
+
"downloads_all_time": m["dlall"], "downloads_1d": None, "likes": m["likes"], "day": day})
|
| 35 |
+
for key, rs in repos.items():
|
| 36 |
+
r = rel[key]
|
| 37 |
+
for x in rs:
|
| 38 |
+
rows.append({"repo_id": x["id"], "author": x["id"].split("/")[0], "release": key,
|
| 39 |
+
"modality": modality[r["cat"]], "official": False, "relation": x["rel"],
|
| 40 |
+
"parent": x["up"], "created": x["created"] or None, "downloads_30d": x["dl30"],
|
| 41 |
+
"downloads_all_time": x["dlall"], "downloads_1d": x.get("d1"), "likes": x["likes"], "day": day})
|
| 42 |
+
models = pd.DataFrame(rows).drop_duplicates("repo_id")
|
| 43 |
+
for c in ["downloads_30d", "downloads_all_time", "downloads_1d", "likes"]:
|
| 44 |
+
models[c] = models[c].astype("Int64")
|
| 45 |
+
|
| 46 |
+
releases = pd.DataFrame([{
|
| 47 |
+
"release": r["key"], "name": r["name"], "modality": modality[r["cat"]], "date": r["date"],
|
| 48 |
+
"base_repo": r["base"], "official_repos": [m["id"] for m in r["models"]],
|
| 49 |
+
"community_models": r["n"], "builders": r["authors"],
|
| 50 |
+
"community_downloads_30d": r["dl30"], "community_downloads_all_time": r["dlall"],
|
| 51 |
+
"official_downloads_30d": r["official"].get("dl30"), "official_downloads_all_time": r["official"].get("dlall"),
|
| 52 |
+
"has_page": r["page"],
|
| 53 |
+
} for r in site["releases"]])
|
| 54 |
+
|
| 55 |
+
keep = set(models.repo_id)
|
| 56 |
+
parts = []
|
| 57 |
+
hs = hubstats.read()
|
| 58 |
+
if hs is not None:
|
| 59 |
+
parts.append(hs.assign(source="hub-stats"))
|
| 60 |
+
own = [org.read_snapshots()]
|
| 61 |
+
for fam in {Path(p).parent.name for p in (store.LOCAL / "raw").glob("*/*.parquet")} - {"org", "hubstats"}:
|
| 62 |
+
raw = store.read_raw(fam)
|
| 63 |
+
own.append(raw[raw.kind == "model"])
|
| 64 |
+
snap = pd.concat(own, ignore_index=True)[["day", "repo_id", "downloads_30d", "downloads_all_time"]]
|
| 65 |
+
parts.append(snap.assign(source="snapshot"))
|
| 66 |
+
downloads = pd.concat(parts, ignore_index=True)
|
| 67 |
+
downloads = downloads[downloads.repo_id.isin(keep)]
|
| 68 |
+
# one row per repo and day; our own snapshot wins over hub-stats on a shared day
|
| 69 |
+
downloads = (downloads.sort_values(["repo_id", "day", "source"], ascending=[True, True, False])
|
| 70 |
+
.drop_duplicates(["repo_id", "day"])
|
| 71 |
+
[["day", "repo_id", "downloads_all_time", "downloads_30d", "source"]].reset_index(drop=True))
|
| 72 |
+
for c in ["downloads_all_time", "downloads_30d"]:
|
| 73 |
+
downloads[c] = downloads[c].astype("Int64")
|
| 74 |
+
return models, releases, downloads
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def publish(site, repos, public_ids, site_files, push=False, log=print):
|
| 78 |
+
"""Writes tables/ and site/ under the local mirror; with `push`, one commit to the dataset."""
|
| 79 |
+
from huggingface_hub import CommitOperationAdd
|
| 80 |
+
|
| 81 |
+
models, releases, downloads = tables(site, repos)
|
| 82 |
+
org.check_public({"ids": list(models.repo_id) + list(models.parent.dropna()) + list(downloads.repo_id.unique())
|
| 83 |
+
+ [i for v in releases.official_repos for i in v] + list(releases.base_repo)}, public_ids)
|
| 84 |
+
out = store.LOCAL / "tables"
|
| 85 |
+
out.mkdir(parents=True, exist_ok=True)
|
| 86 |
+
paths = {}
|
| 87 |
+
for name, df in [("models", models), ("releases", releases), ("downloads", downloads)]:
|
| 88 |
+
p = out / f"{name}.parquet"
|
| 89 |
+
df.to_parquet(p, index=False)
|
| 90 |
+
paths[f"tables/{name}.parquet"] = p
|
| 91 |
+
for p in site_files:
|
| 92 |
+
paths[f"site/{Path(p).name}"] = Path(p)
|
| 93 |
+
if CARD.exists():
|
| 94 |
+
paths["README.md"] = CARD
|
| 95 |
+
log(f"export: {len(models)} models, {len(releases)} releases, {len(downloads)} download rows")
|
| 96 |
+
if push:
|
| 97 |
+
ops = [CommitOperationAdd(path_in_repo=k, path_or_fileobj=str(v)) for k, v in paths.items()]
|
| 98 |
+
api.create_commit(store.DATASET_REPO, ops, repo_type="dataset",
|
| 99 |
+
commit_message=f"tables and site data {site['today']}")
|
| 100 |
+
return paths
|
code/hfeco/hubstats.py
CHANGED
|
@@ -3,8 +3,11 @@
|
|
| 3 |
hub-stats commits a snapshot of every Hub model (models.parquet) about once a day, so its
|
| 4 |
history holds each repo's all-time downloads (`downloadsAllTime`, present from 2025-02-27) and
|
| 5 |
trailing 30-day downloads (`downloads`) day by day. `backfill` reads one revision every `every`
|
| 6 |
-
days
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
"""
|
| 9 |
import time
|
| 10 |
|
|
@@ -15,7 +18,19 @@ from .hub import api
|
|
| 15 |
|
| 16 |
SRC = "cfahlgren1/hub-stats"
|
| 17 |
URL = "https://huggingface.co/datasets/" + SRC + "/resolve/{sha}/models.parquet"
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
def revisions(every=7, since="2025-01-01"):
|
|
@@ -37,18 +52,18 @@ def revisions(every=7, since="2025-01-01"):
|
|
| 37 |
|
| 38 |
|
| 39 |
def backfill(ids, every=7, since="2025-01-01", log=print):
|
|
|
|
| 40 |
import duckdb
|
| 41 |
|
| 42 |
-
|
| 43 |
-
cache.mkdir(parents=True, exist_ok=True)
|
| 44 |
con = duckdb.connect()
|
| 45 |
con.sql("SET http_timeout=120; SET http_retries=8; SET http_retry_wait_ms=2000")
|
| 46 |
con.register("ours", pd.DataFrame({"id": sorted(ids)}))
|
| 47 |
revs = revisions(every, since)
|
| 48 |
log(f"hub-stats: {len(ids)} repos, {len(revs)} revisions")
|
| 49 |
-
t0 = time.time()
|
| 50 |
for day, sha in revs:
|
| 51 |
-
out =
|
| 52 |
if out.exists():
|
| 53 |
continue
|
| 54 |
url = URL.format(sha=sha)
|
|
@@ -56,16 +71,14 @@ def backfill(ids, every=7, since="2025-01-01", log=print):
|
|
| 56 |
try:
|
| 57 |
cols = {r[0] for r in con.sql(f"SELECT name FROM parquet_schema('{url}')").fetchall()}
|
| 58 |
dla = "downloadsAllTime" if "downloadsAllTime" in cols else "NULL::BIGINT"
|
| 59 |
-
df = con.sql(f"""SELECT id AS repo_id, downloads AS
|
| 60 |
FROM read_parquet('{url}') WHERE id IN (SELECT id FROM ours)""").df()
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
break
|
| 64 |
except Exception as e: # network: retry the revision, then leave it out
|
| 65 |
log(f"hub-stats {day} attempt {attempt + 1}: {type(e).__name__}: {str(e)[:120]}")
|
| 66 |
time.sleep(10 * (attempt + 1))
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
df.to_parquet(PATH, index=False)
|
| 70 |
-
log(f"hub-stats: {len(df)} rows over {df.day.nunique()} days in {time.time() - t0:.0f}s")
|
| 71 |
-
return PATH
|
|
|
|
| 3 |
hub-stats commits a snapshot of every Hub model (models.parquet) about once a day, so its
|
| 4 |
history holds each repo's all-time downloads (`downloadsAllTime`, present from 2025-02-27) and
|
| 5 |
trailing 30-day downloads (`downloads`) day by day. `backfill` reads one revision every `every`
|
| 6 |
+
days and keeps only the given repos, one file per revision, laid out like our own snapshots:
|
| 7 |
+
|
| 8 |
+
raw/hubstats/YYYY-MM-DD.parquet repo_id, downloads_30d, downloads_all_time
|
| 9 |
+
|
| 10 |
+
It runs once (when the folder is empty); our own daily snapshots carry the series on.
|
| 11 |
"""
|
| 12 |
import time
|
| 13 |
|
|
|
|
| 18 |
|
| 19 |
SRC = "cfahlgren1/hub-stats"
|
| 20 |
URL = "https://huggingface.co/datasets/" + SRC + "/resolve/{sha}/models.parquet"
|
| 21 |
+
DIR = store.LOCAL / "raw" / "hubstats"
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def files():
|
| 25 |
+
return sorted(DIR.glob("*.parquet"))
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def read():
|
| 29 |
+
"""day, repo_id, downloads_30d, downloads_all_time over every revision kept."""
|
| 30 |
+
fs = files()
|
| 31 |
+
if not fs:
|
| 32 |
+
return None
|
| 33 |
+
return pd.concat([pd.read_parquet(f).assign(day=f.stem) for f in fs], ignore_index=True)
|
| 34 |
|
| 35 |
|
| 36 |
def revisions(every=7, since="2025-01-01"):
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
def backfill(ids, every=7, since="2025-01-01", log=print):
|
| 55 |
+
"""Writes the missing revisions; returns the paths written."""
|
| 56 |
import duckdb
|
| 57 |
|
| 58 |
+
DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 59 |
con = duckdb.connect()
|
| 60 |
con.sql("SET http_timeout=120; SET http_retries=8; SET http_retry_wait_ms=2000")
|
| 61 |
con.register("ours", pd.DataFrame({"id": sorted(ids)}))
|
| 62 |
revs = revisions(every, since)
|
| 63 |
log(f"hub-stats: {len(ids)} repos, {len(revs)} revisions")
|
| 64 |
+
t0, written = time.time(), []
|
| 65 |
for day, sha in revs:
|
| 66 |
+
out = DIR / f"{day}.parquet"
|
| 67 |
if out.exists():
|
| 68 |
continue
|
| 69 |
url = URL.format(sha=sha)
|
|
|
|
| 71 |
try:
|
| 72 |
cols = {r[0] for r in con.sql(f"SELECT name FROM parquet_schema('{url}')").fetchall()}
|
| 73 |
dla = "downloadsAllTime" if "downloadsAllTime" in cols else "NULL::BIGINT"
|
| 74 |
+
df = con.sql(f"""SELECT id AS repo_id, downloads AS downloads_30d, {dla} AS downloads_all_time
|
| 75 |
FROM read_parquet('{url}') WHERE id IN (SELECT id FROM ours)""").df()
|
| 76 |
+
if len(df):
|
| 77 |
+
df.to_parquet(out, index=False)
|
| 78 |
+
written.append(out)
|
| 79 |
break
|
| 80 |
except Exception as e: # network: retry the revision, then leave it out
|
| 81 |
log(f"hub-stats {day} attempt {attempt + 1}: {type(e).__name__}: {str(e)[:120]}")
|
| 82 |
time.sleep(10 * (attempt + 1))
|
| 83 |
+
log(f"hub-stats: {len(written)} revisions written in {time.time() - t0:.0f}s")
|
| 84 |
+
return written
|
|
|
|
|
|
|
|
|
code/hfeco/org.py
CHANGED
|
@@ -16,7 +16,7 @@ from concurrent.futures import ThreadPoolExecutor
|
|
| 16 |
|
| 17 |
import pandas as pd
|
| 18 |
|
| 19 |
-
from . import classify, metrics, store
|
| 20 |
from .hub import api, retry
|
| 21 |
|
| 22 |
ORG = "MiniMaxAI"
|
|
@@ -197,12 +197,12 @@ def history_ids(pub):
|
|
| 197 |
|
| 198 |
def download_points(deep_fams):
|
| 199 |
"""Every followed repo's all-time (dla) and 30-day (d30) downloads, about a week apart: the
|
| 200 |
-
cfahlgren1/hub-stats history (raw/hubstats
|
| 201 |
snapshots a week apart. None until the history exists."""
|
| 202 |
-
|
| 203 |
-
if
|
| 204 |
return None
|
| 205 |
-
hs =
|
| 206 |
own = [read_snapshots()]
|
| 207 |
for fam in deep_fams:
|
| 208 |
raw = store.read_raw(fam)
|
|
@@ -274,7 +274,8 @@ def download_rates(groups, P):
|
|
| 274 |
|
| 275 |
|
| 276 |
def build(rels, found, deep_data, who):
|
| 277 |
-
"""(site, {category: page data}). `deep_data` maps a
|
|
|
|
| 278 |
snaps = read_snapshots()
|
| 279 |
days = sorted(snaps.day.unique())
|
| 280 |
today = days[-1]
|
|
@@ -349,16 +350,16 @@ def build(rels, found, deep_data, who):
|
|
| 349 |
now_total[r["cat"]] += (lineages[k]["official"]["dlall"] or 0) + lineages[k]["dlall"]
|
| 350 |
first = min(cat_start.values())
|
| 351 |
cum = {c: cumulative(P, cat_ids[c]) for c in cat_ids}
|
| 352 |
-
|
| 353 |
totals = {}
|
| 354 |
for c, v in cum.items():
|
| 355 |
run, vals = 0.0, []
|
| 356 |
-
for d in
|
| 357 |
if d >= cat_start[c] and d in v:
|
| 358 |
run = max(run, v[d])
|
| 359 |
vals.append(int(round(run)))
|
| 360 |
totals[c] = vals + [int(max(run, now_total[c]))]
|
| 361 |
-
dl_total = {"days":
|
| 362 |
|
| 363 |
by_cat = defaultdict(list)
|
| 364 |
for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"], reverse=True):
|
|
@@ -415,7 +416,7 @@ def build(rels, found, deep_data, who):
|
|
| 415 |
"repos": page_repos,
|
| 416 |
"authors": {n: author_entry(n) for n in sorted(names)},
|
| 417 |
}
|
| 418 |
-
return site, pages
|
| 419 |
|
| 420 |
|
| 421 |
def check_owned_public(objs):
|
|
|
|
| 16 |
|
| 17 |
import pandas as pd
|
| 18 |
|
| 19 |
+
from . import classify, hubstats, metrics, store
|
| 20 |
from .hub import api, retry
|
| 21 |
|
| 22 |
ORG = "MiniMaxAI"
|
|
|
|
| 197 |
|
| 198 |
def download_points(deep_fams):
|
| 199 |
"""Every followed repo's all-time (dla) and 30-day (d30) downloads, about a week apart: the
|
| 200 |
+
cfahlgren1/hub-stats history (raw/hubstats/, see hfeco/hubstats.py), then our own
|
| 201 |
snapshots a week apart. None until the history exists."""
|
| 202 |
+
hs = hubstats.read()
|
| 203 |
+
if hs is None:
|
| 204 |
return None
|
| 205 |
+
hs = hs.rename(columns={"downloads_30d": "d30", "downloads_all_time": "dla"})
|
| 206 |
own = [read_snapshots()]
|
| 207 |
for fam in deep_fams:
|
| 208 |
raw = store.read_raw(fam)
|
|
|
|
| 274 |
|
| 275 |
|
| 276 |
def build(rels, found, deep_data, who):
|
| 277 |
+
"""(site, {category: page data}, {release: shown community repos}). `deep_data` maps a
|
| 278 |
+
family key to its dashboard dict."""
|
| 279 |
snaps = read_snapshots()
|
| 280 |
days = sorted(snaps.day.unique())
|
| 281 |
today = days[-1]
|
|
|
|
| 350 |
now_total[r["cat"]] += (lineages[k]["official"]["dlall"] or 0) + lineages[k]["dlall"]
|
| 351 |
first = min(cat_start.values())
|
| 352 |
cum = {c: cumulative(P, cat_ids[c]) for c in cat_ids}
|
| 353 |
+
steps = sorted({d for v in cum.values() for d in v if first < d < today})
|
| 354 |
totals = {}
|
| 355 |
for c, v in cum.items():
|
| 356 |
run, vals = 0.0, []
|
| 357 |
+
for d in steps:
|
| 358 |
if d >= cat_start[c] and d in v:
|
| 359 |
run = max(run, v[d])
|
| 360 |
vals.append(int(round(run)))
|
| 361 |
totals[c] = vals + [int(max(run, now_total[c]))]
|
| 362 |
+
dl_total = {"days": steps + [today], "cats": totals}
|
| 363 |
|
| 364 |
by_cat = defaultdict(list)
|
| 365 |
for key, r in sorted(rels.items(), key=lambda kv: kv[1]["date"], reverse=True):
|
|
|
|
| 416 |
"repos": page_repos,
|
| 417 |
"authors": {n: author_entry(n) for n in sorted(names)},
|
| 418 |
}
|
| 419 |
+
return site, pages, dict(repos)
|
| 420 |
|
| 421 |
|
| 422 |
def check_owned_public(objs):
|
code/scripts/backfill_hubstats.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
"""
|
| 2 |
|
| 3 |
python scripts/backfill_hubstats.py [--every 7] [--since 2025-01-01] [--push]
|
| 4 |
|
| 5 |
-
The daily job does this by itself when the
|
| 6 |
-
hfeco/hubstats.py); this is for
|
| 7 |
"""
|
| 8 |
import argparse
|
| 9 |
import sys
|
|
@@ -18,11 +18,11 @@ def main():
|
|
| 18 |
ap = argparse.ArgumentParser()
|
| 19 |
ap.add_argument("--every", type=int, default=7)
|
| 20 |
ap.add_argument("--since", default="2025-01-01")
|
| 21 |
-
ap.add_argument("--push", action="store_true", help="upload
|
| 22 |
a = ap.parse_args()
|
| 23 |
-
|
| 24 |
-
if a.push:
|
| 25 |
-
store.push(
|
| 26 |
print("pushed")
|
| 27 |
|
| 28 |
|
|
|
|
| 1 |
+
"""Fill raw/hubstats/ (past downloads from cfahlgren1/hub-stats) by hand.
|
| 2 |
|
| 3 |
python scripts/backfill_hubstats.py [--every 7] [--since 2025-01-01] [--push]
|
| 4 |
|
| 5 |
+
The daily job does this by itself when the folder is empty in the dataset (see
|
| 6 |
+
hfeco/hubstats.py); this is for refilling it by hand, e.g. with a different step.
|
| 7 |
"""
|
| 8 |
import argparse
|
| 9 |
import sys
|
|
|
|
| 18 |
ap = argparse.ArgumentParser()
|
| 19 |
ap.add_argument("--every", type=int, default=7)
|
| 20 |
ap.add_argument("--since", default="2025-01-01")
|
| 21 |
+
ap.add_argument("--push", action="store_true", help="upload what was written to the dataset")
|
| 22 |
a = ap.parse_args()
|
| 23 |
+
paths = hubstats.backfill(org.history_ids(org.public_models()), a.every, a.since)
|
| 24 |
+
if a.push and paths:
|
| 25 |
+
store.push(paths, "hub-stats downloads history")
|
| 26 |
print("pushed")
|
| 27 |
|
| 28 |
|
code/scripts/daily.py
CHANGED
|
@@ -19,7 +19,7 @@ import pandas as pd
|
|
| 19 |
|
| 20 |
ROOT = Path(__file__).resolve().parent.parent
|
| 21 |
sys.path.insert(0, str(ROOT))
|
| 22 |
-
from hfeco import authors, classify, discover, families, hubstats, metrics, org, pipeline, store # noqa: E402
|
| 23 |
from hfeco.hub import api # noqa: E402
|
| 24 |
|
| 25 |
SPACE_REPO = "MiniMaxAI/ecosystem"
|
|
@@ -84,15 +84,15 @@ found = org.crawl(roots, skip=in_families, log=log)
|
|
| 84 |
snap_path = org.snapshot(rels, found)
|
| 85 |
if args.push:
|
| 86 |
store.push([snap_path], f"org: snapshot {snap_path.stem}")
|
| 87 |
-
if not hubstats.
|
| 88 |
try:
|
| 89 |
-
hubstats.backfill(org.history_ids(pub), log=log)
|
| 90 |
-
if args.push:
|
| 91 |
-
store.push(
|
| 92 |
except Exception as e:
|
| 93 |
log(f"hub-stats history skipped: {type(e).__name__}: {e}")
|
| 94 |
who, who_path = authors.update({i.split("/")[0] for i in found} | {org.ORG}, log=log)
|
| 95 |
-
site, pages = org.build(rels, found, deep, who)
|
| 96 |
public_ids = {m.id for m in pub}
|
| 97 |
out = [("site", site)] + list(pages.items())
|
| 98 |
paths = []
|
|
@@ -110,3 +110,8 @@ if args.push:
|
|
| 110 |
for p in paths],
|
| 111 |
commit_message=f"data {site['today']}", repo_type="space")
|
| 112 |
log("pushed")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
ROOT = Path(__file__).resolve().parent.parent
|
| 21 |
sys.path.insert(0, str(ROOT))
|
| 22 |
+
from hfeco import authors, classify, discover, export, families, hubstats, metrics, org, pipeline, store # noqa: E402
|
| 23 |
from hfeco.hub import api # noqa: E402
|
| 24 |
|
| 25 |
SPACE_REPO = "MiniMaxAI/ecosystem"
|
|
|
|
| 84 |
snap_path = org.snapshot(rels, found)
|
| 85 |
if args.push:
|
| 86 |
store.push([snap_path], f"org: snapshot {snap_path.stem}")
|
| 87 |
+
if not hubstats.files(): # once: past downloads for the history charts; never blocks the day
|
| 88 |
try:
|
| 89 |
+
written = hubstats.backfill(org.history_ids(pub), log=log)
|
| 90 |
+
if args.push and written:
|
| 91 |
+
store.push(written, "hub-stats downloads history")
|
| 92 |
except Exception as e:
|
| 93 |
log(f"hub-stats history skipped: {type(e).__name__}: {e}")
|
| 94 |
who, who_path = authors.update({i.split("/")[0] for i in found} | {org.ORG}, log=log)
|
| 95 |
+
site, pages, shown = org.build(rels, found, deep, who)
|
| 96 |
public_ids = {m.id for m in pub}
|
| 97 |
out = [("site", site)] + list(pages.items())
|
| 98 |
paths = []
|
|
|
|
| 110 |
for p in paths],
|
| 111 |
commit_message=f"data {site['today']}", repo_type="space")
|
| 112 |
log("pushed")
|
| 113 |
+
# the dataset's tables/, site/ and card, for people; never blocks the day
|
| 114 |
+
try:
|
| 115 |
+
export.publish(site, shown, public_ids, paths, push=args.push, log=log)
|
| 116 |
+
except Exception as e:
|
| 117 |
+
log(f"export skipped: {type(e).__name__}: {e}")
|
code/scripts/push_code.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
-
"""Upload the
|
| 2 |
|
| 3 |
python scripts/push_code.py
|
| 4 |
|
| 5 |
-
Uploads every git-tracked file
|
|
|
|
| 6 |
"""
|
| 7 |
import subprocess
|
| 8 |
import sys
|
|
@@ -16,7 +17,7 @@ from hfeco.hub import api # noqa: E402
|
|
| 16 |
from hfeco.store import DATASET_REPO # noqa: E402
|
| 17 |
|
| 18 |
files = subprocess.run(["git", "ls-files"], cwd=ROOT, capture_output=True, text=True, check=True).stdout.split()
|
| 19 |
-
files = [f for f in files if not f.startswith(
|
| 20 |
remote = {f[len("code/"):] for f in api.list_repo_files(DATASET_REPO, repo_type="dataset") if f.startswith("code/")}
|
| 21 |
ops = [CommitOperationAdd(path_in_repo=f"code/{f}", path_or_fileobj=str(ROOT / f)) for f in files]
|
| 22 |
ops += [CommitOperationDelete(path_in_repo=f"code/{f}") for f in sorted(remote - set(files))]
|
|
|
|
| 1 |
+
"""Upload the source to the dataset repo's code/ folder (the daily HF Job runs from there).
|
| 2 |
|
| 3 |
python scripts/push_code.py
|
| 4 |
|
| 5 |
+
Uploads every git-tracked file except eval/ (the hand-labelled holdout): the pipeline, the
|
| 6 |
+
page's source in web/ and the Space card, so a new module can't be forgotten.
|
| 7 |
"""
|
| 8 |
import subprocess
|
| 9 |
import sys
|
|
|
|
| 17 |
from hfeco.store import DATASET_REPO # noqa: E402
|
| 18 |
|
| 19 |
files = subprocess.run(["git", "ls-files"], cwd=ROOT, capture_output=True, text=True, check=True).stdout.split()
|
| 20 |
+
files = [f for f in files if not f.startswith("eval/")]
|
| 21 |
remote = {f[len("code/"):] for f in api.list_repo_files(DATASET_REPO, repo_type="dataset") if f.startswith("code/")}
|
| 22 |
ops = [CommitOperationAdd(path_in_repo=f"code/{f}", path_or_fileobj=str(ROOT / f)) for f in files]
|
| 23 |
ops += [CommitOperationDelete(path_in_repo=f"code/{f}") for f in sorted(remote - set(files))]
|
code/space/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: MiniMax Ecosystem
|
| 3 |
+
emoji: 📈
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: static
|
| 7 |
+
pinned: false
|
| 8 |
+
short_description: Community models built on MiniMax open models
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# MiniMax Ecosystem
|
| 12 |
+
|
| 13 |
+
The community built on MiniMax's open models on Hugging Face: fine-tunes, adapters,
|
| 14 |
+
quantizations and merges of every release, with their downloads. Updated daily.
|
code/web/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Logs
|
| 2 |
+
logs
|
| 3 |
+
*.log
|
| 4 |
+
npm-debug.log*
|
| 5 |
+
yarn-debug.log*
|
| 6 |
+
yarn-error.log*
|
| 7 |
+
pnpm-debug.log*
|
| 8 |
+
lerna-debug.log*
|
| 9 |
+
|
| 10 |
+
node_modules
|
| 11 |
+
dist
|
| 12 |
+
dist-ssr
|
| 13 |
+
*.local
|
| 14 |
+
|
| 15 |
+
# Editor directories and files
|
| 16 |
+
.vscode/*
|
| 17 |
+
!.vscode/extensions.json
|
| 18 |
+
.idea
|
| 19 |
+
.DS_Store
|
| 20 |
+
*.suo
|
| 21 |
+
*.ntvs*
|
| 22 |
+
*.njsproj
|
| 23 |
+
*.sln
|
| 24 |
+
*.sw?
|
code/web/.oxlintrc.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
| 3 |
+
"plugins": ["react", "typescript", "oxc"],
|
| 4 |
+
"rules": {
|
| 5 |
+
"react/rules-of-hooks": "error",
|
| 6 |
+
"react/only-export-components": ["warn", { "allowConstantExport": true }]
|
| 7 |
+
}
|
| 8 |
+
}
|
code/web/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# React + TypeScript + Vite
|
| 2 |
+
|
| 3 |
+
This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.
|
| 4 |
+
|
| 5 |
+
Currently, two official plugins are available:
|
| 6 |
+
|
| 7 |
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
| 8 |
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
| 9 |
+
|
| 10 |
+
## React Compiler
|
| 11 |
+
|
| 12 |
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
| 13 |
+
|
| 14 |
+
## Expanding the Oxlint configuration
|
| 15 |
+
|
| 16 |
+
If you are developing a production application, we recommend enabling type-aware lint rules by installing `oxlint-tsgolint` and editing `.oxlintrc.json`:
|
| 17 |
+
|
| 18 |
+
```json
|
| 19 |
+
{
|
| 20 |
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
| 21 |
+
"plugins": ["react", "typescript", "oxc"],
|
| 22 |
+
"options": {
|
| 23 |
+
"typeAware": true
|
| 24 |
+
},
|
| 25 |
+
"rules": {
|
| 26 |
+
"react/rules-of-hooks": "error",
|
| 27 |
+
"react/only-export-components": ["warn", { "allowConstantExport": true }]
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
See the [Oxlint rules documentation](https://oxc.rs/docs/guide/usage/linter/rules) for the full list of rules and categories.
|
code/web/components.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "radix-nova",
|
| 4 |
+
"rsc": false,
|
| 5 |
+
"tsx": true,
|
| 6 |
+
"tailwind": {
|
| 7 |
+
"config": "",
|
| 8 |
+
"css": "src/index.css",
|
| 9 |
+
"baseColor": "neutral",
|
| 10 |
+
"cssVariables": true,
|
| 11 |
+
"prefix": ""
|
| 12 |
+
},
|
| 13 |
+
"iconLibrary": "lucide",
|
| 14 |
+
"rtl": false,
|
| 15 |
+
"aliases": {
|
| 16 |
+
"components": "@/components",
|
| 17 |
+
"utils": "@/lib/utils",
|
| 18 |
+
"ui": "@/components/ui",
|
| 19 |
+
"lib": "@/lib",
|
| 20 |
+
"hooks": "@/hooks"
|
| 21 |
+
},
|
| 22 |
+
"menuColor": "default",
|
| 23 |
+
"menuAccent": "subtle",
|
| 24 |
+
"registries": {}
|
| 25 |
+
}
|
code/web/index.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
| 6 |
+
<title>MiniMax Ecosystem</title>
|
| 7 |
+
<meta name="description" content="Community models built on MiniMax open models, updated daily." />
|
| 8 |
+
<meta name="theme-color" content="#0b0b10" />
|
| 9 |
+
<link rel="icon" href="data:," />
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<div id="root"></div>
|
| 13 |
+
<script type="module" src="/src/main.tsx"></script>
|
| 14 |
+
</body>
|
| 15 |
+
</html>
|
code/web/package-lock.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
code/web/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "web",
|
| 3 |
+
"private": true,
|
| 4 |
+
"version": "0.0.0",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"dev": "vite",
|
| 8 |
+
"build": "tsc -b && vite build",
|
| 9 |
+
"lint": "oxlint",
|
| 10 |
+
"preview": "vite preview"
|
| 11 |
+
},
|
| 12 |
+
"dependencies": {
|
| 13 |
+
"@fontsource-variable/dm-sans": "^5.2.8",
|
| 14 |
+
"@fontsource-variable/outfit": "^5.3.0",
|
| 15 |
+
"@tailwindcss/vite": "^4.3.5",
|
| 16 |
+
"class-variance-authority": "^0.7.1",
|
| 17 |
+
"cn": "^0.5.2",
|
| 18 |
+
"d3-delaunay": "^6.0.6",
|
| 19 |
+
"d3-force": "^3.0.1",
|
| 20 |
+
"d3-scale": "^4.0.3",
|
| 21 |
+
"d3-shape": "^3.2.0",
|
| 22 |
+
"html-to-image": "1.11.13",
|
| 23 |
+
"lucide-react": "^1.74.0",
|
| 24 |
+
"radix-ui": "^1.8.1",
|
| 25 |
+
"react": "^19.3.1",
|
| 26 |
+
"react-dom": "^19.3.1",
|
| 27 |
+
"recharts": "^3.8.0",
|
| 28 |
+
"shadcn": "^4.23.0",
|
| 29 |
+
"tailwindcss": "^4.3.5",
|
| 30 |
+
"tw-animate-css": "^1.4.0"
|
| 31 |
+
},
|
| 32 |
+
"devDependencies": {
|
| 33 |
+
"@types/d3-delaunay": "^6.0.4",
|
| 34 |
+
"@types/d3-force": "^3.0.10",
|
| 35 |
+
"@types/d3-scale": "^4.0.9",
|
| 36 |
+
"@types/d3-shape": "^3.1.7",
|
| 37 |
+
"@types/node": "^24.19.2",
|
| 38 |
+
"@types/react": "^19.3.0",
|
| 39 |
+
"@types/react-dom": "^19.3.0",
|
| 40 |
+
"@vitejs/plugin-react": "^6.1.2",
|
| 41 |
+
"oxlint": "^1.90.0",
|
| 42 |
+
"typescript": "~7.0.2",
|
| 43 |
+
"vite": "^8.3.6"
|
| 44 |
+
}
|
| 45 |
+
}
|
code/web/src/App.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useState } from "react"
|
| 2 |
+
import type { Site } from "@/lib/types"
|
| 3 |
+
import { useRoute } from "@/lib/route"
|
| 4 |
+
import { Home } from "@/pages/home"
|
| 5 |
+
import { CategoryPage } from "@/pages/category"
|
| 6 |
+
|
| 7 |
+
export default function App() {
|
| 8 |
+
const [site, setSite] = useState<Site | null>(null)
|
| 9 |
+
const [failed, setFailed] = useState(false)
|
| 10 |
+
const route = useRoute()
|
| 11 |
+
|
| 12 |
+
useEffect(() => {
|
| 13 |
+
fetch("data/site.json")
|
| 14 |
+
.then((r) => (r.ok ? r.json() : Promise.reject(r.status)))
|
| 15 |
+
.then(setSite)
|
| 16 |
+
.catch(() => setFailed(true))
|
| 17 |
+
}, [])
|
| 18 |
+
useEffect(() => {
|
| 19 |
+
if (!route.cat) document.title = "MiniMax Ecosystem"
|
| 20 |
+
}, [route.cat])
|
| 21 |
+
|
| 22 |
+
if (failed) return <p className="p-10 text-lg">The data did not load. Try refreshing the page.</p>
|
| 23 |
+
if (!site) return <div className="dark stage min-h-screen" />
|
| 24 |
+
return route.cat
|
| 25 |
+
? <CategoryPage key={route.cat} site={site} cat={route.cat} rel={route.rel} />
|
| 26 |
+
: <Home site={site} />
|
| 27 |
+
}
|
code/web/src/components/category-blocks.tsx
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ArrowUpRight } from "lucide-react"
|
| 2 |
+
import type { Site } from "@/lib/types"
|
| 3 |
+
import { catFrom, catTo } from "@/lib/category"
|
| 4 |
+
import { DAY, full, isoDay, num, toTime } from "@/lib/format"
|
| 5 |
+
import { href } from "@/lib/route"
|
| 6 |
+
import { Spark } from "@/components/sparkline"
|
| 7 |
+
|
| 8 |
+
/** One block per modality: how big its community is, which releases it holds, who builds on it. */
|
| 9 |
+
export function CategoryBlocks({ site }: { site: Site }) {
|
| 10 |
+
return (
|
| 11 |
+
<div className="grid gap-5 lg:grid-cols-2">
|
| 12 |
+
{site.categories.map((c, i) => <Block key={c.key} site={site} cat={c.key} wide={i < 2 || site.categories.length % 2 === 1 && i === site.categories.length - 1} i={i} />)}
|
| 13 |
+
</div>
|
| 14 |
+
)
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function Block({ site, cat, wide, i }: { site: Site; cat: string; wide: boolean; i: number }) {
|
| 18 |
+
const c = site.categories.find((x) => x.key === cat)!
|
| 19 |
+
const rels = c.releases.map((k) => site.releases.find((r) => r.key === k)!)
|
| 20 |
+
const n = rels.reduce((a, r) => a + r.n, 0)
|
| 21 |
+
const dl = rels.reduce((a, r) => a + r.dlall, 0)
|
| 22 |
+
const off = rels.reduce((a, r) => a + (r.official.dlall ?? 0), 0)
|
| 23 |
+
const events = rels.flatMap((r) => r.growth)
|
| 24 |
+
// The curve starts a week before the first community model, so a modality whose community
|
| 25 |
+
// is new still gets a readable curve rather than a flat line and a cliff.
|
| 26 |
+
const firstEvent = events.reduce((a, [d]) => (d < a ? d : a), "9999")
|
| 27 |
+
const first = firstEvent < "9999" ? isoDay(toTime(firstEvent) - 7 * DAY) : rels.reduce((a, r) => (r.date < a ? r.date : a), rels[0].date)
|
| 28 |
+
const repoCount = rels.reduce((a, r) => a + r.models.length, 0)
|
| 29 |
+
|
| 30 |
+
const stats: [string, string][] = [
|
| 31 |
+
[num(dl), "community downloads"],
|
| 32 |
+
[full(c.builders), "builders"],
|
| 33 |
+
[num(off), "MiniMax downloads"],
|
| 34 |
+
[full(repoCount), repoCount === 1 ? "open model" : "open models"],
|
| 35 |
+
]
|
| 36 |
+
|
| 37 |
+
return (
|
| 38 |
+
<a href={href(cat)}
|
| 39 |
+
className={`group relative isolate flex flex-col overflow-hidden rounded-[28px] border border-border bg-card transition-[border-color,transform,box-shadow] duration-200 ease-[cubic-bezier(.22,.61,.36,1)] hover:-translate-y-1 hover:border-[color-mix(in_oklab,var(--border),var(--foreground)_25%)] hover:shadow-[0_24px_60px_-28px_rgba(0,0,0,0.35)] ${wide ? "lg:col-span-2" : ""}`}
|
| 40 |
+
style={{ animation: `rise 700ms cubic-bezier(.22,.61,.36,1) ${i * 80}ms both` }}>
|
| 41 |
+
<div aria-hidden className="absolute -top-40 -right-24 -z-10 size-[420px] rounded-full opacity-[0.16] blur-[90px] transition-opacity duration-300 group-hover:opacity-30"
|
| 42 |
+
style={{ background: `linear-gradient(135deg, ${catFrom(cat)}, ${catTo(cat)})` }} />
|
| 43 |
+
<div className="flex-1 p-7 sm:p-10">
|
| 44 |
+
<div className="flex items-start justify-between gap-4">
|
| 45 |
+
<h2 className="inline-flex items-center gap-3 font-display text-[30px] leading-none font-semibold tracking-[-0.01em] sm:text-[36px]">
|
| 46 |
+
<span className="size-3.5 rounded-full" style={{ background: `linear-gradient(135deg, ${catFrom(cat)}, ${catTo(cat)})` }} />
|
| 47 |
+
{c.name}
|
| 48 |
+
</h2>
|
| 49 |
+
<span className="grid size-11 shrink-0 place-items-center rounded-full border border-border transition-[background-color,color,transform] duration-200 group-hover:rotate-45 group-hover:bg-foreground group-hover:text-background">
|
| 50 |
+
<ArrowUpRight className="size-5" />
|
| 51 |
+
</span>
|
| 52 |
+
</div>
|
| 53 |
+
|
| 54 |
+
<div className={`mt-8 ${wide ? "lg:flex lg:items-end lg:justify-between lg:gap-10" : ""}`}>
|
| 55 |
+
<div>
|
| 56 |
+
<div className="font-display text-[72px] leading-[0.9] font-semibold tracking-[-0.04em] tabular-nums sm:text-[96px]">{full(n)}</div>
|
| 57 |
+
<div className="mt-3 text-lg text-muted-foreground">community models</div>
|
| 58 |
+
</div>
|
| 59 |
+
<dl className={`mt-8 grid grid-cols-2 gap-x-8 gap-y-6 ${wide ? "sm:grid-cols-4 lg:mt-0" : ""}`}>
|
| 60 |
+
{stats.map(([v, l]) => (
|
| 61 |
+
<div key={l}>
|
| 62 |
+
<dt className="sr-only">{l}</dt>
|
| 63 |
+
<dd className="font-display text-[28px] leading-none font-semibold tabular-nums">{v}</dd>
|
| 64 |
+
<dd className="mt-2 text-[15px] text-muted-foreground">{l}</dd>
|
| 65 |
+
</div>
|
| 66 |
+
))}
|
| 67 |
+
</dl>
|
| 68 |
+
</div>
|
| 69 |
+
|
| 70 |
+
<div className="mt-8 flex flex-wrap items-center gap-2">
|
| 71 |
+
{rels.map((r) => (
|
| 72 |
+
<span key={r.key} className="inline-flex h-9 items-center gap-2 rounded-full bg-muted px-3.5 text-[15px]">
|
| 73 |
+
<span className="font-medium">{r.name}</span>
|
| 74 |
+
{r.n > 0 && <span className="font-display text-muted-foreground tabular-nums">{full(r.n)}</span>}
|
| 75 |
+
</span>
|
| 76 |
+
))}
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
{c.top_authors.length > 0 && (
|
| 80 |
+
<div className="mt-7 flex items-center gap-3">
|
| 81 |
+
<div className="flex -space-x-2.5">
|
| 82 |
+
{c.top_authors.map((a) => (
|
| 83 |
+
<span key={a.id} title={a.n} className="grid size-9 place-items-center overflow-hidden rounded-full bg-muted text-sm font-medium ring-[3px] ring-card">
|
| 84 |
+
{a.a ? <img src={a.a} alt="" loading="lazy" className="size-full object-cover" /> : a.id.slice(0, 1).toUpperCase()}
|
| 85 |
+
</span>
|
| 86 |
+
))}
|
| 87 |
+
</div>
|
| 88 |
+
{c.builders > c.top_authors.length && (
|
| 89 |
+
<span className="text-[15px] text-muted-foreground">+{full(c.builders - c.top_authors.length)} more builders</span>
|
| 90 |
+
)}
|
| 91 |
+
</div>
|
| 92 |
+
)}
|
| 93 |
+
</div>
|
| 94 |
+
<Spark events={events} from={first} to={site.today} cat={cat} height={wide ? 120 : 100}
|
| 95 |
+
dots={rels.map((r) => r.date)} />
|
| 96 |
+
</a>
|
| 97 |
+
)
|
| 98 |
+
}
|
code/web/src/components/community-chart.tsx
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useMemo, useRef, useState } from "react"
|
| 2 |
+
import { area, curveMonotoneX, line, stack } from "d3-shape"
|
| 3 |
+
import { scaleLinear } from "d3-scale"
|
| 4 |
+
import type { Release, Site } from "@/lib/types"
|
| 5 |
+
import { CAT_ORDER, catColor, shortName } from "@/lib/category"
|
| 6 |
+
import { DAY, full, md, mdy, num, toTime } from "@/lib/format"
|
| 7 |
+
|
| 8 |
+
type Row = { t: number } & Record<string, number>
|
| 9 |
+
export type Series = { rows: Row[]; cats: string[]; start: number; end: number }
|
| 10 |
+
export type Metric = "models" | "downloads"
|
| 11 |
+
/** A milestone: releases within three weeks share one pole. Names sit right of the pole, or
|
| 12 |
+
* left of it (`side`) when the right is taken; with no room either side only the pole shows. */
|
| 13 |
+
type Pin = { t: number; key: string; rels: Release[]; cat: string; side: "right" | "left" | "none" }
|
| 14 |
+
const NAME_FONT = '500 15px "Outfit Variable", system-ui, sans-serif'
|
| 15 |
+
let measurer: CanvasRenderingContext2D | null = null
|
| 16 |
+
const textWidth = (s: string) => {
|
| 17 |
+
measurer ??= document.createElement("canvas").getContext("2d")!
|
| 18 |
+
measurer.font = NAME_FONT
|
| 19 |
+
return measurer.measureText(s).width
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
const REVEAL = 2000 // ms for the curve to sweep in
|
| 23 |
+
|
| 24 |
+
/** A shared pin opens the release that has its own page, if one does. */
|
| 25 |
+
const pick = (rs: Release[]) => rs.find((r) => r.page) ?? rs[0]
|
| 26 |
+
const LINE_H = 24 // one release name in the milestone row
|
| 27 |
+
const ROW_TOP = 14 // centre of the first name, where every pole starts
|
| 28 |
+
|
| 29 |
+
/** Cumulative community models per modality, one point a week from our first release to today. */
|
| 30 |
+
export function useSeries(site: Site): Series {
|
| 31 |
+
return useMemo(() => {
|
| 32 |
+
const first = Math.min(...site.releases.map((r) => toTime(r.date)))
|
| 33 |
+
const d = new Date(first - 20 * DAY)
|
| 34 |
+
const start = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1)
|
| 35 |
+
const end = toTime(site.today)
|
| 36 |
+
const ts: number[] = []
|
| 37 |
+
for (let t = start; t < end; t += 7 * DAY) ts.push(t)
|
| 38 |
+
ts.push(end)
|
| 39 |
+
const cats = CAT_ORDER.filter((c) => site.categories.some((x) => x.key === c))
|
| 40 |
+
const rows: Row[] = ts.map((t) => ({ t }) as Row)
|
| 41 |
+
for (const c of cats) {
|
| 42 |
+
const ev = site.releases.filter((r) => r.cat === c).flatMap((r) => r.growth.map(([s, n]) => [toTime(s), n] as const))
|
| 43 |
+
.sort((a, b) => a[0] - b[0])
|
| 44 |
+
let i = 0, run = 0
|
| 45 |
+
for (const row of rows) {
|
| 46 |
+
while (i < ev.length && ev[i][0] <= row.t) run += ev[i++][1]
|
| 47 |
+
row[c] = run
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
return { rows, cats, start, end }
|
| 51 |
+
}, [site])
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/** All-time downloads by modality, of MiniMax models and everything built on them, about
|
| 55 |
+
* weekly, on the same time axis as the models. */
|
| 56 |
+
export function useDownloadSeries(site: Site, base: Series): Series | null {
|
| 57 |
+
return useMemo(() => {
|
| 58 |
+
const d = site.dl_total
|
| 59 |
+
if (!d?.days.length) return null
|
| 60 |
+
const rows = d.days.map((day, i) => ({ t: toTime(day), ...Object.fromEntries(base.cats.map((c) => [c, d.cats[c]?.[i] ?? 0])) }) as Row)
|
| 61 |
+
rows.unshift({ t: base.start, ...Object.fromEntries(base.cats.map((c) => [c, 0])) } as Row)
|
| 62 |
+
return { rows, cats: base.cats, start: base.start, end: base.end }
|
| 63 |
+
}, [site, base])
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/** The box sets the size (its height comes from the page, so the hero can fit the first screen). */
|
| 67 |
+
export function CommunityChart({ site, series, metric, hidden, onPick, className }: {
|
| 68 |
+
site: Site; series: Series; metric: Metric; hidden: Set<string>; onPick: (r: Release) => void; className: string
|
| 69 |
+
}) {
|
| 70 |
+
const box = useRef<HTMLDivElement>(null)
|
| 71 |
+
const [[W, H], setSize] = useState([0, 0])
|
| 72 |
+
const [hover, setHover] = useState<number | null>(null)
|
| 73 |
+
const pointer = useRef("mouse") // a tap previews; only a mouse click on the plot opens a release
|
| 74 |
+
useEffect(() => {
|
| 75 |
+
const el = box.current
|
| 76 |
+
if (!el) return
|
| 77 |
+
const ro = new ResizeObserver(() => setSize([el.clientWidth, el.clientHeight]))
|
| 78 |
+
ro.observe(el)
|
| 79 |
+
return () => ro.disconnect()
|
| 80 |
+
}, [])
|
| 81 |
+
|
| 82 |
+
const { rows, cats, start, end } = series
|
| 83 |
+
const last = rows.at(-1)!.t
|
| 84 |
+
const value = metric === "models" ? (v: number) => full(Math.round(v)) : (v: number) => num(v)
|
| 85 |
+
const tick = (v: number) => (v >= 1e6 ? num(v) : v >= 1000 ? `${v / 1000}K` : String(v))
|
| 86 |
+
const keys = cats.filter((c) => !hidden.has(c))
|
| 87 |
+
const narrow = W < 640
|
| 88 |
+
// Phones get the dots on the curve only; the release cards below carry the names.
|
| 89 |
+
const m = { l: 4, r: narrow ? 44 : 60, t: narrow ? 24 : ROW_TOP + LINE_H + 40, b: 40 }
|
| 90 |
+
|
| 91 |
+
const g = useMemo(() => {
|
| 92 |
+
if (!W || !H) return null
|
| 93 |
+
const x = scaleLinear().domain([start, end]).range([m.l, W - m.r])
|
| 94 |
+
const stacked = stack<Row>().keys(keys)(rows)
|
| 95 |
+
const top = rows.map((_, i) => (stacked.length ? stacked[stacked.length - 1][i][1] : 0))
|
| 96 |
+
const y = scaleLinear().domain([0, Math.max(10, ...top)]).nice(5).range([H - m.b, m.t])
|
| 97 |
+
const areaGen = area<[number, number] & { data: Row }>().x((d) => x(d.data.t)).y0((d) => y(d[0])).y1((d) => y(d[1]))
|
| 98 |
+
.curve(curveMonotoneX)
|
| 99 |
+
const edge = line<[number, number] & { data: Row }>().x((d) => x(d.data.t)).y((d) => y(d[1])).curve(curveMonotoneX)
|
| 100 |
+
const topLine = line<number>().x((_, i) => x(rows[i].t)).y((v) => y(v)).curve(curveMonotoneX)(top) ?? ""
|
| 101 |
+
const valueAt = (t: number) => {
|
| 102 |
+
const i = rows.findIndex((r) => r.t >= t)
|
| 103 |
+
if (i <= 0) return top[Math.max(0, i)] ?? 0
|
| 104 |
+
const a = rows[i - 1], b = rows[i]
|
| 105 |
+
return top[i - 1] + ((top[i] - top[i - 1]) * (t - a.t)) / (b.t - a.t)
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
// Releases within three weeks of each other share one pole, names stacked under each other.
|
| 109 |
+
const sorted = [...site.releases].sort((a, b) => a.date.localeCompare(b.date))
|
| 110 |
+
const groups: Release[][] = []
|
| 111 |
+
for (const r of sorted) {
|
| 112 |
+
const last = groups.at(-1)
|
| 113 |
+
if (last && toTime(r.date) - toTime(last[0].date) <= 21 * DAY) last.push(r)
|
| 114 |
+
else groups.push([r])
|
| 115 |
+
}
|
| 116 |
+
const width = (rs: Release[]) => Math.max(...rs.map((r) => textWidth(shortName(r.name)))) + 22
|
| 117 |
+
const pins: Pin[] = []
|
| 118 |
+
let taken = -Infinity // right edge of the last name block placed
|
| 119 |
+
groups.forEach((rs, i) => {
|
| 120 |
+
const t = toTime(rs[0].date), px = x(t), w = width(rs)
|
| 121 |
+
const next = i + 1 < groups.length ? x(toTime(groups[i + 1][0].date)) : Infinity
|
| 122 |
+
const prev = i > 0 ? x(toTime(groups[i - 1][0].date)) : -Infinity
|
| 123 |
+
let side: Pin["side"] = "none"
|
| 124 |
+
if (px - 5 + w < Math.min(next - 8, W + 8) && px - 5 > taken + 8) side = "right"
|
| 125 |
+
else if (px + 5 - w > Math.max(taken, prev) + 10) side = "left"
|
| 126 |
+
if (side === "right") taken = px - 5 + w
|
| 127 |
+
else if (side === "left") taken = Math.max(taken, px + 5)
|
| 128 |
+
pins.push({ t, key: rs.map((r) => r.key).join("+"), rels: rs, cat: rs[0].cat, side })
|
| 129 |
+
})
|
| 130 |
+
|
| 131 |
+
const ticksY = y.ticks(5)
|
| 132 |
+
const ticksX: { t: number; label: string }[] = []
|
| 133 |
+
for (let d = new Date(start); d.getTime() <= end; d.setUTCMonth(d.getUTCMonth() + 3)) {
|
| 134 |
+
const mo = d.getUTCMonth()
|
| 135 |
+
if (mo % 3) { d.setUTCMonth(mo - (mo % 3)); continue }
|
| 136 |
+
ticksX.push({ t: d.getTime(), label: mo === 0 ? String(d.getUTCFullYear()) : ["Jan", "Apr", "Jul", "Oct"][mo / 3] })
|
| 137 |
+
}
|
| 138 |
+
// Quarters when there is room, otherwise half-years; years always win a place.
|
| 139 |
+
const minGap = narrow ? 44 : 60
|
| 140 |
+
const xt: typeof ticksX = []
|
| 141 |
+
for (const tk of ticksX) {
|
| 142 |
+
const px = x(tk.t)
|
| 143 |
+
if (px < m.l + 12 || px > W - m.r - 10) continue
|
| 144 |
+
if (narrow && !["Jan", "Jul"].includes(new Date(tk.t).toUTCString().slice(8, 11))) continue
|
| 145 |
+
const prev = xt.at(-1)
|
| 146 |
+
if (prev && px - x(prev.t) < minGap) {
|
| 147 |
+
if (tk.label.length === 4) xt[xt.length - 1] = tk
|
| 148 |
+
continue
|
| 149 |
+
}
|
| 150 |
+
xt.push(tk)
|
| 151 |
+
}
|
| 152 |
+
return { x, y, stacked, top, areaGen, edge, topLine, valueAt, pins, ticksY, xt }
|
| 153 |
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 154 |
+
}, [W, H, rows, keys.join(), site, narrow])
|
| 155 |
+
useEffect(() => setHover(null), [metric])
|
| 156 |
+
|
| 157 |
+
const onMove = (e: React.PointerEvent) => {
|
| 158 |
+
if (!g) return
|
| 159 |
+
const rect = (e.currentTarget as SVGElement).getBoundingClientRect()
|
| 160 |
+
const t = g.x.invert(e.clientX - rect.left)
|
| 161 |
+
let best = 0
|
| 162 |
+
for (let i = 0; i < rows.length; i++) if (Math.abs(rows[i].t - t) < Math.abs(rows[best].t - t)) best = i
|
| 163 |
+
setHover(best)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
const hr = hover != null ? rows[hover] : null
|
| 167 |
+
const near = hr && g ? g.pins.find((p) => p.rels.some((r) => Math.abs(toTime(r.date) - hr.t) <= 4 * DAY)) : null
|
| 168 |
+
const [lit, setLit] = useState<string | null>(null)
|
| 169 |
+
const plotW = W - m.l - m.r
|
| 170 |
+
|
| 171 |
+
return (
|
| 172 |
+
<div ref={box} className={`relative w-full select-none ${className}`}>
|
| 173 |
+
{g && H > 0 && (
|
| 174 |
+
<svg width={W} height={H} className="absolute inset-0 overflow-visible" role="img"
|
| 175 |
+
aria-label={metric === "models" ? `Community models built on MiniMax, ${value(g.top.at(-1) ?? 0)} today`
|
| 176 |
+
: `Downloads of MiniMax models and everything built on them, ${value(g.top.at(-1) ?? 0)} in all`}>
|
| 177 |
+
<defs>
|
| 178 |
+
{keys.map((c) => (
|
| 179 |
+
<linearGradient key={c} id={`fill-${c}`} x1="0" y1="0" x2="0" y2="1">
|
| 180 |
+
<stop offset="0" style={{ stopColor: catColor(c), stopOpacity: 0.55 }} />
|
| 181 |
+
<stop offset="1" style={{ stopColor: catColor(c), stopOpacity: 0.06 }} />
|
| 182 |
+
</linearGradient>
|
| 183 |
+
))}
|
| 184 |
+
<linearGradient id="top-stroke" x1="0" y1="0" x2="1" y2="0">
|
| 185 |
+
<stop offset="0" stopColor="#ffffff" stopOpacity={0.35} />
|
| 186 |
+
<stop offset="0.7" stopColor="#ffffff" stopOpacity={0.9} />
|
| 187 |
+
<stop offset="1" stopColor="#ffffff" />
|
| 188 |
+
</linearGradient>
|
| 189 |
+
<filter id="glow" x="-10%" y="-30%" width="120%" height="160%">
|
| 190 |
+
<feGaussianBlur stdDeviation="7" />
|
| 191 |
+
</filter>
|
| 192 |
+
</defs>
|
| 193 |
+
|
| 194 |
+
{g.ticksY.map((v) => (
|
| 195 |
+
<g key={v}>
|
| 196 |
+
<line x1={m.l} x2={W - m.r} y1={g.y(v)} y2={g.y(v)} stroke="#fff" strokeOpacity={v === 0 ? 0.16 : 0.07} />
|
| 197 |
+
<text x={W - m.r + 12} y={g.y(v)} dy="0.35em" fontSize={14} fill="#fff"
|
| 198 |
+
fillOpacity={Math.abs(g.y(v) - g.y(g.top.at(-1) ?? 0)) < 16 ? 0 : 0.45}
|
| 199 |
+
className="font-display tabular-nums">{tick(v)}</text>
|
| 200 |
+
</g>
|
| 201 |
+
))}
|
| 202 |
+
{g.xt.map((tk) => (
|
| 203 |
+
<text key={tk.t} x={g.x(tk.t)} y={H - m.b + 26} textAnchor="middle" fontSize={14} fill="#fff"
|
| 204 |
+
fillOpacity={tk.label.length === 4 ? 0.7 : 0.42} className="font-display">{tk.label}</text>
|
| 205 |
+
))}
|
| 206 |
+
|
| 207 |
+
{/* the milestones: every pole starts on the same line at the top and ends on the curve */}
|
| 208 |
+
{!narrow && g.pins.map((p) => {
|
| 209 |
+
const px = g.x(p.t), py = g.y(g.valueAt(p.t))
|
| 210 |
+
const on = lit === p.key || near === p
|
| 211 |
+
return (
|
| 212 |
+
<line key={p.key} x1={px} x2={px} y1={ROW_TOP} y2={py - 7} stroke="#fff"
|
| 213 |
+
strokeOpacity={on ? 0.55 : 0.16} className="transition-[stroke-opacity] duration-200"
|
| 214 |
+
style={{ animation: `fade 500ms ease-out ${(REVEAL * (px - m.l)) / plotW}ms both` }} />
|
| 215 |
+
)
|
| 216 |
+
})}
|
| 217 |
+
|
| 218 |
+
<g key={metric} style={{ animation: `wipe ${REVEAL}ms cubic-bezier(.65,0,.35,1) both` }}>
|
| 219 |
+
{g.stacked.map((s) => (
|
| 220 |
+
<path key={s.key} d={g.areaGen(s as never) ?? ""} fill={`url(#fill-${s.key})`} />
|
| 221 |
+
))}
|
| 222 |
+
{g.stacked.map((s) => (
|
| 223 |
+
<path key={s.key} d={g.edge(s as never) ?? ""} fill="none" stroke={catColor(s.key)} strokeWidth={2} strokeOpacity={0.9} />
|
| 224 |
+
))}
|
| 225 |
+
<path d={g.topLine} fill="none" stroke="#fff" strokeOpacity={0.5} strokeWidth={6} filter="url(#glow)" />
|
| 226 |
+
<path d={g.topLine} fill="none" stroke="url(#top-stroke)" strokeWidth={2.5} strokeLinecap="round" />
|
| 227 |
+
</g>
|
| 228 |
+
|
| 229 |
+
{g.pins.map((p) => {
|
| 230 |
+
const px = g.x(p.t), py = g.y(g.valueAt(p.t))
|
| 231 |
+
const delay = (REVEAL * (px - m.l)) / plotW
|
| 232 |
+
return (
|
| 233 |
+
<g key={`${metric}:${p.key}`} style={{ animation: `pop 520ms cubic-bezier(.34,1.56,.64,1) ${delay}ms both`, transformOrigin: `${px}px ${py}px` }}>
|
| 234 |
+
<circle cx={px} cy={py} r={11} fill={catColor(p.cat)} opacity={0.25} />
|
| 235 |
+
<circle cx={px} cy={py} r={5.5} fill={catColor(p.cat)} stroke="var(--stage)" strokeWidth={2} />
|
| 236 |
+
</g>
|
| 237 |
+
)
|
| 238 |
+
})}
|
| 239 |
+
|
| 240 |
+
{/* today */}
|
| 241 |
+
<g key={`now:${metric}`} style={{ animation: `fade 400ms ease-out ${REVEAL}ms both` }}>
|
| 242 |
+
<circle cx={g.x(last)} cy={g.y(g.top.at(-1) ?? 0)} r={14} fill="#fff" opacity={0.25}
|
| 243 |
+
style={{ animation: "breathe 2.8s ease-in-out infinite", transformOrigin: `${g.x(last)}px ${g.y(g.top.at(-1) ?? 0)}px` }} />
|
| 244 |
+
<circle cx={g.x(last)} cy={g.y(g.top.at(-1) ?? 0)} r={5} fill="#fff" />
|
| 245 |
+
</g>
|
| 246 |
+
|
| 247 |
+
{hr && (
|
| 248 |
+
<g pointerEvents="none">
|
| 249 |
+
<line x1={g.x(hr.t)} x2={g.x(hr.t)} y1={m.t - 8} y2={H - m.b} stroke="#fff" strokeOpacity={0.35} />
|
| 250 |
+
{g.stacked.map((s) => (
|
| 251 |
+
<circle key={s.key} cx={g.x(hr.t)} cy={g.y(s[hover!][1])} r={4.5} fill={catColor(s.key)} stroke="var(--stage)" strokeWidth={2} />
|
| 252 |
+
))}
|
| 253 |
+
</g>
|
| 254 |
+
)}
|
| 255 |
+
|
| 256 |
+
<rect x={m.l} y={m.t - 10} width={plotW} height={H - m.b - m.t + 10} fill="transparent"
|
| 257 |
+
onPointerMove={onMove} onPointerDown={(e) => { pointer.current = e.pointerType; onMove(e) }}
|
| 258 |
+
onPointerLeave={(e) => e.pointerType === "mouse" && setHover(null)}
|
| 259 |
+
onClick={() => near && pointer.current === "mouse" && onPick(pick(near.rels))}
|
| 260 |
+
style={{ cursor: near ? "pointer" : "crosshair" }} />
|
| 261 |
+
</svg>
|
| 262 |
+
)}
|
| 263 |
+
|
| 264 |
+
{/* names are HTML so they stay crisp, focusable and clickable; each dot sits on its pole */}
|
| 265 |
+
{g && !narrow && g.pins.map((p) => p.side !== "none" && (
|
| 266 |
+
<div key={p.key} className="absolute flex flex-col"
|
| 267 |
+
style={{ top: ROW_TOP - LINE_H / 2, height: LINE_H * p.rels.length,
|
| 268 |
+
...(p.side === "left" ? { right: W - g.x(p.t) - 5, alignItems: "flex-end" } : { left: g.x(p.t) - 5 }),
|
| 269 |
+
animation: `fade 500ms ease-out ${(REVEAL * (g.x(p.t) - m.l)) / plotW}ms both` }}
|
| 270 |
+
onPointerEnter={() => setLit(p.key)} onPointerLeave={() => setLit(null)}>
|
| 271 |
+
{p.rels.map((r) => (
|
| 272 |
+
<button key={r.key} type="button" onClick={() => onPick(r)}
|
| 273 |
+
className={`group inline-flex items-center gap-2.5 font-display text-[15px] leading-none font-medium whitespace-nowrap text-white/75 transition-colors hover:text-white ${p.side === "left" ? "flex-row-reverse" : ""}`}
|
| 274 |
+
style={{ height: LINE_H }}>
|
| 275 |
+
<span className="size-2.5 shrink-0 rounded-full ring-2 ring-[var(--stage)] transition-transform group-hover:scale-125"
|
| 276 |
+
style={{ background: catColor(r.cat) }} />
|
| 277 |
+
{shortName(r.name)}
|
| 278 |
+
</button>
|
| 279 |
+
))}
|
| 280 |
+
</div>
|
| 281 |
+
))}
|
| 282 |
+
|
| 283 |
+
{g && hr && (
|
| 284 |
+
<Tip x={g.x(hr.t)} W={W} top={m.t}>
|
| 285 |
+
<div className="text-[15px] text-white/60">{mdy(new Date(hr.t).toISOString())}</div>
|
| 286 |
+
<div className="mt-0.5 font-display text-[28px] leading-tight font-semibold tabular-nums">
|
| 287 |
+
{value(keys.reduce((a, c) => a + hr[c], 0))}
|
| 288 |
+
</div>
|
| 289 |
+
<div className="mt-2 space-y-1">
|
| 290 |
+
{[...keys].reverse().filter((c) => hr[c] > 0).map((c) => (
|
| 291 |
+
<div key={c} className="flex items-center justify-between gap-6 text-[15px]">
|
| 292 |
+
<span className="inline-flex items-center gap-2 text-white/75">
|
| 293 |
+
<span className="size-2.5 rounded-full" style={{ background: catColor(c) }} />
|
| 294 |
+
{site.categories.find((x) => x.key === c)?.name}
|
| 295 |
+
</span>
|
| 296 |
+
<span className="font-display tabular-nums">{value(hr[c])}</span>
|
| 297 |
+
</div>
|
| 298 |
+
))}
|
| 299 |
+
</div>
|
| 300 |
+
{near && (
|
| 301 |
+
<div className="mt-3 border-t border-white/10 pt-2.5 text-[15px]">
|
| 302 |
+
{near.rels.map((r) => (
|
| 303 |
+
<div key={r.key} className="flex items-center justify-between gap-6">
|
| 304 |
+
<span className="font-medium">{r.name}</span>
|
| 305 |
+
<span className="text-white/60">{md(r.date)}</span>
|
| 306 |
+
</div>
|
| 307 |
+
))}
|
| 308 |
+
</div>
|
| 309 |
+
)}
|
| 310 |
+
</Tip>
|
| 311 |
+
)}
|
| 312 |
+
</div>
|
| 313 |
+
)
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
function Tip({ x, W, top, children }: { x: number; W: number; top: number; children: React.ReactNode }) {
|
| 317 |
+
const w = 248
|
| 318 |
+
const left = x + 18 + w < W ? x + 18 : Math.max(0, x - 18 - w)
|
| 319 |
+
return (
|
| 320 |
+
<div className="pointer-events-none absolute z-10 rounded-2xl border border-white/12 bg-[#15151c]/90 p-4 text-white shadow-[0_18px_40px_rgba(0,0,0,0.45)] backdrop-blur-md"
|
| 321 |
+
style={{ left, top, width: w }}>
|
| 322 |
+
{children}
|
| 323 |
+
</div>
|
| 324 |
+
)
|
| 325 |
+
}
|
code/web/src/components/daily.tsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useMemo, useState } from "react"
|
| 2 |
+
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
|
| 3 |
+
import { ChartContainer, ChartTooltip } from "@/components/ui/chart"
|
| 4 |
+
import { REL_NAME, type Lineage, type Rel } from "@/lib/types"
|
| 5 |
+
import { isoDay, mdy, num, toTime } from "@/lib/format"
|
| 6 |
+
import { timeTicks } from "@/lib/ticks"
|
| 7 |
+
import { Panel, Section } from "@/components/layout"
|
| 8 |
+
import { axisTick, relColor, relConfig, RelLegend } from "@/components/rel"
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Downloads per day of the community models, stacked by kind, about a week per point (the
|
| 12 |
+
* hub-stats history, then our snapshots); drawn like the other time charts on the page.
|
| 13 |
+
*/
|
| 14 |
+
export function DailyLines({ L, rel, download }: { L: Lineage; rel: Rel[]; download?: string }) {
|
| 15 |
+
const { rows, present, thin } = useMemo(() => {
|
| 16 |
+
const days = [...new Set(L.daily.map((d) => d.day))].sort()
|
| 17 |
+
// biggest kinds at the bottom of the stack
|
| 18 |
+
const total = (r: Rel) => L.daily.reduce((a, d) => a + (d.rel === r ? d.n : 0), 0)
|
| 19 |
+
const present = rel.filter((r) => total(r) > 0).sort((a, b) => total(b) - total(a))
|
| 20 |
+
const at = new Map(L.daily.map((d) => [`${d.day}|${d.rel}`, d.n]))
|
| 21 |
+
const rows = days.map((day) => ({ t: toTime(day), ...Object.fromEntries(present.map((r) => [r, at.get(`${day}|${r}`) ?? 0])) }))
|
| 22 |
+
// a sliver of the total gets no outline, or it would trace the top of the stack in its colour
|
| 23 |
+
const all = present.reduce((a, r) => a + total(r), 0) || 1
|
| 24 |
+
const thin = new Set(present.filter((r) => total(r) / all < 0.02))
|
| 25 |
+
return { rows, present, thin }
|
| 26 |
+
}, [L, rel])
|
| 27 |
+
const [hidden, setHidden] = useState<Set<Rel>>(new Set())
|
| 28 |
+
const toggle = (r: Rel) => setHidden((h) => {
|
| 29 |
+
const n = new Set(h)
|
| 30 |
+
if (n.has(r)) n.delete(r)
|
| 31 |
+
else if (n.size < present.length - 1) n.add(r)
|
| 32 |
+
return n
|
| 33 |
+
})
|
| 34 |
+
const { ticks, label } = useMemo(() => (rows.length ? timeTicks(rows[0].t, rows.at(-1)!.t) : { ticks: [], label: String }), [rows])
|
| 35 |
+
if (rows.length < 2) return null
|
| 36 |
+
const shown = present.filter((r) => !hidden.has(r))
|
| 37 |
+
|
| 38 |
+
return (
|
| 39 |
+
<Section title="Daily downloads">
|
| 40 |
+
<Panel download={download}>
|
| 41 |
+
<RelLegend rels={[...present].sort((a, b) => rel.indexOf(a) - rel.indexOf(b))} hidden={hidden} onToggle={toggle} />
|
| 42 |
+
<ChartContainer config={relConfig(present)} className="aspect-auto h-[360px] w-full">
|
| 43 |
+
<AreaChart data={rows} margin={{ left: 4, right: 12, top: 8 }}>
|
| 44 |
+
<defs>
|
| 45 |
+
{present.map((r) => (
|
| 46 |
+
<linearGradient key={r} id={`dd-${r}`} x1="0" y1="0" x2="0" y2="1">
|
| 47 |
+
<stop offset="0" stopColor={relColor(r)} stopOpacity={0.5} />
|
| 48 |
+
<stop offset="1" stopColor={relColor(r)} stopOpacity={0.08} />
|
| 49 |
+
</linearGradient>
|
| 50 |
+
))}
|
| 51 |
+
</defs>
|
| 52 |
+
<CartesianGrid vertical={false} />
|
| 53 |
+
<XAxis dataKey="t" type="number" scale="time" domain={["dataMin", "dataMax"]} ticks={ticks}
|
| 54 |
+
tickFormatter={label} tickLine={false} axisLine={false} tick={axisTick} />
|
| 55 |
+
<YAxis tickLine={false} axisLine={false} tick={axisTick} width={56} tickFormatter={(v) => num(Number(v))} />
|
| 56 |
+
<ChartTooltip cursor={{ stroke: "var(--muted-foreground)", strokeOpacity: 0.4 }}
|
| 57 |
+
content={({ active, payload }) => {
|
| 58 |
+
if (!active || !payload?.length) return null
|
| 59 |
+
const row = payload[0].payload as Record<string, number>
|
| 60 |
+
const items = [...shown].reverse().filter((r) => row[r] > 0)
|
| 61 |
+
return (
|
| 62 |
+
<div className="min-w-[13rem] rounded-xl border border-border/60 bg-background px-3.5 py-3 text-[15px] shadow-xl">
|
| 63 |
+
<div className="text-muted-foreground">{mdy(isoDay(row.t))}</div>
|
| 64 |
+
<div className="mt-0.5 font-display text-[24px] leading-tight font-semibold tabular-nums">
|
| 65 |
+
{num(shown.reduce((a, r) => a + (row[r] ?? 0), 0))}
|
| 66 |
+
</div>
|
| 67 |
+
<div className="mt-2 space-y-1">
|
| 68 |
+
{items.map((r) => (
|
| 69 |
+
<div key={r} className="flex items-center justify-between gap-6">
|
| 70 |
+
<span className="inline-flex items-center gap-2 text-muted-foreground">
|
| 71 |
+
<span className="size-2.5 rounded-full" style={{ background: relColor(r) }} />
|
| 72 |
+
{REL_NAME[r]}
|
| 73 |
+
</span>
|
| 74 |
+
<span className="font-medium tabular-nums">{num(row[r])}</span>
|
| 75 |
+
</div>
|
| 76 |
+
))}
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
)
|
| 80 |
+
}} />
|
| 81 |
+
{shown.map((r) => (
|
| 82 |
+
<Area key={r} dataKey={r} stackId="d" type="monotone" stroke={relColor(r)} strokeWidth={thin.has(r) ? 0 : 1.75}
|
| 83 |
+
fill={`url(#dd-${r})`} dot={false} activeDot={{ r: 4, strokeWidth: 2, stroke: "var(--card)" }}
|
| 84 |
+
animationDuration={1100} animationEasing="ease-out" />
|
| 85 |
+
))}
|
| 86 |
+
</AreaChart>
|
| 87 |
+
</ChartContainer>
|
| 88 |
+
</Panel>
|
| 89 |
+
</Section>
|
| 90 |
+
)
|
| 91 |
+
}
|
code/web/src/components/download-button.tsx
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useRef, useState } from "react"
|
| 2 |
+
import { Check, Download, LoaderCircle } from "lucide-react"
|
| 3 |
+
import { backgroundFor, EXPORT_IGNORE, savePng } from "@/lib/export"
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Round icon button in the top right of a chart: saves `target` as a PNG named after `name`.
|
| 7 |
+
* `tone` matches what it sits on (a card on the page, or the dark stage).
|
| 8 |
+
*/
|
| 9 |
+
export function DownloadButton({ target, name, tone = "card", pad = 0, big = false, className = "" }: {
|
| 10 |
+
target: React.RefObject<HTMLElement | null>; name: string; tone?: "card" | "stage"; pad?: number; big?: boolean; className?: string
|
| 11 |
+
}) {
|
| 12 |
+
const [state, setState] = useState<"idle" | "busy" | "done">("idle")
|
| 13 |
+
const timer = useRef<number>(0)
|
| 14 |
+
useEffect(() => () => window.clearTimeout(timer.current), [])
|
| 15 |
+
|
| 16 |
+
const run = async () => {
|
| 17 |
+
const node = target.current
|
| 18 |
+
if (!node || state === "busy") return
|
| 19 |
+
setState("busy")
|
| 20 |
+
try {
|
| 21 |
+
await savePng(node, name, { background: backgroundFor(node), pad })
|
| 22 |
+
setState("done")
|
| 23 |
+
timer.current = window.setTimeout(() => setState("idle"), 1400)
|
| 24 |
+
} catch {
|
| 25 |
+
setState("idle")
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
const look = tone === "stage"
|
| 30 |
+
? "border-white/15 bg-white/[0.06] text-white/70 backdrop-blur hover:border-white/35 hover:bg-white/12 hover:text-white focus-visible:outline-white/60"
|
| 31 |
+
: "border-border bg-card text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-ring"
|
| 32 |
+
const Icon = state === "busy" ? LoaderCircle : state === "done" ? Check : Download
|
| 33 |
+
return (
|
| 34 |
+
<button type="button" onClick={run} {...{ [EXPORT_IGNORE]: "" }}
|
| 35 |
+
aria-label={`Download ${name} as PNG`} title="Download PNG" aria-busy={state === "busy"}
|
| 36 |
+
className={`inline-flex ${big ? "size-10" : "size-9"} shrink-0 items-center justify-center rounded-full border transition-colors focus-visible:outline-2 ${look} ${className}`}>
|
| 37 |
+
<Icon className={`size-4 ${state === "busy" ? "animate-spin" : ""}`} strokeWidth={2} />
|
| 38 |
+
</button>
|
| 39 |
+
)
|
| 40 |
+
}
|
code/web/src/components/downloads.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useMemo, useState } from "react"
|
| 2 |
+
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
|
| 3 |
+
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/ui/chart"
|
| 4 |
+
import { axisTick } from "@/components/rel"
|
| 5 |
+
import { isoDay, mdy, num, toTime } from "@/lib/format"
|
| 6 |
+
import { timeTicks } from "@/lib/ticks"
|
| 7 |
+
|
| 8 |
+
type Key = "comm" | "off"
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* All-time downloads over time, like a star history: the community models built on a release,
|
| 12 |
+
* and the release itself. Points are about a week apart (hub-stats history, then our snapshots).
|
| 13 |
+
*/
|
| 14 |
+
export function DownloadHistory({ history, name, color }: { history: [string, number, number][]; name: string; color: string }) {
|
| 15 |
+
const rows = useMemo(() => history.map(([d, off, comm]) => ({ t: toTime(d), off, comm })), [history])
|
| 16 |
+
const [hidden, setHidden] = useState<Set<Key>>(new Set())
|
| 17 |
+
const config = {
|
| 18 |
+
comm: { label: "Community downloads", color },
|
| 19 |
+
off: { label: `${name} downloads`, color: "var(--foreground)" },
|
| 20 |
+
} satisfies ChartConfig
|
| 21 |
+
const keys: Key[] = ["comm", "off"]
|
| 22 |
+
|
| 23 |
+
const { ticks, label } = useMemo(() => timeTicks(rows[0].t, rows.at(-1)!.t), [rows])
|
| 24 |
+
|
| 25 |
+
const toggle = (k: Key) => setHidden((h) => {
|
| 26 |
+
const n = new Set(h)
|
| 27 |
+
if (n.has(k)) n.delete(k)
|
| 28 |
+
else if (n.size < keys.length - 1) n.add(k)
|
| 29 |
+
return n
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
+
return (
|
| 33 |
+
<>
|
| 34 |
+
<div className="mb-4 flex flex-wrap gap-x-5 gap-y-2 text-[15px] text-muted-foreground">
|
| 35 |
+
{keys.map((k) => {
|
| 36 |
+
const off = hidden.has(k)
|
| 37 |
+
return (
|
| 38 |
+
<button key={k} type="button" aria-pressed={!off} onClick={() => toggle(k)}
|
| 39 |
+
className="inline-flex items-center gap-2 rounded-md hover:text-foreground">
|
| 40 |
+
<span className={`inline-block size-2.5 shrink-0 rounded-full ${off ? "border border-muted-foreground" : ""}`}
|
| 41 |
+
style={{ background: off ? "transparent" : config[k].color }} />
|
| 42 |
+
<span className={off ? "line-through opacity-60" : ""}>{config[k].label}</span>
|
| 43 |
+
<span className="font-medium text-foreground tabular-nums">{num(rows.at(-1)![k])}</span>
|
| 44 |
+
</button>
|
| 45 |
+
)
|
| 46 |
+
})}
|
| 47 |
+
</div>
|
| 48 |
+
<ChartContainer config={config} className="aspect-auto h-[360px] w-full">
|
| 49 |
+
<AreaChart data={rows} margin={{ left: 4, right: 12, top: 8 }}>
|
| 50 |
+
<defs>
|
| 51 |
+
{keys.map((k) => (
|
| 52 |
+
<linearGradient key={k} id={`dlh-${k}`} x1="0" y1="0" x2="0" y2="1">
|
| 53 |
+
<stop offset="0" stopColor={`var(--color-${k})`} stopOpacity={k === "comm" ? 0.35 : 0.12} />
|
| 54 |
+
<stop offset="1" stopColor={`var(--color-${k})`} stopOpacity={0.02} />
|
| 55 |
+
</linearGradient>
|
| 56 |
+
))}
|
| 57 |
+
</defs>
|
| 58 |
+
<CartesianGrid vertical={false} />
|
| 59 |
+
<XAxis dataKey="t" type="number" scale="time" domain={["dataMin", "dataMax"]} ticks={ticks}
|
| 60 |
+
tickFormatter={label} tickLine={false} axisLine={false} tick={axisTick} />
|
| 61 |
+
<YAxis tickLine={false} axisLine={false} tick={axisTick} width={56} tickFormatter={(v) => num(Number(v))} />
|
| 62 |
+
<ChartTooltip content={<ChartTooltipContent labelFormatter={(_, p) => mdy(isoDay(Number(p?.[0]?.payload?.t)))}
|
| 63 |
+
formatter={(v, k) => (
|
| 64 |
+
<span className="flex w-full items-center justify-between gap-6">
|
| 65 |
+
<span className="flex items-center gap-2 text-muted-foreground">
|
| 66 |
+
<span className="size-2.5 rounded-full" style={{ background: config[k as Key].color }} />
|
| 67 |
+
{config[k as Key].label}
|
| 68 |
+
</span>
|
| 69 |
+
<span className="font-medium tabular-nums">{num(Number(v))}</span>
|
| 70 |
+
</span>)} />} />
|
| 71 |
+
{keys.filter((k) => !hidden.has(k)).map((k) => (
|
| 72 |
+
<Area key={k} dataKey={k} type="monotone" stroke={`var(--color-${k})`} strokeWidth={k === "comm" ? 2.5 : 2}
|
| 73 |
+
fill={`url(#dlh-${k})`} dot={false} animationDuration={1100} animationEasing="ease-out" />
|
| 74 |
+
))}
|
| 75 |
+
</AreaChart>
|
| 76 |
+
</ChartContainer>
|
| 77 |
+
</>
|
| 78 |
+
)
|
| 79 |
+
}
|
code/web/src/components/galaxy.tsx
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useMemo, useRef, useState } from "react"
|
| 2 |
+
import { REL_NAME, type Author, type Lineage, type Rel, type Repo } from "@/lib/types"
|
| 3 |
+
import { num as fmt, full, hfUrl, mdy } from "@/lib/format"
|
| 4 |
+
import { catFrom, catTo } from "@/lib/category"
|
| 5 |
+
import type { Ring } from "@/lib/galaxy"
|
| 6 |
+
import { RelDot, RelLegend } from "@/components/rel"
|
| 7 |
+
import { Who } from "@/components/who"
|
| 8 |
+
import { Octopus } from "@/components/octopus"
|
| 9 |
+
import { DownloadButton } from "@/components/download-button"
|
| 10 |
+
|
| 11 |
+
type P = { id: string; x: number; y: number; r: number; ring: number; repo: Repo }
|
| 12 |
+
type Layout = { pos: P[]; rings: Ring[]; extent: number }
|
| 13 |
+
|
| 14 |
+
const RING_NAME = ["", "Built on it directly", "Second generation", "Third generation and on"]
|
| 15 |
+
const ORDER: Rel[] = ["adapter", "finetune", "quantized", "repackage", "merge", "mirror", "component"]
|
| 16 |
+
const CENTER_R = 64
|
| 17 |
+
const LABEL_FONT = '500 14px "DM Sans Variable", system-ui, sans-serif'
|
| 18 |
+
|
| 19 |
+
/** Deterministic 0..1 from a string, so every bubble keeps its own rhythm across loads. */
|
| 20 |
+
function hash(s: string): number {
|
| 21 |
+
let h = 2166136261
|
| 22 |
+
for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619)
|
| 23 |
+
return ((h >>> 0) % 100000) / 100000
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* The official model in the middle (the MiniMax Code octopus), every community model around it:
|
| 28 |
+
* one ring per generation, each bubble near the model it is built on, bigger bubble for more
|
| 29 |
+
* downloads. Bubbles are painted in exactly the relation colours used everywhere else on the
|
| 30 |
+
* page. They drift a little on their own while neighbouring rings sway against each other; the
|
| 31 |
+
* motion pauses while something is hovered, when the picture is off screen, and entirely under
|
| 32 |
+
* reduced motion. Drawn on a canvas: 1,000+ moving circles would choke SVG.
|
| 33 |
+
*/
|
| 34 |
+
export function Galaxy({ lineageKey, repos, L, authors, name, cat }: {
|
| 35 |
+
lineageKey: string; repos: Repo[]; L: Lineage; authors: Record<string, Author>; name: string; cat: string
|
| 36 |
+
}) {
|
| 37 |
+
const [layout, setLayout] = useState<Layout | null>(null)
|
| 38 |
+
const [hover, setHover] = useState<string | null>(null)
|
| 39 |
+
const box = useRef<HTMLDivElement>(null)
|
| 40 |
+
const stageRef = useRef<HTMLDivElement>(null)
|
| 41 |
+
const canvas = useRef<HTMLCanvasElement>(null)
|
| 42 |
+
const tapRef = useRef<string | null>(null) // what was showing before this tap
|
| 43 |
+
const typeRef = useRef("mouse")
|
| 44 |
+
const hoverRef = useRef<string | null>(null)
|
| 45 |
+
const cur = useRef<Float32Array>(new Float32Array(0)) // current x, y of every bubble
|
| 46 |
+
// A first guess from the window, so the picture has its size before the observer reports.
|
| 47 |
+
const [w, setW] = useState(() => Math.min(window.innerWidth - 64, 1072))
|
| 48 |
+
|
| 49 |
+
useEffect(() => {
|
| 50 |
+
const worker = new Worker(new URL("../lib/galaxy.worker.ts", import.meta.url), { type: "module" })
|
| 51 |
+
const byId = new Map(repos.map((r) => [r.id, r]))
|
| 52 |
+
worker.onmessage = (e) => {
|
| 53 |
+
const { pos, rings, extent } = e.data as { pos: [string, number, number, number, number][]; rings: Ring[]; extent: number }
|
| 54 |
+
setLayout({ pos: pos.map(([id, x, y, r, ring]) => ({ id, x, y, r, ring, repo: byId.get(id)! })), rings, extent })
|
| 55 |
+
worker.terminate()
|
| 56 |
+
}
|
| 57 |
+
worker.postMessage({ key: lineageKey, repos, base: L.base, officialDl: L.official.dlall ?? 0 })
|
| 58 |
+
return () => worker.terminate()
|
| 59 |
+
}, [lineageKey, repos, L])
|
| 60 |
+
|
| 61 |
+
useEffect(() => {
|
| 62 |
+
const el = box.current
|
| 63 |
+
if (!el) return
|
| 64 |
+
const ro = new ResizeObserver(() => setW(el.clientWidth))
|
| 65 |
+
ro.observe(el)
|
| 66 |
+
return () => ro.disconnect()
|
| 67 |
+
}, [])
|
| 68 |
+
|
| 69 |
+
const size = Math.min(w, 980)
|
| 70 |
+
const E = (layout?.extent ?? 300) + 8
|
| 71 |
+
const k = size / (2 * E) // world -> px
|
| 72 |
+
const toPx = (x: number) => size / 2 + x * k
|
| 73 |
+
|
| 74 |
+
const index = useMemo(() => new Map(layout?.pos.map((p, i) => [p.id, i]) ?? []), [layout])
|
| 75 |
+
const kids = useMemo(() => {
|
| 76 |
+
const m = new Map<string, number[]>()
|
| 77 |
+
layout?.pos.forEach((p, i) => m.set(p.repo.up, [...(m.get(p.repo.up) ?? []), i]))
|
| 78 |
+
return m
|
| 79 |
+
}, [layout])
|
| 80 |
+
|
| 81 |
+
// Names for the biggest bubbles, skipping any that would collide with one already placed.
|
| 82 |
+
const labels = useMemo(() => {
|
| 83 |
+
if (!layout || size < 560) return []
|
| 84 |
+
const ctx = document.createElement("canvas").getContext("2d")!
|
| 85 |
+
ctx.font = LABEL_FONT
|
| 86 |
+
const placed: { x0: number; x1: number; y0: number; y1: number }[] = []
|
| 87 |
+
const out: { i: number; w: number }[] = []
|
| 88 |
+
const order = layout.pos.map((p, i) => [p, i] as const).sort((a, b) => b[0].r - a[0].r).slice(0, 24)
|
| 89 |
+
for (const [p, i] of order) {
|
| 90 |
+
if (p.r * k < 9 || out.length >= 6) break
|
| 91 |
+
const wpx = ctx.measureText(p.id).width + 22
|
| 92 |
+
const x = toPx(p.x), y = toPx(p.y) + p.r * k + 6
|
| 93 |
+
const rect = { x0: x - wpx / 2 - 6, x1: x + wpx / 2 + 6, y0: y - 4, y1: y + 30 }
|
| 94 |
+
if (placed.some((q) => rect.x0 < q.x1 && rect.x1 > q.x0 && rect.y0 < q.y1 && rect.y1 > q.y0)) continue
|
| 95 |
+
placed.push(rect)
|
| 96 |
+
out.push({ i, w: wpx })
|
| 97 |
+
}
|
| 98 |
+
return out
|
| 99 |
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 100 |
+
}, [layout, size])
|
| 101 |
+
|
| 102 |
+
const lit = useMemo(() => {
|
| 103 |
+
if (!hover || !layout) return null
|
| 104 |
+
const s = new Set<number>()
|
| 105 |
+
const hi = index.get(hover)
|
| 106 |
+
if (hi != null) {
|
| 107 |
+
s.add(hi)
|
| 108 |
+
const up = index.get(layout.pos[hi].repo.up)
|
| 109 |
+
if (up != null) s.add(up)
|
| 110 |
+
}
|
| 111 |
+
for (const c of kids.get(hover) ?? []) s.add(c)
|
| 112 |
+
return s
|
| 113 |
+
}, [hover, layout, index, kids])
|
| 114 |
+
const litRef = useRef<Set<number> | null>(null)
|
| 115 |
+
useEffect(() => {
|
| 116 |
+
hoverRef.current = hover
|
| 117 |
+
litRef.current = lit
|
| 118 |
+
}, [hover, lit])
|
| 119 |
+
|
| 120 |
+
// The animation loop: positions are a function of a clock that only runs while the picture
|
| 121 |
+
// is visible and nothing is hovered.
|
| 122 |
+
useEffect(() => {
|
| 123 |
+
const cv = canvas.current, stage = stageRef.current
|
| 124 |
+
if (!cv || !stage || !layout || !size) return
|
| 125 |
+
const dpr = Math.min(2, window.devicePixelRatio || 1)
|
| 126 |
+
cv.width = Math.round(size * dpr)
|
| 127 |
+
cv.height = Math.round(size * dpr)
|
| 128 |
+
const ctx = cv.getContext("2d")!
|
| 129 |
+
const n = layout.pos.length
|
| 130 |
+
if (cur.current.length !== 2 * n) cur.current = new Float32Array(2 * n)
|
| 131 |
+
const rho = new Float32Array(n), theta = new Float32Array(n)
|
| 132 |
+
const ph = new Float32Array(n), fq = new Float32Array(n), amp = new Float32Array(n)
|
| 133 |
+
const maxR = Math.max(1, ...layout.pos.map((p) => p.r))
|
| 134 |
+
layout.pos.forEach((p, i) => {
|
| 135 |
+
rho[i] = Math.hypot(p.x, p.y)
|
| 136 |
+
theta[i] = Math.atan2(p.y, p.x)
|
| 137 |
+
ph[i] = hash(p.id) * Math.PI * 2
|
| 138 |
+
fq[i] = 0.55 + hash(p.id + "f") * 0.6 // radians per second
|
| 139 |
+
amp[i] = (1.2 + 2.6 * (1 - p.r / maxR)) / k // small bubbles wander more
|
| 140 |
+
})
|
| 141 |
+
const byColor = new Map<Rel, number[]>()
|
| 142 |
+
layout.pos.forEach((p, i) => byColor.set(p.repo.rel, [...(byColor.get(p.repo.rel) ?? []), i]))
|
| 143 |
+
|
| 144 |
+
const still = matchMedia("(prefers-reduced-motion: reduce)").matches
|
| 145 |
+
let visible = true
|
| 146 |
+
const io = new IntersectionObserver(([e]) => (visible = e.isIntersecting))
|
| 147 |
+
io.observe(cv)
|
| 148 |
+
let colors: Record<string, string> = {}
|
| 149 |
+
let colorsAt = -1e9
|
| 150 |
+
let clock = 0, last = performance.now(), raf = 0
|
| 151 |
+
|
| 152 |
+
const frame = (now: number) => {
|
| 153 |
+
raf = requestAnimationFrame(frame)
|
| 154 |
+
const dt = Math.min(0.05, (now - last) / 1000)
|
| 155 |
+
last = now
|
| 156 |
+
const hovering = hoverRef.current != null
|
| 157 |
+
if (!visible) return
|
| 158 |
+
if (!still && !hovering) clock += dt
|
| 159 |
+
if (now - colorsAt > 1000) { // follows a light/dark switch within a second
|
| 160 |
+
const cs = getComputedStyle(stage)
|
| 161 |
+
colors = Object.fromEntries(ORDER.map((r) => [r, cs.getPropertyValue(`--rel-${r}`).trim() || "#888"]))
|
| 162 |
+
colorsAt = now
|
| 163 |
+
}
|
| 164 |
+
const t = clock
|
| 165 |
+
const c = cur.current
|
| 166 |
+
for (let i = 0; i < n; i++) {
|
| 167 |
+
const ring = layout.pos[i].ring
|
| 168 |
+
const sway = 0.022 * (ring % 2 ? 1 : -1) * Math.sin((t * 2 * Math.PI) / 16 + ring * 0.9)
|
| 169 |
+
const a = theta[i] + sway
|
| 170 |
+
c[2 * i] = rho[i] * Math.cos(a) + amp[i] * Math.sin(t * fq[i] + ph[i])
|
| 171 |
+
c[2 * i + 1] = rho[i] * Math.sin(a) + amp[i] * Math.cos(t * fq[i] * 0.83 + ph[i] * 1.7)
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
| 175 |
+
ctx.clearRect(0, 0, cv.width, cv.height)
|
| 176 |
+
ctx.setTransform(dpr * k, 0, 0, dpr * k, (dpr * size) / 2, (dpr * size) / 2)
|
| 177 |
+
|
| 178 |
+
for (const g of layout.rings) {
|
| 179 |
+
ctx.beginPath()
|
| 180 |
+
ctx.arc(0, 0, (g.inner + g.outer) / 2, 0, Math.PI * 2)
|
| 181 |
+
ctx.strokeStyle = "rgba(255,255,255,0.035)"
|
| 182 |
+
ctx.lineWidth = g.outer - g.inner + 16
|
| 183 |
+
ctx.setLineDash([])
|
| 184 |
+
ctx.stroke()
|
| 185 |
+
ctx.beginPath()
|
| 186 |
+
ctx.arc(0, 0, g.outer + 8, 0, Math.PI * 2)
|
| 187 |
+
ctx.strokeStyle = "rgba(255,255,255,0.14)"
|
| 188 |
+
ctx.lineWidth = 1 / k
|
| 189 |
+
ctx.setLineDash([2 / k, 6 / k])
|
| 190 |
+
ctx.stroke()
|
| 191 |
+
}
|
| 192 |
+
ctx.setLineDash([])
|
| 193 |
+
|
| 194 |
+
const L2 = litRef.current
|
| 195 |
+
const hv = hoverRef.current
|
| 196 |
+
if (hv && L2) {
|
| 197 |
+
const hi = index.get(hv)
|
| 198 |
+
const ax = hi == null ? 0 : c[2 * hi], ay = hi == null ? 0 : c[2 * hi + 1]
|
| 199 |
+
ctx.strokeStyle = "rgba(255,255,255,0.55)"
|
| 200 |
+
ctx.lineWidth = 1.3 / k
|
| 201 |
+
ctx.beginPath()
|
| 202 |
+
const link = (bx: number, by: number) => {
|
| 203 |
+
ctx.moveTo(ax, ay)
|
| 204 |
+
ctx.quadraticCurveTo(((ax + bx) / 2) * 0.82, ((ay + by) / 2) * 0.82, bx, by)
|
| 205 |
+
}
|
| 206 |
+
for (const j of L2) if (j !== hi) link(c[2 * j], c[2 * j + 1])
|
| 207 |
+
if (hi != null && index.get(layout.pos[hi].repo.up) == null) link(0, 0) // built on the official model
|
| 208 |
+
ctx.stroke()
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
for (const pass of [0, 1]) { // dimmed bubbles first, so the lit ones sit on top
|
| 212 |
+
if (pass === 1 && !L2) break
|
| 213 |
+
for (const [rel, idx] of byColor) {
|
| 214 |
+
ctx.fillStyle = colors[rel]
|
| 215 |
+
ctx.globalAlpha = L2 ? (pass === 0 ? 0.14 : 1) : 1
|
| 216 |
+
ctx.beginPath()
|
| 217 |
+
for (const i of idx) {
|
| 218 |
+
if (L2 && (pass === 0) === L2.has(i)) continue
|
| 219 |
+
const x = c[2 * i], y = c[2 * i + 1], r = layout.pos[i].r
|
| 220 |
+
ctx.moveTo(x + r, y)
|
| 221 |
+
ctx.arc(x, y, r, 0, Math.PI * 2)
|
| 222 |
+
}
|
| 223 |
+
ctx.fill()
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
ctx.globalAlpha = 1
|
| 227 |
+
const hi = hv ? index.get(hv) : undefined
|
| 228 |
+
if (hi != null) {
|
| 229 |
+
ctx.beginPath()
|
| 230 |
+
ctx.arc(c[2 * hi], c[2 * hi + 1], layout.pos[hi].r + 1.5 / k, 0, Math.PI * 2)
|
| 231 |
+
ctx.strokeStyle = "#fff"
|
| 232 |
+
ctx.lineWidth = 2 / k
|
| 233 |
+
ctx.stroke()
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
// names of the biggest bubbles ride along with them
|
| 237 |
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
|
| 238 |
+
ctx.font = LABEL_FONT
|
| 239 |
+
ctx.textAlign = "center"
|
| 240 |
+
ctx.textBaseline = "middle"
|
| 241 |
+
for (const { i, w: lw } of labels) {
|
| 242 |
+
const x = size / 2 + c[2 * i] * k, y = size / 2 + c[2 * i + 1] * k + layout.pos[i].r * k + 6
|
| 243 |
+
ctx.globalAlpha = L2 && !L2.has(i) ? 0.2 : 1
|
| 244 |
+
ctx.beginPath()
|
| 245 |
+
ctx.roundRect(x - lw / 2, y, lw, 26, 13)
|
| 246 |
+
ctx.fillStyle = "rgba(21,21,28,0.86)"
|
| 247 |
+
ctx.fill()
|
| 248 |
+
ctx.strokeStyle = "rgba(255,255,255,0.12)"
|
| 249 |
+
ctx.lineWidth = 1
|
| 250 |
+
ctx.stroke()
|
| 251 |
+
ctx.fillStyle = "#fff"
|
| 252 |
+
ctx.fillText(layout.pos[i].id, x, y + 13.5)
|
| 253 |
+
}
|
| 254 |
+
ctx.globalAlpha = 1
|
| 255 |
+
}
|
| 256 |
+
raf = requestAnimationFrame(frame)
|
| 257 |
+
return () => {
|
| 258 |
+
cancelAnimationFrame(raf)
|
| 259 |
+
io.disconnect()
|
| 260 |
+
}
|
| 261 |
+
}, [layout, size, k, labels, index])
|
| 262 |
+
|
| 263 |
+
const hit = (e: React.PointerEvent) => {
|
| 264 |
+
if (!layout) return
|
| 265 |
+
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
|
| 266 |
+
const wx = (e.clientX - rect.left - size / 2) / k, wy = (e.clientY - rect.top - size / 2) / k
|
| 267 |
+
if (Math.hypot(wx, wy) < CENTER_R) return setHover(L.base)
|
| 268 |
+
const c = cur.current
|
| 269 |
+
let best = -1, bd = Infinity
|
| 270 |
+
for (let i = 0; i < layout.pos.length; i++) {
|
| 271 |
+
const d = Math.hypot(c[2 * i] - wx, c[2 * i + 1] - wy) - layout.pos[i].r
|
| 272 |
+
if (d < bd) { bd = d; best = i }
|
| 273 |
+
}
|
| 274 |
+
setHover(best >= 0 && bd < 10 / k ? layout.pos[best].id : null)
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
const present = ORDER.filter((r) => repos.some((x) => x.rel === r))
|
| 278 |
+
const center = hover === L.base
|
| 279 |
+
const hi = hover && !center ? index.get(hover) : undefined
|
| 280 |
+
const hp = hi != null ? layout!.pos[hi] : null
|
| 281 |
+
const hpos = hi != null ? { x: toPx(cur.current[2 * hi]), y: toPx(cur.current[2 * hi + 1]) } : null
|
| 282 |
+
const icon = Math.max(30, CENTER_R * k * 1.8)
|
| 283 |
+
|
| 284 |
+
return (
|
| 285 |
+
<div ref={stageRef} className="stage relative isolate overflow-hidden rounded-[28px] px-4 pt-8 pb-6 sm:px-8 sm:pt-10">
|
| 286 |
+
<div aria-hidden className="pointer-events-none absolute top-1/2 left-1/2 -z-10 size-[70%] -translate-x-1/2 -translate-y-1/2 rounded-full opacity-20 blur-[120px]"
|
| 287 |
+
style={{ background: `radial-gradient(circle, ${catTo(cat)}, transparent 70%)` }} />
|
| 288 |
+
<DownloadButton target={stageRef} name={`${name} galaxy`} tone="stage" className="absolute top-[26px] right-4 z-20 sm:top-[34px] sm:right-8" />
|
| 289 |
+
<RelLegend rels={present} className="pr-12 text-white/70" />
|
| 290 |
+
<div ref={box} className="w-full">
|
| 291 |
+
<div className="relative mx-auto select-none" style={{ width: size, height: size }}
|
| 292 |
+
onPointerMove={(e) => e.pointerType === "mouse" && hit(e)}
|
| 293 |
+
onPointerDown={(e) => { typeRef.current = e.pointerType; if (e.pointerType !== "mouse") { tapRef.current = hover; hit(e) } }}
|
| 294 |
+
onPointerLeave={(e) => e.pointerType === "mouse" && setHover(null)}
|
| 295 |
+
onClick={() => {
|
| 296 |
+
const touch = typeRef.current !== "mouse"
|
| 297 |
+
if (hover && (!touch || tapRef.current === hover)) window.open(hfUrl(hover), "_blank", "noopener")
|
| 298 |
+
}}
|
| 299 |
+
role="img" aria-label={`${full(L.n_models)} community models around ${name}`}>
|
| 300 |
+
{size > 0 && (
|
| 301 |
+
<div aria-hidden className="pointer-events-none absolute rounded-full blur-[30px]"
|
| 302 |
+
style={{ left: size / 2 - icon, top: size / 2 - icon, width: icon * 2, height: icon * 2,
|
| 303 |
+
background: `radial-gradient(circle, ${catTo(cat)}, ${catFrom(cat)} 45%, transparent 70%)`,
|
| 304 |
+
opacity: 0.8, animation: "breathe 4s ease-in-out infinite" }} />
|
| 305 |
+
)}
|
| 306 |
+
{/* the entrance turns the canvas as one composited layer */}
|
| 307 |
+
<div className="absolute inset-0" style={{ animation: "unfold 1500ms cubic-bezier(.22,.61,.36,1) both", transformOrigin: "50% 50%" }}>
|
| 308 |
+
<canvas ref={canvas} className="absolute inset-0" style={{ width: size, height: size }} />
|
| 309 |
+
</div>
|
| 310 |
+
{size > 0 && (
|
| 311 |
+
<div className="pointer-events-none absolute" title={name}
|
| 312 |
+
style={{ left: size / 2 - icon / 2, top: size / 2 - icon / 2, opacity: hover && !center ? 0.5 : 1,
|
| 313 |
+
animation: "pop 900ms cubic-bezier(.34,1.56,.64,1) 300ms both" }}>
|
| 314 |
+
<Octopus size={icon} />
|
| 315 |
+
</div>
|
| 316 |
+
)}
|
| 317 |
+
{layout?.rings.map((g) => size >= 480 && (
|
| 318 |
+
<span key={g.ring} className="pointer-events-none absolute -translate-x-1/2 rounded-full border border-white/10 bg-[var(--stage)] px-3 py-0.5 text-sm whitespace-nowrap text-white/60"
|
| 319 |
+
style={{ left: size / 2, top: toPx(-g.outer - 8) - 12, animation: "fade 600ms ease-out 900ms both" }}>
|
| 320 |
+
{RING_NAME[g.ring]}
|
| 321 |
+
</span>
|
| 322 |
+
))}
|
| 323 |
+
{!layout && size > 0 && (
|
| 324 |
+
<div className="absolute inset-0 grid place-items-center text-[15px] text-white/60">Placing {full(repos.length)} models…</div>
|
| 325 |
+
)}
|
| 326 |
+
{hover && (center || (hp && hpos)) && (
|
| 327 |
+
<Card pos={center ? { x: size / 2, y: size / 2, r: icon / 2 } : { x: hpos!.x, y: hpos!.y, r: hp!.r * k }} size={size}>
|
| 328 |
+
{center ? <Official L={L} authors={authors} kidsN={L.n_models} /> : <Model p={hp!} authors={authors} />}
|
| 329 |
+
</Card>
|
| 330 |
+
)}
|
| 331 |
+
</div>
|
| 332 |
+
</div>
|
| 333 |
+
</div>
|
| 334 |
+
)
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
function Card({ pos, size, children }: { pos: { x: number; y: number; r: number }; size: number; children: React.ReactNode }) {
|
| 338 |
+
const W = 300
|
| 339 |
+
const right = pos.x + pos.r + 14 + W < size
|
| 340 |
+
const left = right ? pos.x + pos.r + 14 : Math.max(0, pos.x - pos.r - 14 - W)
|
| 341 |
+
const top = Math.min(Math.max(0, pos.y - 70), size - 250)
|
| 342 |
+
return (
|
| 343 |
+
<div className="pointer-events-none absolute z-10 rounded-2xl border border-white/12 bg-[#15151c]/92 p-4 text-[15px] text-white shadow-[0_18px_40px_rgba(0,0,0,0.5)] backdrop-blur-md"
|
| 344 |
+
style={{ left, top, width: W }}>
|
| 345 |
+
{children}
|
| 346 |
+
</div>
|
| 347 |
+
)
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
function Row({ k, v }: { k: string; v: React.ReactNode }) {
|
| 351 |
+
return (
|
| 352 |
+
<div className="flex justify-between gap-4">
|
| 353 |
+
<span className="text-white/55">{k}</span>
|
| 354 |
+
<span className="text-right tabular-nums">{v}</span>
|
| 355 |
+
</div>
|
| 356 |
+
)
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
function Model({ p, authors }: { p: P; authors: Record<string, Author> }) {
|
| 360 |
+
const r = p.repo
|
| 361 |
+
const [owner, name] = r.id.split("/")
|
| 362 |
+
return (
|
| 363 |
+
<>
|
| 364 |
+
<div className="mb-3 flex items-center gap-3">
|
| 365 |
+
<Who name={owner} authors={authors} size="size-11" />
|
| 366 |
+
<div className="min-w-0">
|
| 367 |
+
<div className="font-semibold break-all leading-snug">{name}</div>
|
| 368 |
+
<div className="truncate text-white/55">{authors[owner]?.n ?? owner}</div>
|
| 369 |
+
</div>
|
| 370 |
+
</div>
|
| 371 |
+
<div className="space-y-1.5">
|
| 372 |
+
<Row k="Type" v={<span className="inline-flex items-center gap-2"><RelDot rel={r.rel} />{REL_NAME[r.rel]}</span>} />
|
| 373 |
+
<Row k="Built on" v={<span className="break-all">{r.up.startsWith("MiniMaxAI/") ? `${r.up.split("/")[1]} (official)` : r.up}</span>} />
|
| 374 |
+
<Row k="Downloads" v={fmt(r.dlall)} />
|
| 375 |
+
<Row k="Last 30 days" v={fmt(r.dl30)} />
|
| 376 |
+
<Row k="Likes" v={full(r.likes)} />
|
| 377 |
+
<Row k="Created" v={r.created ? mdy(r.created) : "–"} />
|
| 378 |
+
</div>
|
| 379 |
+
</>
|
| 380 |
+
)
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
function Official({ L, authors, kidsN }: { L: Lineage; authors: Record<string, Author>; kidsN: number }) {
|
| 384 |
+
return (
|
| 385 |
+
<>
|
| 386 |
+
<div className="mb-3 flex items-center gap-3">
|
| 387 |
+
<Who name="MiniMaxAI" authors={authors} size="size-11" />
|
| 388 |
+
<div className="min-w-0">
|
| 389 |
+
<div className="font-semibold">{L.base.split("/")[1]}</div>
|
| 390 |
+
<div className="text-white/55">MiniMax official</div>
|
| 391 |
+
</div>
|
| 392 |
+
</div>
|
| 393 |
+
<div className="space-y-1.5">
|
| 394 |
+
<Row k="Downloads" v={fmt(L.official.dlall)} />
|
| 395 |
+
<Row k="Last 30 days" v={fmt(L.official.dl30)} />
|
| 396 |
+
<Row k="Likes" v={full(L.official.likes)} />
|
| 397 |
+
<Row k="Community models" v={full(kidsN)} />
|
| 398 |
+
</div>
|
| 399 |
+
</>
|
| 400 |
+
)
|
| 401 |
+
}
|
code/web/src/components/growth.tsx
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useMemo, useState } from "react"
|
| 2 |
+
import { Bar, BarChart, CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"
|
| 3 |
+
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/ui/chart"
|
| 4 |
+
import { REL_NAME, type Lineage, type Rel } from "@/lib/types"
|
| 5 |
+
import { relConfig, RelLegend, axisTick } from "@/components/rel"
|
| 6 |
+
import { md } from "@/lib/format"
|
| 7 |
+
|
| 8 |
+
const day = (d: Date) => d.toISOString().slice(0, 10)
|
| 9 |
+
const addDays = (s: string, n: number) => {
|
| 10 |
+
const d = new Date(s + "T00:00:00Z")
|
| 11 |
+
d.setUTCDate(d.getUTCDate() + n)
|
| 12 |
+
return day(d)
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/** Running total of each kind of derivative, from the creation dates (full history). */
|
| 16 |
+
export function GrowthLines({ L, rel, today }: { L: Lineage; rel: Rel[]; today: string }) {
|
| 17 |
+
const { rows, present } = useMemo(() => {
|
| 18 |
+
const present = rel.filter((r) => L.by_relation[r].n > 0)
|
| 19 |
+
if (!L.growth.length) return { rows: [], present }
|
| 20 |
+
const byDate = new Map<string, Partial<Record<Rel, number>>>()
|
| 21 |
+
for (const g of L.growth) {
|
| 22 |
+
const m = byDate.get(g.date) ?? {}
|
| 23 |
+
m[g.rel] = (m[g.rel] ?? 0) + g.n
|
| 24 |
+
byDate.set(g.date, m)
|
| 25 |
+
}
|
| 26 |
+
const start = [...byDate.keys()].sort()[0]
|
| 27 |
+
const run: Record<string, number> = Object.fromEntries(present.map((r) => [r, 0]))
|
| 28 |
+
const rows: Record<string, string | number>[] = []
|
| 29 |
+
for (let d = start; d <= today; d = addDays(d, 1)) {
|
| 30 |
+
for (const [r, n] of Object.entries(byDate.get(d) ?? {})) run[r] = (run[r] ?? 0) + n
|
| 31 |
+
rows.push({ date: d, ...run })
|
| 32 |
+
}
|
| 33 |
+
// Long histories are drawn from one point a week, which keeps the curves smooth.
|
| 34 |
+
const step = rows.length > 90 ? 7 : 1
|
| 35 |
+
const thin = rows.filter((_, i) => i % step === 0 || i === rows.length - 1)
|
| 36 |
+
return { rows: thin, present }
|
| 37 |
+
}, [L, rel, today])
|
| 38 |
+
const [hidden, setHidden] = useState<Set<Rel>>(new Set())
|
| 39 |
+
const toggle = (r: Rel) => setHidden((h) => { const n = new Set(h); if (n.has(r)) n.delete(r); else n.add(r); return n })
|
| 40 |
+
|
| 41 |
+
return (
|
| 42 |
+
<>
|
| 43 |
+
<RelLegend rels={present} hidden={hidden} onToggle={toggle} />
|
| 44 |
+
<ChartContainer config={relConfig(present)} className="aspect-auto h-[320px] w-full">
|
| 45 |
+
<LineChart data={rows} margin={{ left: 4, right: 12, top: 8 }}>
|
| 46 |
+
<CartesianGrid vertical={false} />
|
| 47 |
+
<XAxis dataKey="date" tickLine={false} axisLine={false} tick={axisTick} tickFormatter={md} minTickGap={48} />
|
| 48 |
+
<YAxis tickLine={false} axisLine={false} tick={axisTick} width={44} />
|
| 49 |
+
<ChartTooltip content={<ChartTooltipContent labelFormatter={(v) => md(String(v))} />} />
|
| 50 |
+
{present.filter((r) => !hidden.has(r)).map((r) => (
|
| 51 |
+
<Line key={r} dataKey={r} name={REL_NAME[r]} type="monotone" stroke={`var(--color-${r})`}
|
| 52 |
+
strokeWidth={2} dot={false} animationDuration={900} animationEasing="ease-out" />
|
| 53 |
+
))}
|
| 54 |
+
</LineChart>
|
| 55 |
+
</ChartContainer>
|
| 56 |
+
</>
|
| 57 |
+
)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/** New derivatives per finished week (Monday start); the current week would read as a drop. */
|
| 61 |
+
export function WeeklyBars({ L, today, color = "var(--brand)" }: { L: Lineage; today: string; color?: string }) {
|
| 62 |
+
const rows = useMemo(() => {
|
| 63 |
+
const monday = (s: string) => {
|
| 64 |
+
const d = new Date(s + "T00:00:00Z")
|
| 65 |
+
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 6) % 7))
|
| 66 |
+
return day(d)
|
| 67 |
+
}
|
| 68 |
+
const weeks = new Map<string, number>()
|
| 69 |
+
for (const g of L.growth) weeks.set(monday(g.date), (weeks.get(monday(g.date)) ?? 0) + g.n)
|
| 70 |
+
const keys = [...weeks.keys()].sort()
|
| 71 |
+
const end = monday(today)
|
| 72 |
+
const out: { week: string; n: number }[] = []
|
| 73 |
+
for (let w = keys[0]; w && w < end; w = addDays(w, 7)) out.push({ week: w, n: weeks.get(w) ?? 0 })
|
| 74 |
+
return out
|
| 75 |
+
}, [L, today])
|
| 76 |
+
const config = { n: { label: "New", color } } satisfies ChartConfig
|
| 77 |
+
const weekMax = Math.max(1, ...rows.map((r) => r.n))
|
| 78 |
+
const step = weekMax > 200 ? 100 : weekMax > 60 ? 50 : weekMax > 20 ? 10 : 5
|
| 79 |
+
|
| 80 |
+
return (
|
| 81 |
+
<ChartContainer config={config} className="aspect-auto h-[356px] w-full">
|
| 82 |
+
<BarChart data={rows} margin={{ left: 4, right: 4, top: 8 }}>
|
| 83 |
+
<CartesianGrid vertical={false} />
|
| 84 |
+
<XAxis dataKey="week" tickLine={false} axisLine={false} tick={axisTick} tickFormatter={md} minTickGap={40} />
|
| 85 |
+
<YAxis tickLine={false} axisLine={false} tick={axisTick} width={36} allowDecimals={false}
|
| 86 |
+
domain={[0, (max: number) => Math.ceil(max / step) * step]} tickCount={Math.max(2, Math.ceil(weekMax / step) + 1)} />
|
| 87 |
+
<ChartTooltip cursor={{ fill: "var(--muted)" }}
|
| 88 |
+
content={<ChartTooltipContent labelFormatter={(v) => `Week of ${md(String(v))}`} />} />
|
| 89 |
+
<Bar dataKey="n" fill="var(--color-n)" radius={[4, 4, 0, 0]} maxBarSize={22} animationDuration={900} animationEasing="ease-out" />
|
| 90 |
+
</BarChart>
|
| 91 |
+
</ChartContainer>
|
| 92 |
+
)
|
| 93 |
+
}
|
code/web/src/components/layout.tsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useRef, useState } from "react"
|
| 2 |
+
import { catColor } from "@/lib/category"
|
| 3 |
+
import { DownloadButton } from "@/components/download-button"
|
| 4 |
+
|
| 5 |
+
export function Section({ title, children, className = "" }: { title?: string; children: React.ReactNode; className?: string }) {
|
| 6 |
+
return (
|
| 7 |
+
<section className={`mt-24 ${className}`}>
|
| 8 |
+
{title && <h2 className="mb-8 font-display text-[30px] leading-tight font-semibold tracking-[-0.01em] sm:text-[34px]">{title}</h2>}
|
| 9 |
+
{children}
|
| 10 |
+
</section>
|
| 11 |
+
)
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/** A card. With `download` (the file name) it gets a download button in its top right corner. */
|
| 15 |
+
export function Panel({ title, download, children }: { title?: string; download?: string; children: React.ReactNode }) {
|
| 16 |
+
const ref = useRef<HTMLDivElement>(null)
|
| 17 |
+
if (!download)
|
| 18 |
+
return (
|
| 19 |
+
<div className="min-w-0 rounded-[20px] border border-border bg-card p-5 sm:p-8">
|
| 20 |
+
{title && <h3 className="mb-6 text-lg font-medium">{title}</h3>}
|
| 21 |
+
{children}
|
| 22 |
+
</div>
|
| 23 |
+
)
|
| 24 |
+
return (
|
| 25 |
+
<div ref={ref} className="relative min-w-0 rounded-[20px] border border-border bg-card p-5 sm:p-8">
|
| 26 |
+
{title ? (
|
| 27 |
+
<div className="mb-6 flex items-center justify-between gap-4">
|
| 28 |
+
<h3 className="text-lg font-medium">{title}</h3>
|
| 29 |
+
<DownloadButton target={ref} name={download} />
|
| 30 |
+
</div>
|
| 31 |
+
) : (
|
| 32 |
+
// level with the legend row; the legend leaves room for it
|
| 33 |
+
<DownloadButton target={ref} name={download} className="absolute top-3.5 right-5 sm:top-[26px] sm:right-8" />
|
| 34 |
+
)}
|
| 35 |
+
<div className={title ? undefined : "[&>:first-child]:pr-12"}>{children}</div>
|
| 36 |
+
</div>
|
| 37 |
+
)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/** Soft colour light behind the dark stage; `cats` picks the hues. */
|
| 41 |
+
export function Glow({ cats }: { cats: string[] }) {
|
| 42 |
+
const spots = [
|
| 43 |
+
{ left: "62%", top: "-18%", size: 620, o: 0.42 },
|
| 44 |
+
{ left: "-12%", top: "8%", size: 520, o: 0.3 },
|
| 45 |
+
{ left: "30%", top: "46%", size: 560, o: 0.22 },
|
| 46 |
+
{ left: "84%", top: "52%", size: 420, o: 0.2 },
|
| 47 |
+
]
|
| 48 |
+
return (
|
| 49 |
+
<div aria-hidden className="pointer-events-none absolute inset-0 -z-10 overflow-hidden">
|
| 50 |
+
{spots.map((s, i) => (
|
| 51 |
+
<div key={i} className="absolute rounded-full blur-[120px]"
|
| 52 |
+
style={{ left: s.left, top: s.top, width: s.size, height: s.size, opacity: s.o,
|
| 53 |
+
background: catColor(cats[i % cats.length]) }} />
|
| 54 |
+
))}
|
| 55 |
+
<div className="absolute inset-0 bg-[radial-gradient(rgba(255,255,255,0.07)_1px,transparent_1px)] [background-size:28px_28px] [mask-image:linear-gradient(180deg,#000,transparent_85%)]" />
|
| 56 |
+
</div>
|
| 57 |
+
)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/** A number that counts up once when it first appears. */
|
| 61 |
+
export function CountUp({ value, format, ms = 1600 }: { value: number; format: (n: number) => string; ms?: number }) {
|
| 62 |
+
const [v, setV] = useState(0)
|
| 63 |
+
const done = useRef(false)
|
| 64 |
+
useEffect(() => {
|
| 65 |
+
if (done.current || matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
| 66 |
+
setV(value)
|
| 67 |
+
return
|
| 68 |
+
}
|
| 69 |
+
done.current = true
|
| 70 |
+
let raf = 0
|
| 71 |
+
const t0 = performance.now()
|
| 72 |
+
const tick = (t: number) => {
|
| 73 |
+
const p = Math.min(1, (t - t0) / ms)
|
| 74 |
+
setV(value * (1 - Math.pow(1 - p, 3)))
|
| 75 |
+
if (p < 1) raf = requestAnimationFrame(tick)
|
| 76 |
+
}
|
| 77 |
+
raf = requestAnimationFrame(tick)
|
| 78 |
+
return () => cancelAnimationFrame(raf)
|
| 79 |
+
}, [value, ms])
|
| 80 |
+
return <>{format(v)}</>
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/** Big value over its label, for the stat rows on the stage. */
|
| 84 |
+
export function Stat({ value, label }: { value: React.ReactNode; label: string }) {
|
| 85 |
+
return (
|
| 86 |
+
<div className="min-w-0">
|
| 87 |
+
<div className="font-display text-[34px] leading-none font-semibold tracking-[-0.02em] text-white tabular-nums sm:text-[44px]">{value}</div>
|
| 88 |
+
<div className="mt-2.5 text-[15px] text-white/60 sm:text-base">{label}</div>
|
| 89 |
+
</div>
|
| 90 |
+
)
|
| 91 |
+
}
|
code/web/src/components/model-table.tsx
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useMemo, useState } from "react"
|
| 2 |
+
import { ArrowDown, ArrowUp, Search } from "lucide-react"
|
| 3 |
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
| 4 |
+
import { Input } from "@/components/ui/input"
|
| 5 |
+
import { Button } from "@/components/ui/button"
|
| 6 |
+
import { REL_NAME, type Author, type Repo } from "@/lib/types"
|
| 7 |
+
import { num as fmt, hfUrl } from "@/lib/format"
|
| 8 |
+
import { RelDot } from "@/components/rel"
|
| 9 |
+
import { Who } from "@/components/who"
|
| 10 |
+
|
| 11 |
+
type Key = "id" | "rel" | "dl30" | "dlall" | "d1"
|
| 12 |
+
|
| 13 |
+
export function ModelTable({ repos, authors, hasDaily }: { repos: Repo[]; authors: Record<string, Author>; hasDaily: boolean }) {
|
| 14 |
+
const [q, setQ] = useState("")
|
| 15 |
+
const [sort, setSort] = useState<{ k: Key; dir: 1 | -1 }>({ k: "dl30", dir: -1 })
|
| 16 |
+
const [shown, setShown] = useState(20)
|
| 17 |
+
|
| 18 |
+
const rows = useMemo(() => {
|
| 19 |
+
const s = q.trim().toLowerCase()
|
| 20 |
+
const list = s ? repos.filter((r) => r.id.toLowerCase().includes(s)) : repos
|
| 21 |
+
return [...list].sort((a, b) => {
|
| 22 |
+
const x = a[sort.k], y = b[sort.k]
|
| 23 |
+
if (x == null || y == null) return (x == null ? 1 : 0) - (y == null ? 1 : 0)
|
| 24 |
+
return (x < y ? -1 : x > y ? 1 : 0) * sort.dir
|
| 25 |
+
})
|
| 26 |
+
}, [repos, q, sort])
|
| 27 |
+
|
| 28 |
+
const cols: [Key, string, boolean][] = [
|
| 29 |
+
["id", "Model", false], ["rel", "Type", false], ["dl30", "30 days", true], ["dlall", "All-time", true],
|
| 30 |
+
...(hasDaily ? ([["d1", "Last day", true]] as [Key, string, boolean][]) : []),
|
| 31 |
+
]
|
| 32 |
+
const head = (k: Key, label: string, num: boolean) => (
|
| 33 |
+
<TableHead key={k} className={`h-11 text-[15px] ${num ? "text-right" : ""}`}>
|
| 34 |
+
<button className={`inline-flex items-center gap-1 text-muted-foreground hover:text-foreground ${sort.k === k ? "text-foreground" : ""}`}
|
| 35 |
+
onClick={() => setSort((s) => ({ k, dir: s.k === k ? (-s.dir as 1 | -1) : -1 }))}>
|
| 36 |
+
{label}
|
| 37 |
+
{sort.k === k && (sort.dir < 0 ? <ArrowDown className="size-4" /> : <ArrowUp className="size-4" />)}
|
| 38 |
+
</button>
|
| 39 |
+
</TableHead>
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
return (
|
| 43 |
+
<div>
|
| 44 |
+
<div className="relative mb-4 max-w-sm">
|
| 45 |
+
<Search className="pointer-events-none absolute top-1/2 left-3.5 size-4 -translate-y-1/2 text-muted-foreground" />
|
| 46 |
+
<Input value={q} onChange={(e) => { setQ(e.target.value); setShown(20) }} placeholder="Search models or builders"
|
| 47 |
+
className="h-11 rounded-full pl-10 text-[15px]" aria-label="Search models or builders" />
|
| 48 |
+
</div>
|
| 49 |
+
<Table className="text-[15px]">
|
| 50 |
+
<TableHeader>
|
| 51 |
+
<TableRow className="border-border/60 hover:bg-transparent">{cols.map(([k, l, n]) => head(k, l, n))}</TableRow>
|
| 52 |
+
</TableHeader>
|
| 53 |
+
<TableBody>
|
| 54 |
+
{rows.slice(0, shown).map((r) => {
|
| 55 |
+
const [owner, name] = r.id.split("/")
|
| 56 |
+
return (
|
| 57 |
+
<TableRow key={r.id} className="border-border/60">
|
| 58 |
+
<TableCell className="py-3">
|
| 59 |
+
<a href={hfUrl(r.id)} target="_blank" rel="noopener" className="flex min-w-0 items-center gap-3 hover:underline">
|
| 60 |
+
<Who name={owner} authors={authors} size="size-7" />
|
| 61 |
+
<span className="max-w-[min(52vw,520px)] truncate" title={r.id}>
|
| 62 |
+
<span className="text-muted-foreground">{owner}/</span>{name}
|
| 63 |
+
</span>
|
| 64 |
+
</a>
|
| 65 |
+
</TableCell>
|
| 66 |
+
<TableCell className="py-3 whitespace-nowrap">
|
| 67 |
+
<span className="inline-flex items-center gap-2"><RelDot rel={r.rel} />{REL_NAME[r.rel]}</span>
|
| 68 |
+
</TableCell>
|
| 69 |
+
<TableCell className="py-3 text-right tabular-nums">{fmt(r.dl30)}</TableCell>
|
| 70 |
+
<TableCell className="py-3 text-right tabular-nums">{fmt(r.dlall)}</TableCell>
|
| 71 |
+
{hasDaily && <TableCell className="py-3 text-right tabular-nums">{fmt(r.d1)}</TableCell>}
|
| 72 |
+
</TableRow>
|
| 73 |
+
)
|
| 74 |
+
})}
|
| 75 |
+
</TableBody>
|
| 76 |
+
</Table>
|
| 77 |
+
{rows.length > shown && (
|
| 78 |
+
<div className="mt-5 flex justify-center">
|
| 79 |
+
<Button variant="secondary" className="h-10 rounded-full px-6 text-[15px]" onClick={() => setShown((n) => n + 50)}>
|
| 80 |
+
Show 50 more
|
| 81 |
+
</Button>
|
| 82 |
+
</div>
|
| 83 |
+
)}
|
| 84 |
+
</div>
|
| 85 |
+
)
|
| 86 |
+
}
|
code/web/src/components/octopus.tsx
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MiniMax Code octopus (the mark at the top left of code.minimax.cn), white on the dark
|
| 3 |
+
* stage as it is there. It bobs and gently squashes like it is breathing; with reduced motion it
|
| 4 |
+
* stands still. The glow behind it, in the modality's colour, is drawn by the galaxy.
|
| 5 |
+
*/
|
| 6 |
+
const PATH =
|
| 7 |
+
"M26.1139 4.97856C27.0309 5.3238 27.9237 4.03738 26.646 3.1182C24.6317 1.66905 23.1936 2.46289 22.4987 3.03243C22.4723 3.05442 21.7246 2.46069 21.2277 2.15283C19.6422 1.16987 17.8984 0.470588 16.0578 0.178119C15.3585 0.0681688 14.6526 0.0131941 13.9467 0V0.00879121C13.0364 -0.00880087 12.1238 0.048375 11.2244 0.189112C9.3838 0.479381 7.63998 1.17867 6.0545 2.16383C5.55532 2.47389 4.80986 3.06542 4.78347 3.04343C4.08858 2.47169 2.64823 1.67784 0.636135 3.12919C-0.64149 4.04837 0.251308 5.337 1.1683 4.98956C1.79941 4.75206 2.60645 4.16712 3.20898 4.64431C1.53113 6.70258 0.526185 9.31941 0.526185 12.1693C0.526185 15.0192 1.46076 17.4491 3.03086 19.47L2.77797 19.6658C1.22987 20.8686 0.957189 23.083 2.16664 24.6201C3.3739 26.155 5.6103 26.4255 7.1562 25.2271L8.87582 23.8922C9.06274 23.7471 9.28264 23.7075 9.48495 23.7493C9.51134 23.7559 9.53773 23.7625 9.56412 23.7691C9.85439 23.8615 10.0853 24.1253 10.0853 24.475C10.0853 26.4189 11.6708 27.9934 13.6301 28H13.6477C15.607 27.9934 17.1947 26.4189 17.1925 24.475C17.1925 24.1319 17.4146 23.8725 17.6961 23.7757C17.7334 23.7669 17.7708 23.7559 17.8082 23.7471C18.0039 23.7119 18.2172 23.7537 18.3997 23.8945L20.1194 25.2292C21.6653 26.4299 23.9017 26.1572 25.1089 24.6245C26.3184 23.0874 26.0457 20.873 24.4976 19.6701L24.2491 19.4744C25.0539 18.4365 25.6917 17.2666 26.1227 16C26.1315 15.9736 26.1403 15.9472 26.1491 15.9208C26.1886 15.8021 26.2282 15.6811 26.2634 15.5602C26.281 15.5008 26.2964 15.4414 26.314 15.3821C26.3382 15.2919 26.3646 15.2018 26.3887 15.1116C26.4151 15.0104 26.4371 14.9093 26.4613 14.8081C26.4723 14.7576 26.4855 14.707 26.4965 14.6542C26.668 13.8494 26.7604 13.0159 26.7604 12.1605C26.7604 9.31061 25.7554 6.69159 24.0776 4.63551C24.6801 4.15613 25.4872 4.74107 26.1183 4.98076L26.1139 4.97856Z"
|
| 8 |
+
|
| 9 |
+
export function Octopus({ size }: { size: number }) {
|
| 10 |
+
return (
|
| 11 |
+
<svg width={size} height={size * (28 / 27.2822)} viewBox="0 0 27.2822 28" aria-hidden className="overflow-visible"
|
| 12 |
+
style={{ animation: "octo-swim 3.6s ease-in-out infinite", transformOrigin: "50% 60%" }}>
|
| 13 |
+
<path d={PATH} fill="#fff" fillOpacity={0.96} />
|
| 14 |
+
</svg>
|
| 15 |
+
)
|
| 16 |
+
}
|
code/web/src/components/rel.tsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { ChartConfig } from "@/components/ui/chart"
|
| 2 |
+
import { REL_NAME, type Rel } from "@/lib/types"
|
| 3 |
+
|
| 4 |
+
/** Each relation keeps one colour everywhere on the page (defined in index.css). */
|
| 5 |
+
export const relColor = (r: Rel | "official") => (r === "official" ? "var(--foreground)" : `var(--rel-${r})`)
|
| 6 |
+
|
| 7 |
+
export const relConfig = (rels: Rel[]): ChartConfig =>
|
| 8 |
+
Object.fromEntries(rels.map((r) => [r, { label: REL_NAME[r], color: relColor(r) }]))
|
| 9 |
+
|
| 10 |
+
export const axisTick = { fontSize: 14, fill: "var(--muted-foreground)" }
|
| 11 |
+
|
| 12 |
+
export function RelDot({ rel, className = "" }: { rel: Rel | "official"; className?: string }) {
|
| 13 |
+
return <span className={`inline-block size-2.5 shrink-0 rounded-full ${className}`} style={{ background: relColor(rel) }} />
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/** Legend; pass `hidden` and `onToggle` to let people switch series off (the axis rescales). */
|
| 17 |
+
export function RelLegend({ rels, hidden, onToggle, className = "text-muted-foreground" }: {
|
| 18 |
+
rels: Rel[]; hidden?: Set<Rel>; onToggle?: (r: Rel) => void; className?: string
|
| 19 |
+
}) {
|
| 20 |
+
return (
|
| 21 |
+
<div className={`mb-4 flex flex-wrap gap-x-5 gap-y-2 text-[15px] ${className}`}>
|
| 22 |
+
{rels.map((r) => {
|
| 23 |
+
const off = hidden?.has(r)
|
| 24 |
+
const body = (
|
| 25 |
+
<>
|
| 26 |
+
<span className={`inline-block size-2.5 shrink-0 rounded-full ${off ? "border border-muted-foreground" : ""}`}
|
| 27 |
+
style={{ background: off ? "transparent" : relColor(r) }} />
|
| 28 |
+
<span className={off ? "line-through opacity-60" : ""}>{REL_NAME[r]}</span>
|
| 29 |
+
</>
|
| 30 |
+
)
|
| 31 |
+
return onToggle ? (
|
| 32 |
+
<button key={r} type="button" aria-pressed={!off} onClick={() => onToggle(r)}
|
| 33 |
+
className="inline-flex items-center gap-2 rounded-md hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">
|
| 34 |
+
{body}
|
| 35 |
+
</button>
|
| 36 |
+
) : (
|
| 37 |
+
<span key={r} className="inline-flex items-center gap-2">{body}</span>
|
| 38 |
+
)
|
| 39 |
+
})}
|
| 40 |
+
</div>
|
| 41 |
+
)
|
| 42 |
+
}
|
code/web/src/components/relation-table.tsx
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
| 2 |
+
import { HF_RELS, REL_NAME, type Lineage, type Rel } from "@/lib/types"
|
| 3 |
+
import { num as fmt, full } from "@/lib/format"
|
| 4 |
+
import { RelDot, relColor } from "@/components/rel"
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Community models by type next to what Hugging Face's model tree shows. HF has only four types,
|
| 8 |
+
* so those come first with their own subtotal; the types HF has no place for follow, then the
|
| 9 |
+
* total. Types with nothing in them are left out.
|
| 10 |
+
*/
|
| 11 |
+
export function RelationTable({ L, order }: { L: Lineage; order: Rel[] }) {
|
| 12 |
+
const b = L.by_relation
|
| 13 |
+
const hfRels = HF_RELS.filter((r) => b[r].n > 0 || (L.hf_tree[r] ?? 0) > 0)
|
| 14 |
+
const extra = order.filter((r) => !HF_RELS.includes(r) && b[r].n > 0)
|
| 15 |
+
const max = Math.max(...order.map((r) => b[r].n))
|
| 16 |
+
const sum = (rs: Rel[], k: "n" | "dl30" | "dlall") => rs.reduce((a, r) => a + b[r][k], 0)
|
| 17 |
+
const hfSum = HF_RELS.reduce((a, r) => a + (L.hf_tree[r] ?? 0), 0)
|
| 18 |
+
|
| 19 |
+
const row = (r: Rel) => (
|
| 20 |
+
<TableRow key={r} className="border-border/60 hover:bg-transparent">
|
| 21 |
+
<TableCell className="py-3.5">
|
| 22 |
+
<span className="inline-flex items-center gap-2.5"><RelDot rel={r} />{REL_NAME[r]}</span>
|
| 23 |
+
</TableCell>
|
| 24 |
+
<TableCell className="py-3.5">
|
| 25 |
+
<div className="flex items-center gap-3">
|
| 26 |
+
<span className="w-14 text-right font-display font-semibold tabular-nums">{full(b[r].n)}</span>
|
| 27 |
+
<span className="hidden h-2 rounded-full sm:block" style={{ width: `${(b[r].n / max) * 160}px`, background: relColor(r) }} />
|
| 28 |
+
</div>
|
| 29 |
+
</TableCell>
|
| 30 |
+
<TableCell className="py-3.5 text-right tabular-nums">{HF_RELS.includes(r) ? full(L.hf_tree[r] ?? 0) : "—"}</TableCell>
|
| 31 |
+
<TableCell className="py-3.5 text-right tabular-nums">{fmt(b[r].dl30)}</TableCell>
|
| 32 |
+
<TableCell className="py-3.5 text-right tabular-nums">{fmt(b[r].dlall)}</TableCell>
|
| 33 |
+
</TableRow>
|
| 34 |
+
)
|
| 35 |
+
const total = (label: string, n: number, hf: number | null, d30: number, da: number) => (
|
| 36 |
+
<TableRow className="border-border/60 font-semibold hover:bg-transparent">
|
| 37 |
+
<TableCell className="py-3.5">{label}</TableCell>
|
| 38 |
+
<TableCell className="py-3.5"><span className="inline-block w-14 text-right font-display tabular-nums">{full(n)}</span></TableCell>
|
| 39 |
+
<TableCell className="py-3.5 text-right tabular-nums">{hf == null ? "—" : full(hf)}</TableCell>
|
| 40 |
+
<TableCell className="py-3.5 text-right tabular-nums">{fmt(d30)}</TableCell>
|
| 41 |
+
<TableCell className="py-3.5 text-right tabular-nums">{fmt(da)}</TableCell>
|
| 42 |
+
</TableRow>
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
return (
|
| 46 |
+
<Table className="text-[15px]">
|
| 47 |
+
<TableHeader>
|
| 48 |
+
<TableRow className="border-border/60 hover:bg-transparent">
|
| 49 |
+
<TableHead className="text-[15px] text-muted-foreground">Type</TableHead>
|
| 50 |
+
<TableHead className="text-[15px] text-muted-foreground">Models</TableHead>
|
| 51 |
+
<TableHead className="text-right text-[15px] text-muted-foreground">On HF model tree</TableHead>
|
| 52 |
+
<TableHead className="text-right text-[15px] text-muted-foreground">Downloads, 30 days</TableHead>
|
| 53 |
+
<TableHead className="text-right text-[15px] text-muted-foreground">All-time</TableHead>
|
| 54 |
+
</TableRow>
|
| 55 |
+
</TableHeader>
|
| 56 |
+
<TableBody>
|
| 57 |
+
{hfRels.map(row)}
|
| 58 |
+
{extra.length > 0 && total("Subtotal", sum(HF_RELS, "n"), hfSum, sum(HF_RELS, "dl30"), sum(HF_RELS, "dlall"))}
|
| 59 |
+
{extra.map(row)}
|
| 60 |
+
{total("Total", L.n_models, extra.length ? null : hfSum, L.dl30, L.dlall)}
|
| 61 |
+
</TableBody>
|
| 62 |
+
</Table>
|
| 63 |
+
)
|
| 64 |
+
}
|
code/web/src/components/release-rail.tsx
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useRef, useState } from "react"
|
| 2 |
+
import { ArrowLeft, ArrowRight, ArrowUpRight } from "lucide-react"
|
| 3 |
+
import type { Release, Site } from "@/lib/types"
|
| 4 |
+
import { catColor } from "@/lib/category"
|
| 5 |
+
import { full, hfUrl, mdy, num } from "@/lib/format"
|
| 6 |
+
import { href } from "@/lib/route"
|
| 7 |
+
import { Spark } from "@/components/sparkline"
|
| 8 |
+
|
| 9 |
+
/** Every open release in order, as cards: when, what, and the community it has today. */
|
| 10 |
+
export function ReleaseRail({ site }: { site: Site }) {
|
| 11 |
+
const rail = useRef<HTMLOListElement>(null)
|
| 12 |
+
const [edge, setEdge] = useState({ start: true, end: false })
|
| 13 |
+
const rels = [...site.releases].sort((a, b) => a.date.localeCompare(b.date))
|
| 14 |
+
const catName = (k: string) => site.categories.find((c) => c.key === k)?.name ?? k
|
| 15 |
+
|
| 16 |
+
const sync = () => {
|
| 17 |
+
const el = rail.current
|
| 18 |
+
if (!el) return
|
| 19 |
+
setEdge({ start: el.scrollLeft < 8, end: el.scrollLeft + el.clientWidth > el.scrollWidth - 8 })
|
| 20 |
+
}
|
| 21 |
+
useEffect(() => {
|
| 22 |
+
const el = rail.current
|
| 23 |
+
if (!el) return
|
| 24 |
+
el.scrollLeft = el.scrollWidth // newest in view; history is a scroll away
|
| 25 |
+
sync()
|
| 26 |
+
}, [])
|
| 27 |
+
const page = (dir: number) => rail.current?.scrollBy({ left: dir * rail.current.clientWidth * 0.8, behavior: "smooth" })
|
| 28 |
+
|
| 29 |
+
return (
|
| 30 |
+
<div className="relative mx-auto w-full max-w-[1200px] px-4 pb-16 sm:px-8 sm:pb-20">
|
| 31 |
+
<div className="mb-6 flex items-end justify-between gap-4">
|
| 32 |
+
<h2 className="font-display text-[30px] leading-tight font-semibold tracking-[-0.01em] text-white sm:text-[34px]">Every release</h2>
|
| 33 |
+
<div className="hidden gap-2 sm:flex">
|
| 34 |
+
{[-1, 1].map((d) => (
|
| 35 |
+
<button key={d} type="button" onClick={() => page(d)} disabled={d < 0 ? edge.start : edge.end}
|
| 36 |
+
aria-label={d < 0 ? "Earlier releases" : "Later releases"}
|
| 37 |
+
className="grid size-10 place-items-center rounded-full border border-white/15 text-white transition-colors hover:bg-white/10 disabled:opacity-30">
|
| 38 |
+
{d < 0 ? <ArrowLeft className="size-4" /> : <ArrowRight className="size-4" />}
|
| 39 |
+
</button>
|
| 40 |
+
))}
|
| 41 |
+
</div>
|
| 42 |
+
</div>
|
| 43 |
+
<ol ref={rail} onScroll={sync}
|
| 44 |
+
className="-mx-4 flex snap-x snap-mandatory scroll-px-4 gap-3 overflow-x-auto scroll-smooth px-4 pb-2 [scrollbar-width:none] sm:-mx-8 sm:scroll-px-8 sm:px-8 [&::-webkit-scrollbar]:hidden"
|
| 45 |
+
style={{ maskImage: `linear-gradient(90deg, ${edge.start ? "#000" : "transparent"}, #000 48px, #000 calc(100% - 48px), ${edge.end ? "#000" : "transparent"})` }}>
|
| 46 |
+
{rels.map((r, i) => <Card key={r.key} r={r} cat={catName(r.cat)} today={site.today} i={i} />)}
|
| 47 |
+
</ol>
|
| 48 |
+
</div>
|
| 49 |
+
)
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
function Card({ r, cat, today, i }: { r: Release; cat: string; today: string; i: number }) {
|
| 53 |
+
const external = !r.page
|
| 54 |
+
return (
|
| 55 |
+
<li className="w-[264px] shrink-0 snap-start" style={{ animation: `rise 600ms cubic-bezier(.22,.61,.36,1) ${120 + i * 40}ms both` }}>
|
| 56 |
+
<a href={external ? hfUrl(r.base) : href(r.cat, r.key)} target={external ? "_blank" : undefined} rel={external ? "noopener" : undefined}
|
| 57 |
+
className="group relative flex h-full flex-col overflow-hidden rounded-[20px] border border-white/10 bg-white/[0.04] backdrop-blur transition-[border-color,background-color,transform] duration-200 ease-[cubic-bezier(.22,.61,.36,1)] hover:-translate-y-0.5 hover:border-white/25 hover:bg-white/[0.07]">
|
| 58 |
+
<div className="p-5 pb-3">
|
| 59 |
+
<div className="flex items-center justify-between gap-3 text-[15px] text-white/55">
|
| 60 |
+
<span>{mdy(r.date)}</span>
|
| 61 |
+
<span className="inline-flex items-center gap-1.5">
|
| 62 |
+
<span className="size-2 rounded-full" style={{ background: catColor(r.cat) }} />{cat}
|
| 63 |
+
</span>
|
| 64 |
+
</div>
|
| 65 |
+
<div className="mt-2 flex items-start justify-between gap-2">
|
| 66 |
+
<span className="font-display text-[22px] leading-tight font-semibold text-white">{r.name}</span>
|
| 67 |
+
{external && <ArrowUpRight className="mt-1 size-4 shrink-0 text-white/40" />}
|
| 68 |
+
</div>
|
| 69 |
+
<div className="mt-4 grid grid-cols-2 gap-3">
|
| 70 |
+
<div>
|
| 71 |
+
<div className="font-display text-[22px] leading-none font-semibold text-white tabular-nums">{full(r.n)}</div>
|
| 72 |
+
<div className="mt-1.5 text-[15px] text-white/55">community</div>
|
| 73 |
+
</div>
|
| 74 |
+
<div>
|
| 75 |
+
<div className="font-display text-[22px] leading-none font-semibold text-white tabular-nums">{num(r.official.dlall)}</div>
|
| 76 |
+
<div className="mt-1.5 text-[15px] text-white/55">downloads</div>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
</div>
|
| 80 |
+
<div className="mt-auto">
|
| 81 |
+
<Spark events={r.growth} from={r.date} to={today} cat={r.cat} height={56} ring="var(--stage)" />
|
| 82 |
+
</div>
|
| 83 |
+
</a>
|
| 84 |
+
</li>
|
| 85 |
+
)
|
| 86 |
+
}
|
code/web/src/components/segmented.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** Two-way switch on the dark stage: a white pill slides under the chosen option. */
|
| 2 |
+
export function Segmented<T extends string>({ value, options, onChange, label }: {
|
| 3 |
+
value: T; options: [{ value: T; label: string }, { value: T; label: string }]; onChange: (v: T) => void; label: string
|
| 4 |
+
}) {
|
| 5 |
+
const i = options.findIndex((o) => o.value === value)
|
| 6 |
+
return (
|
| 7 |
+
<div role="radiogroup" aria-label={label}
|
| 8 |
+
className="relative grid h-10 shrink-0 grid-cols-2 rounded-full border border-white/15 bg-white/[0.06] p-1 backdrop-blur">
|
| 9 |
+
<span aria-hidden className="absolute inset-y-1 left-1 w-[calc(50%-4px)] rounded-full bg-white shadow-[0_4px_14px_rgba(0,0,0,0.3)] transition-transform duration-300 ease-[cubic-bezier(.22,.61,.36,1)]"
|
| 10 |
+
style={{ transform: `translateX(${i * 100}%)` }} />
|
| 11 |
+
{options.map((o) => {
|
| 12 |
+
const on = o.value === value
|
| 13 |
+
return (
|
| 14 |
+
<button key={o.value} type="button" role="radio" aria-checked={on} onClick={() => onChange(o.value)}
|
| 15 |
+
className={`relative z-10 rounded-full px-4 text-[15px] font-medium transition-colors duration-300 focus-visible:outline-2 focus-visible:outline-white/60 ${on ? "text-[#171717]" : "text-white/70 hover:text-white"}`}>
|
| 16 |
+
{o.label}
|
| 17 |
+
</button>
|
| 18 |
+
)
|
| 19 |
+
})}
|
| 20 |
+
</div>
|
| 21 |
+
)
|
| 22 |
+
}
|
code/web/src/components/site-header.tsx
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ArrowUpRight, ChevronDown } from "lucide-react"
|
| 2 |
+
import {
|
| 3 |
+
DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel,
|
| 4 |
+
DropdownMenuSeparator, DropdownMenuTrigger,
|
| 5 |
+
} from "@/components/ui/dropdown-menu"
|
| 6 |
+
import type { Site } from "@/lib/types"
|
| 7 |
+
import { catColor } from "@/lib/category"
|
| 8 |
+
import { full } from "@/lib/format"
|
| 9 |
+
import { href } from "@/lib/route"
|
| 10 |
+
|
| 11 |
+
/** Sits on the dark stage of every page: the MiniMax mark home, and every model page in a menu. */
|
| 12 |
+
export function SiteHeader({ site }: { site: Site }) {
|
| 13 |
+
const rel = (k: string) => site.releases.find((r) => r.key === k)!
|
| 14 |
+
return (
|
| 15 |
+
<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">
|
| 16 |
+
<a href={href()} className="flex items-center gap-3 rounded-lg text-white focus-visible:outline-2 focus-visible:outline-white/60">
|
| 17 |
+
{site.org.a && <img src={site.org.a} alt="" className="size-9 rounded-[10px]" />}
|
| 18 |
+
<span className="font-display text-[18px] leading-none font-semibold tracking-[-0.01em] whitespace-nowrap sm:text-[20px]">
|
| 19 |
+
MiniMax
|
| 20 |
+
</span>
|
| 21 |
+
</a>
|
| 22 |
+
<DropdownMenu modal={false}>
|
| 23 |
+
<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">
|
| 24 |
+
Models
|
| 25 |
+
<ChevronDown className="size-4 transition-transform duration-200 group-data-[state=open]:rotate-180" />
|
| 26 |
+
</DropdownMenuTrigger>
|
| 27 |
+
<DropdownMenuContent align="end" sideOffset={10}
|
| 28 |
+
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">
|
| 29 |
+
{site.categories.map((c, i) => {
|
| 30 |
+
const pages = c.releases.map(rel).filter((r) => r.page)
|
| 31 |
+
const total = c.releases.reduce((a, k) => a + rel(k).n, 0)
|
| 32 |
+
return (
|
| 33 |
+
<DropdownMenuGroup key={c.key}>
|
| 34 |
+
{i > 0 && <DropdownMenuSeparator className="my-1.5 bg-white/8" />}
|
| 35 |
+
<DropdownMenuItem asChild className="rounded-lg px-2.5 py-2 text-[15px] focus:bg-white/8">
|
| 36 |
+
<a href={href(c.key)} className="flex items-center gap-2.5">
|
| 37 |
+
<span className="size-2.5 rounded-full" style={{ background: catColor(c.key) }} />
|
| 38 |
+
<span className="font-semibold">{c.name}</span>
|
| 39 |
+
<span className="ml-auto font-display text-white/55 tabular-nums">{full(total)}</span>
|
| 40 |
+
</a>
|
| 41 |
+
</DropdownMenuItem>
|
| 42 |
+
{pages.length > 1 && pages.map((r) => (
|
| 43 |
+
<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">
|
| 44 |
+
<a href={href(c.key, r.key)} className="flex items-center">
|
| 45 |
+
{r.name}
|
| 46 |
+
<span className="ml-auto font-display text-white/45 tabular-nums">{full(r.n)}</span>
|
| 47 |
+
</a>
|
| 48 |
+
</DropdownMenuItem>
|
| 49 |
+
))}
|
| 50 |
+
</DropdownMenuGroup>
|
| 51 |
+
)
|
| 52 |
+
})}
|
| 53 |
+
<DropdownMenuSeparator className="my-1.5 bg-white/8" />
|
| 54 |
+
<DropdownMenuLabel className="sr-only">Elsewhere</DropdownMenuLabel>
|
| 55 |
+
<DropdownMenuItem asChild className="rounded-lg px-2.5 py-2 text-[15px] text-white/80 focus:bg-white/8 focus:text-white">
|
| 56 |
+
<a href="https://huggingface.co/MiniMaxAI" target="_blank" rel="noopener" className="flex items-center gap-2">
|
| 57 |
+
MiniMaxAI on Hugging Face <ArrowUpRight className="ml-auto size-4 text-white/50" />
|
| 58 |
+
</a>
|
| 59 |
+
</DropdownMenuItem>
|
| 60 |
+
</DropdownMenuContent>
|
| 61 |
+
</DropdownMenu>
|
| 62 |
+
</header>
|
| 63 |
+
)
|
| 64 |
+
}
|
code/web/src/components/sparkline.tsx
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect, useId, useMemo, useRef, useState } from "react"
|
| 2 |
+
import { area, curveMonotoneX, line } from "d3-shape"
|
| 3 |
+
import { DAY, toTime } from "@/lib/format"
|
| 4 |
+
import { catColor } from "@/lib/category"
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* A smooth running total from creation dates, drawn edge to edge: the area fades out downwards,
|
| 8 |
+
* and `dots` (dates) sit on the curve. Used inside cards, so it has no axes; the card states
|
| 9 |
+
* the numbers.
|
| 10 |
+
*/
|
| 11 |
+
export function Spark({ events, from, to, cat, height, dots = [], ring = "var(--card)" }: {
|
| 12 |
+
events: [string, number][]; from: string; to: string; cat: string; height: number
|
| 13 |
+
dots?: string[]; ring?: string
|
| 14 |
+
}) {
|
| 15 |
+
const id = useId().replace(/:/g, "")
|
| 16 |
+
const box = useRef<HTMLDivElement>(null)
|
| 17 |
+
const [width, setW] = useState(0)
|
| 18 |
+
useEffect(() => {
|
| 19 |
+
const el = box.current
|
| 20 |
+
if (!el) return
|
| 21 |
+
const ro = new ResizeObserver(() => setW(el.clientWidth))
|
| 22 |
+
ro.observe(el)
|
| 23 |
+
return () => ro.disconnect()
|
| 24 |
+
}, [])
|
| 25 |
+
|
| 26 |
+
const g = useMemo(() => {
|
| 27 |
+
if (!width) return null
|
| 28 |
+
const t0 = toTime(from), t1 = Math.max(toTime(to), t0 + DAY)
|
| 29 |
+
const ev = events.map(([d, n]) => [toTime(d), n] as const).sort((a, b) => a[0] - b[0])
|
| 30 |
+
const steps = 60
|
| 31 |
+
const pts: [number, number][] = []
|
| 32 |
+
let i = 0, run = 0
|
| 33 |
+
for (let k = 0; k <= steps; k++) {
|
| 34 |
+
const t = t0 + ((t1 - t0) * k) / steps
|
| 35 |
+
while (i < ev.length && ev[i][0] <= t) run += ev[i++][1]
|
| 36 |
+
pts.push([t, run])
|
| 37 |
+
}
|
| 38 |
+
const max = Math.max(1, run)
|
| 39 |
+
const X = (t: number) => 2 + ((t - t0) / (t1 - t0)) * (width - 4)
|
| 40 |
+
const Y = (v: number) => height - 3 - (v / max) * (height - 14)
|
| 41 |
+
const at = (t: number) => ev.reduce((a, [et, n]) => (et <= t ? a + n : a), 0)
|
| 42 |
+
return {
|
| 43 |
+
fill: area<[number, number]>().x((p) => X(p[0])).y0(height).y1((p) => Y(p[1])).curve(curveMonotoneX)(pts) ?? "",
|
| 44 |
+
stroke: line<[number, number]>().x((p) => X(p[0])).y((p) => Y(p[1])).curve(curveMonotoneX)(pts) ?? "",
|
| 45 |
+
dots: dots.filter((d) => toTime(d) >= t0).map((d) => ({ x: X(toTime(d)), y: Y(at(toTime(d))) })),
|
| 46 |
+
}
|
| 47 |
+
}, [events, from, to, width, height, dots])
|
| 48 |
+
|
| 49 |
+
return (
|
| 50 |
+
<div ref={box} className="w-full" style={{ height }}>
|
| 51 |
+
{g && (
|
| 52 |
+
<svg width={width} height={height} aria-hidden className="block overflow-visible">
|
| 53 |
+
<defs>
|
| 54 |
+
<linearGradient id={`sp-${id}`} x1="0" y1="0" x2="0" y2="1">
|
| 55 |
+
<stop offset="0" style={{ stopColor: catColor(cat), stopOpacity: 0.42 }} />
|
| 56 |
+
<stop offset="1" style={{ stopColor: catColor(cat), stopOpacity: 0 }} />
|
| 57 |
+
</linearGradient>
|
| 58 |
+
</defs>
|
| 59 |
+
<path d={g.fill} fill={`url(#sp-${id})`} />
|
| 60 |
+
<path d={g.stroke} fill="none" stroke={catColor(cat)} strokeWidth={2} />
|
| 61 |
+
{g.dots.map((p, i) => (
|
| 62 |
+
<circle key={i} cx={p.x} cy={p.y} r={4.5} fill={catColor(cat)} stroke={ring} strokeWidth={2} />
|
| 63 |
+
))}
|
| 64 |
+
</svg>
|
| 65 |
+
)}
|
| 66 |
+
</div>
|
| 67 |
+
)
|
| 68 |
+
}
|
code/web/src/components/top-lists.tsx
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useMemo } from "react"
|
| 2 |
+
import { REL_NAME, type Author, type Lineage, type Repo } from "@/lib/types"
|
| 3 |
+
import { num as fmt, hfUrl } from "@/lib/format"
|
| 4 |
+
import { relColor } from "@/components/rel"
|
| 5 |
+
import { Who } from "@/components/who"
|
| 6 |
+
|
| 7 |
+
export function TopModels({ repos, authors }: { repos: Repo[]; authors: Record<string, Author> }) {
|
| 8 |
+
const top = useMemo(() => [...repos].sort((a, b) => (b.dl30 ?? 0) - (a.dl30 ?? 0)).slice(0, 10), [repos])
|
| 9 |
+
const max = Math.max(1, ...top.map((r) => r.dl30 ?? 0))
|
| 10 |
+
return (
|
| 11 |
+
<ol className="space-y-4">
|
| 12 |
+
{top.map((r) => {
|
| 13 |
+
const [owner, name] = r.id.split("/")
|
| 14 |
+
return (
|
| 15 |
+
<li key={r.id} className="flex items-center gap-3">
|
| 16 |
+
<Who name={owner} authors={authors} />
|
| 17 |
+
<div className="min-w-0 flex-1">
|
| 18 |
+
<div className="flex items-baseline justify-between gap-3">
|
| 19 |
+
<a href={hfUrl(r.id)} target="_blank" rel="noopener" className="truncate text-[15px] hover:underline" title={r.id}>
|
| 20 |
+
<span className="text-muted-foreground">{owner}/</span>{name}
|
| 21 |
+
</a>
|
| 22 |
+
<span className="shrink-0 font-display text-[15px] font-semibold tabular-nums">{fmt(r.dl30)}</span>
|
| 23 |
+
</div>
|
| 24 |
+
<div className="mt-1.5 flex items-center gap-3">
|
| 25 |
+
<div className="h-1.5 rounded-full" style={{ width: `${Math.max(2, ((r.dl30 ?? 0) / max) * 78)}%`, background: relColor(r.rel) }} />
|
| 26 |
+
<span className="shrink-0 text-sm text-muted-foreground">{REL_NAME[r.rel]}</span>
|
| 27 |
+
</div>
|
| 28 |
+
</div>
|
| 29 |
+
</li>
|
| 30 |
+
)
|
| 31 |
+
})}
|
| 32 |
+
</ol>
|
| 33 |
+
)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
export function TopAuthors({ L, authors }: { L: Lineage; authors: Record<string, Author> }) {
|
| 37 |
+
const top = (L.top_authors ?? []).slice(0, 10)
|
| 38 |
+
const max = Math.max(1, ...top.map((a) => a.n))
|
| 39 |
+
return (
|
| 40 |
+
<ol className="space-y-4">
|
| 41 |
+
{top.map((t) => (
|
| 42 |
+
<li key={t.a} className="flex items-center gap-3">
|
| 43 |
+
<Who name={t.a} authors={authors} />
|
| 44 |
+
<div className="min-w-0 flex-1">
|
| 45 |
+
<div className="flex items-baseline justify-between gap-3">
|
| 46 |
+
<a href={hfUrl(t.a)} target="_blank" rel="noopener" className="truncate text-[15px] hover:underline">
|
| 47 |
+
{authors[t.a]?.n ?? t.a}
|
| 48 |
+
{authors[t.a]?.n && authors[t.a].n !== t.a && <span className="ml-2 text-muted-foreground">{t.a}</span>}
|
| 49 |
+
</a>
|
| 50 |
+
<span className="shrink-0 text-[15px]"><span className="font-display font-semibold tabular-nums">{t.n}</span> {t.n === 1 ? "model" : "models"}</span>
|
| 51 |
+
</div>
|
| 52 |
+
<div className="mt-1.5 h-1.5 rounded-full bg-[var(--neutral-series)]" style={{ width: `${(t.n / max) * 100}%` }} />
|
| 53 |
+
</div>
|
| 54 |
+
</li>
|
| 55 |
+
))}
|
| 56 |
+
</ol>
|
| 57 |
+
)
|
| 58 |
+
}
|
| 59 |
+
|
code/web/src/components/ui/avatar.tsx
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import { cn } from "cn"
|
| 5 |
+
import { Avatar as AvatarPrimitive } from "radix-ui"
|
| 6 |
+
|
| 7 |
+
function Avatar({
|
| 8 |
+
className,
|
| 9 |
+
size = "default",
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Root> & {
|
| 12 |
+
size?: "default" | "sm" | "lg"
|
| 13 |
+
}) {
|
| 14 |
+
return (
|
| 15 |
+
<AvatarPrimitive.Root
|
| 16 |
+
data-slot="avatar"
|
| 17 |
+
data-size={size}
|
| 18 |
+
className={cn(
|
| 19 |
+
"group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
|
| 20 |
+
className
|
| 21 |
+
)}
|
| 22 |
+
{...props}
|
| 23 |
+
/>
|
| 24 |
+
)
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function AvatarImage({
|
| 28 |
+
className,
|
| 29 |
+
...props
|
| 30 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Image>) {
|
| 31 |
+
return (
|
| 32 |
+
<AvatarPrimitive.Image
|
| 33 |
+
data-slot="avatar-image"
|
| 34 |
+
className={cn(
|
| 35 |
+
"aspect-square size-full rounded-full object-cover",
|
| 36 |
+
className
|
| 37 |
+
)}
|
| 38 |
+
{...props}
|
| 39 |
+
/>
|
| 40 |
+
)
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function AvatarFallback({
|
| 44 |
+
className,
|
| 45 |
+
...props
|
| 46 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
|
| 47 |
+
return (
|
| 48 |
+
<AvatarPrimitive.Fallback
|
| 49 |
+
data-slot="avatar-fallback"
|
| 50 |
+
className={cn(
|
| 51 |
+
"flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
|
| 52 |
+
className
|
| 53 |
+
)}
|
| 54 |
+
{...props}
|
| 55 |
+
/>
|
| 56 |
+
)
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
|
| 60 |
+
return (
|
| 61 |
+
<span
|
| 62 |
+
data-slot="avatar-badge"
|
| 63 |
+
className={cn(
|
| 64 |
+
"absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
|
| 65 |
+
"group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
|
| 66 |
+
"group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
|
| 67 |
+
"group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
|
| 68 |
+
className
|
| 69 |
+
)}
|
| 70 |
+
{...props}
|
| 71 |
+
/>
|
| 72 |
+
)
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
| 76 |
+
return (
|
| 77 |
+
<div
|
| 78 |
+
data-slot="avatar-group"
|
| 79 |
+
className={cn(
|
| 80 |
+
"group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
|
| 81 |
+
className
|
| 82 |
+
)}
|
| 83 |
+
{...props}
|
| 84 |
+
/>
|
| 85 |
+
)
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function AvatarGroupCount({
|
| 89 |
+
className,
|
| 90 |
+
...props
|
| 91 |
+
}: React.ComponentProps<"div">) {
|
| 92 |
+
return (
|
| 93 |
+
<div
|
| 94 |
+
data-slot="avatar-group-count"
|
| 95 |
+
className={cn(
|
| 96 |
+
"relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
|
| 97 |
+
className
|
| 98 |
+
)}
|
| 99 |
+
{...props}
|
| 100 |
+
/>
|
| 101 |
+
)
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
export {
|
| 105 |
+
Avatar,
|
| 106 |
+
AvatarImage,
|
| 107 |
+
AvatarFallback,
|
| 108 |
+
AvatarGroup,
|
| 109 |
+
AvatarGroupCount,
|
| 110 |
+
AvatarBadge,
|
| 111 |
+
}
|
code/web/src/components/ui/badge.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 3 |
+
import { cn } from "cn"
|
| 4 |
+
import { Slot } from "radix-ui"
|
| 5 |
+
|
| 6 |
+
const badgeVariants = cva(
|
| 7 |
+
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
| 12 |
+
secondary:
|
| 13 |
+
"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
| 14 |
+
destructive:
|
| 15 |
+
"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
| 16 |
+
outline:
|
| 17 |
+
"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
| 18 |
+
ghost:
|
| 19 |
+
"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
| 20 |
+
link: "text-primary underline-offset-4 hover:underline",
|
| 21 |
+
},
|
| 22 |
+
},
|
| 23 |
+
defaultVariants: {
|
| 24 |
+
variant: "default",
|
| 25 |
+
},
|
| 26 |
+
}
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
function Badge({
|
| 30 |
+
className,
|
| 31 |
+
variant = "default",
|
| 32 |
+
asChild = false,
|
| 33 |
+
...props
|
| 34 |
+
}: React.ComponentProps<"span"> &
|
| 35 |
+
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
| 36 |
+
const Comp = asChild ? Slot.Root : "span"
|
| 37 |
+
|
| 38 |
+
return (
|
| 39 |
+
<Comp
|
| 40 |
+
data-slot="badge"
|
| 41 |
+
data-variant={variant}
|
| 42 |
+
className={cn(badgeVariants({ variant }), className)}
|
| 43 |
+
{...props}
|
| 44 |
+
/>
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
export { Badge, badgeVariants }
|
code/web/src/components/ui/button.tsx
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 3 |
+
import { cn } from "cn"
|
| 4 |
+
import { Slot } from "radix-ui"
|
| 5 |
+
|
| 6 |
+
const buttonVariants = cva(
|
| 7 |
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
| 12 |
+
outline:
|
| 13 |
+
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
| 14 |
+
secondary:
|
| 15 |
+
"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
| 16 |
+
ghost:
|
| 17 |
+
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
| 18 |
+
destructive:
|
| 19 |
+
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
| 20 |
+
link: "text-primary underline-offset-4 hover:underline",
|
| 21 |
+
},
|
| 22 |
+
size: {
|
| 23 |
+
default:
|
| 24 |
+
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
| 25 |
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
| 26 |
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
| 27 |
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
| 28 |
+
icon: "size-8",
|
| 29 |
+
"icon-xs":
|
| 30 |
+
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
| 31 |
+
"icon-sm":
|
| 32 |
+
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
| 33 |
+
"icon-lg": "size-9",
|
| 34 |
+
},
|
| 35 |
+
},
|
| 36 |
+
defaultVariants: {
|
| 37 |
+
variant: "default",
|
| 38 |
+
size: "default",
|
| 39 |
+
},
|
| 40 |
+
}
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
function Button({
|
| 44 |
+
className,
|
| 45 |
+
variant = "default",
|
| 46 |
+
size = "default",
|
| 47 |
+
asChild = false,
|
| 48 |
+
...props
|
| 49 |
+
}: React.ComponentProps<"button"> &
|
| 50 |
+
VariantProps<typeof buttonVariants> & {
|
| 51 |
+
asChild?: boolean
|
| 52 |
+
}) {
|
| 53 |
+
const Comp = asChild ? Slot.Root : "button"
|
| 54 |
+
|
| 55 |
+
return (
|
| 56 |
+
<Comp
|
| 57 |
+
data-slot="button"
|
| 58 |
+
data-variant={variant}
|
| 59 |
+
data-size={size}
|
| 60 |
+
className={cn(buttonVariants({ variant, size, className }))}
|
| 61 |
+
{...props}
|
| 62 |
+
/>
|
| 63 |
+
)
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
export { Button, buttonVariants }
|
code/web/src/components/ui/card.tsx
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cn } from "cn"
|
| 3 |
+
|
| 4 |
+
function Card({
|
| 5 |
+
className,
|
| 6 |
+
size = "default",
|
| 7 |
+
...props
|
| 8 |
+
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
| 9 |
+
return (
|
| 10 |
+
<div
|
| 11 |
+
data-slot="card"
|
| 12 |
+
data-size={size}
|
| 13 |
+
className={cn(
|
| 14 |
+
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
| 15 |
+
className
|
| 16 |
+
)}
|
| 17 |
+
{...props}
|
| 18 |
+
/>
|
| 19 |
+
)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
| 23 |
+
return (
|
| 24 |
+
<div
|
| 25 |
+
data-slot="card-header"
|
| 26 |
+
className={cn(
|
| 27 |
+
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
| 28 |
+
className
|
| 29 |
+
)}
|
| 30 |
+
{...props}
|
| 31 |
+
/>
|
| 32 |
+
)
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
| 36 |
+
return (
|
| 37 |
+
<div
|
| 38 |
+
data-slot="card-title"
|
| 39 |
+
className={cn(
|
| 40 |
+
"font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
| 41 |
+
className
|
| 42 |
+
)}
|
| 43 |
+
{...props}
|
| 44 |
+
/>
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
| 49 |
+
return (
|
| 50 |
+
<div
|
| 51 |
+
data-slot="card-description"
|
| 52 |
+
className={cn("text-sm text-muted-foreground", className)}
|
| 53 |
+
{...props}
|
| 54 |
+
/>
|
| 55 |
+
)
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
| 59 |
+
return (
|
| 60 |
+
<div
|
| 61 |
+
data-slot="card-action"
|
| 62 |
+
className={cn(
|
| 63 |
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
| 64 |
+
className
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
/>
|
| 68 |
+
)
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
| 72 |
+
return (
|
| 73 |
+
<div
|
| 74 |
+
data-slot="card-content"
|
| 75 |
+
className={cn("px-(--card-spacing)", className)}
|
| 76 |
+
{...props}
|
| 77 |
+
/>
|
| 78 |
+
)
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
| 82 |
+
return (
|
| 83 |
+
<div
|
| 84 |
+
data-slot="card-footer"
|
| 85 |
+
className={cn(
|
| 86 |
+
"flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
|
| 87 |
+
className
|
| 88 |
+
)}
|
| 89 |
+
{...props}
|
| 90 |
+
/>
|
| 91 |
+
)
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
export {
|
| 95 |
+
Card,
|
| 96 |
+
CardHeader,
|
| 97 |
+
CardFooter,
|
| 98 |
+
CardTitle,
|
| 99 |
+
CardAction,
|
| 100 |
+
CardDescription,
|
| 101 |
+
CardContent,
|
| 102 |
+
}
|
code/web/src/components/ui/chart.tsx
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cn } from "cn"
|
| 3 |
+
import * as RechartsPrimitive from "recharts"
|
| 4 |
+
import type { TooltipValueType } from "recharts"
|
| 5 |
+
|
| 6 |
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
| 7 |
+
const THEMES = { light: "", dark: ".dark" } as const
|
| 8 |
+
|
| 9 |
+
const INITIAL_DIMENSION = { width: 320, height: 200 } as const
|
| 10 |
+
type TooltipNameType = number | string
|
| 11 |
+
|
| 12 |
+
export type ChartConfig = Record<
|
| 13 |
+
string,
|
| 14 |
+
{
|
| 15 |
+
label?: React.ReactNode
|
| 16 |
+
icon?: React.ComponentType
|
| 17 |
+
} & (
|
| 18 |
+
| { color?: string; theme?: never }
|
| 19 |
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
| 20 |
+
)
|
| 21 |
+
>
|
| 22 |
+
|
| 23 |
+
type ChartContextProps = {
|
| 24 |
+
config: ChartConfig
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
| 28 |
+
|
| 29 |
+
function useChart() {
|
| 30 |
+
const context = React.useContext(ChartContext)
|
| 31 |
+
|
| 32 |
+
if (!context) {
|
| 33 |
+
throw new Error("useChart must be used within a <ChartContainer />")
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
return context
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function ChartContainer({
|
| 40 |
+
id,
|
| 41 |
+
className,
|
| 42 |
+
children,
|
| 43 |
+
config,
|
| 44 |
+
initialDimension = INITIAL_DIMENSION,
|
| 45 |
+
...props
|
| 46 |
+
}: React.ComponentProps<"div"> & {
|
| 47 |
+
config: ChartConfig
|
| 48 |
+
children: React.ComponentProps<
|
| 49 |
+
typeof RechartsPrimitive.ResponsiveContainer
|
| 50 |
+
>["children"]
|
| 51 |
+
initialDimension?: {
|
| 52 |
+
width: number
|
| 53 |
+
height: number
|
| 54 |
+
}
|
| 55 |
+
}) {
|
| 56 |
+
const uniqueId = React.useId()
|
| 57 |
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`
|
| 58 |
+
|
| 59 |
+
return (
|
| 60 |
+
<ChartContext.Provider value={{ config }}>
|
| 61 |
+
<div
|
| 62 |
+
data-slot="chart"
|
| 63 |
+
data-chart={chartId}
|
| 64 |
+
className={cn(
|
| 65 |
+
"flex aspect-video justify-center text-sm [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
| 66 |
+
className
|
| 67 |
+
)}
|
| 68 |
+
{...props}
|
| 69 |
+
>
|
| 70 |
+
<ChartStyle id={chartId} config={config} />
|
| 71 |
+
<RechartsPrimitive.ResponsiveContainer
|
| 72 |
+
initialDimension={initialDimension}
|
| 73 |
+
>
|
| 74 |
+
{children}
|
| 75 |
+
</RechartsPrimitive.ResponsiveContainer>
|
| 76 |
+
</div>
|
| 77 |
+
</ChartContext.Provider>
|
| 78 |
+
)
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
| 82 |
+
const colorConfig = Object.entries(config).filter(
|
| 83 |
+
([, config]) => config.theme ?? config.color
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
if (!colorConfig.length) {
|
| 87 |
+
return null
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
return (
|
| 91 |
+
<style
|
| 92 |
+
dangerouslySetInnerHTML={{
|
| 93 |
+
__html: Object.entries(THEMES)
|
| 94 |
+
.map(
|
| 95 |
+
([theme, prefix]) => `
|
| 96 |
+
${prefix} [data-chart=${id}] {
|
| 97 |
+
${colorConfig
|
| 98 |
+
.map(([key, itemConfig]) => {
|
| 99 |
+
const color =
|
| 100 |
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
|
| 101 |
+
itemConfig.color
|
| 102 |
+
return color ? ` --color-${key}: ${color};` : null
|
| 103 |
+
})
|
| 104 |
+
.join("\n")}
|
| 105 |
+
}
|
| 106 |
+
`
|
| 107 |
+
)
|
| 108 |
+
.join("\n"),
|
| 109 |
+
}}
|
| 110 |
+
/>
|
| 111 |
+
)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
| 115 |
+
|
| 116 |
+
function ChartTooltipContent({
|
| 117 |
+
active,
|
| 118 |
+
payload,
|
| 119 |
+
className,
|
| 120 |
+
indicator = "dot",
|
| 121 |
+
hideLabel = false,
|
| 122 |
+
hideIndicator = false,
|
| 123 |
+
label,
|
| 124 |
+
labelFormatter,
|
| 125 |
+
labelClassName,
|
| 126 |
+
formatter,
|
| 127 |
+
color,
|
| 128 |
+
nameKey,
|
| 129 |
+
labelKey,
|
| 130 |
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
| 131 |
+
React.ComponentProps<"div"> & {
|
| 132 |
+
hideLabel?: boolean
|
| 133 |
+
hideIndicator?: boolean
|
| 134 |
+
indicator?: "line" | "dot" | "dashed"
|
| 135 |
+
nameKey?: string
|
| 136 |
+
labelKey?: string
|
| 137 |
+
} & Omit<
|
| 138 |
+
RechartsPrimitive.DefaultTooltipContentProps<
|
| 139 |
+
TooltipValueType,
|
| 140 |
+
TooltipNameType
|
| 141 |
+
>,
|
| 142 |
+
"accessibilityLayer"
|
| 143 |
+
>) {
|
| 144 |
+
const { config } = useChart()
|
| 145 |
+
|
| 146 |
+
const tooltipLabel = React.useMemo(() => {
|
| 147 |
+
if (hideLabel || !payload?.length) {
|
| 148 |
+
return null
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
const [item] = payload
|
| 152 |
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`
|
| 153 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 154 |
+
const value =
|
| 155 |
+
!labelKey && typeof label === "string"
|
| 156 |
+
? (config[label]?.label ?? label)
|
| 157 |
+
: itemConfig?.label
|
| 158 |
+
|
| 159 |
+
if (labelFormatter) {
|
| 160 |
+
return (
|
| 161 |
+
<div className={cn("font-medium", labelClassName)}>
|
| 162 |
+
{labelFormatter(value, payload)}
|
| 163 |
+
</div>
|
| 164 |
+
)
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
if (!value) {
|
| 168 |
+
return null
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
| 172 |
+
}, [
|
| 173 |
+
label,
|
| 174 |
+
labelFormatter,
|
| 175 |
+
payload,
|
| 176 |
+
hideLabel,
|
| 177 |
+
labelClassName,
|
| 178 |
+
config,
|
| 179 |
+
labelKey,
|
| 180 |
+
])
|
| 181 |
+
|
| 182 |
+
if (!active || !payload?.length) {
|
| 183 |
+
return null
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
| 187 |
+
|
| 188 |
+
return (
|
| 189 |
+
<div
|
| 190 |
+
className={cn(
|
| 191 |
+
"grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-3 py-2 text-sm shadow-xl",
|
| 192 |
+
className
|
| 193 |
+
)}
|
| 194 |
+
>
|
| 195 |
+
{!nestLabel ? tooltipLabel : null}
|
| 196 |
+
<div className="grid gap-1.5">
|
| 197 |
+
{payload
|
| 198 |
+
.filter((item) => item.type !== "none")
|
| 199 |
+
.map((item, index) => {
|
| 200 |
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`
|
| 201 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 202 |
+
const indicatorColor = color ?? item.payload?.fill ?? item.color
|
| 203 |
+
|
| 204 |
+
return (
|
| 205 |
+
<div
|
| 206 |
+
key={index}
|
| 207 |
+
className={cn(
|
| 208 |
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
| 209 |
+
indicator === "dot" && "items-center"
|
| 210 |
+
)}
|
| 211 |
+
>
|
| 212 |
+
{formatter && item?.value !== undefined && item.name ? (
|
| 213 |
+
formatter(item.value, item.name, item, index, item.payload)
|
| 214 |
+
) : (
|
| 215 |
+
<>
|
| 216 |
+
{itemConfig?.icon ? (
|
| 217 |
+
<itemConfig.icon />
|
| 218 |
+
) : (
|
| 219 |
+
!hideIndicator && (
|
| 220 |
+
<div
|
| 221 |
+
className={cn(
|
| 222 |
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
| 223 |
+
{
|
| 224 |
+
"h-2.5 w-2.5": indicator === "dot",
|
| 225 |
+
"w-1": indicator === "line",
|
| 226 |
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
| 227 |
+
indicator === "dashed",
|
| 228 |
+
"my-0.5": nestLabel && indicator === "dashed",
|
| 229 |
+
}
|
| 230 |
+
)}
|
| 231 |
+
style={
|
| 232 |
+
{
|
| 233 |
+
"--color-bg": indicatorColor,
|
| 234 |
+
"--color-border": indicatorColor,
|
| 235 |
+
} as React.CSSProperties
|
| 236 |
+
}
|
| 237 |
+
/>
|
| 238 |
+
)
|
| 239 |
+
)}
|
| 240 |
+
<div
|
| 241 |
+
className={cn(
|
| 242 |
+
"flex flex-1 justify-between leading-none",
|
| 243 |
+
nestLabel ? "items-end" : "items-center"
|
| 244 |
+
)}
|
| 245 |
+
>
|
| 246 |
+
<div className="grid gap-1.5">
|
| 247 |
+
{nestLabel ? tooltipLabel : null}
|
| 248 |
+
<span className="text-muted-foreground">
|
| 249 |
+
{itemConfig?.label ?? item.name}
|
| 250 |
+
</span>
|
| 251 |
+
</div>
|
| 252 |
+
{item.value != null && (
|
| 253 |
+
<span className="font-mono font-medium text-foreground tabular-nums">
|
| 254 |
+
{typeof item.value === "number"
|
| 255 |
+
? item.value.toLocaleString()
|
| 256 |
+
: String(item.value)}
|
| 257 |
+
</span>
|
| 258 |
+
)}
|
| 259 |
+
</div>
|
| 260 |
+
</>
|
| 261 |
+
)}
|
| 262 |
+
</div>
|
| 263 |
+
)
|
| 264 |
+
})}
|
| 265 |
+
</div>
|
| 266 |
+
</div>
|
| 267 |
+
)
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
const ChartLegend = RechartsPrimitive.Legend
|
| 271 |
+
|
| 272 |
+
function ChartLegendContent({
|
| 273 |
+
className,
|
| 274 |
+
hideIcon = false,
|
| 275 |
+
payload,
|
| 276 |
+
verticalAlign = "bottom",
|
| 277 |
+
nameKey,
|
| 278 |
+
}: React.ComponentProps<"div"> & {
|
| 279 |
+
hideIcon?: boolean
|
| 280 |
+
nameKey?: string
|
| 281 |
+
} & RechartsPrimitive.DefaultLegendContentProps) {
|
| 282 |
+
const { config } = useChart()
|
| 283 |
+
|
| 284 |
+
if (!payload?.length) {
|
| 285 |
+
return null
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
return (
|
| 289 |
+
<div
|
| 290 |
+
className={cn(
|
| 291 |
+
"flex items-center justify-center gap-4",
|
| 292 |
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
| 293 |
+
className
|
| 294 |
+
)}
|
| 295 |
+
>
|
| 296 |
+
{payload
|
| 297 |
+
.filter((item) => item.type !== "none")
|
| 298 |
+
.map((item, index) => {
|
| 299 |
+
const key = `${nameKey ?? item.dataKey ?? "value"}`
|
| 300 |
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
| 301 |
+
|
| 302 |
+
return (
|
| 303 |
+
<div
|
| 304 |
+
key={index}
|
| 305 |
+
className={cn(
|
| 306 |
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
| 307 |
+
)}
|
| 308 |
+
>
|
| 309 |
+
{itemConfig?.icon && !hideIcon ? (
|
| 310 |
+
<itemConfig.icon />
|
| 311 |
+
) : (
|
| 312 |
+
<div
|
| 313 |
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
| 314 |
+
style={{
|
| 315 |
+
backgroundColor: item.color,
|
| 316 |
+
}}
|
| 317 |
+
/>
|
| 318 |
+
)}
|
| 319 |
+
{itemConfig?.label}
|
| 320 |
+
</div>
|
| 321 |
+
)
|
| 322 |
+
})}
|
| 323 |
+
</div>
|
| 324 |
+
)
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
function getPayloadConfigFromPayload(
|
| 328 |
+
config: ChartConfig,
|
| 329 |
+
payload: unknown,
|
| 330 |
+
key: string
|
| 331 |
+
) {
|
| 332 |
+
if (typeof payload !== "object" || payload === null) {
|
| 333 |
+
return undefined
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
const payloadPayload =
|
| 337 |
+
"payload" in payload &&
|
| 338 |
+
typeof payload.payload === "object" &&
|
| 339 |
+
payload.payload !== null
|
| 340 |
+
? payload.payload
|
| 341 |
+
: undefined
|
| 342 |
+
|
| 343 |
+
let configLabelKey: string = key
|
| 344 |
+
|
| 345 |
+
if (
|
| 346 |
+
key in payload &&
|
| 347 |
+
typeof payload[key as keyof typeof payload] === "string"
|
| 348 |
+
) {
|
| 349 |
+
configLabelKey = payload[key as keyof typeof payload] as string
|
| 350 |
+
} else if (
|
| 351 |
+
payloadPayload &&
|
| 352 |
+
key in payloadPayload &&
|
| 353 |
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
| 354 |
+
) {
|
| 355 |
+
configLabelKey = payloadPayload[
|
| 356 |
+
key as keyof typeof payloadPayload
|
| 357 |
+
] as string
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
return configLabelKey in config ? config[configLabelKey] : config[key]
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
export {
|
| 364 |
+
ChartContainer,
|
| 365 |
+
ChartTooltip,
|
| 366 |
+
ChartTooltipContent,
|
| 367 |
+
ChartLegend,
|
| 368 |
+
ChartLegendContent,
|
| 369 |
+
ChartStyle,
|
| 370 |
+
}
|
code/web/src/components/ui/dropdown-menu.tsx
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cn } from "cn"
|
| 3 |
+
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
| 4 |
+
import { CheckIcon, ChevronRightIcon } from "lucide-react"
|
| 5 |
+
|
| 6 |
+
function DropdownMenu({
|
| 7 |
+
...props
|
| 8 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
| 9 |
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
function DropdownMenuPortal({
|
| 13 |
+
...props
|
| 14 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
| 15 |
+
return (
|
| 16 |
+
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
| 17 |
+
)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function DropdownMenuTrigger({
|
| 21 |
+
...props
|
| 22 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
| 23 |
+
return (
|
| 24 |
+
<DropdownMenuPrimitive.Trigger
|
| 25 |
+
data-slot="dropdown-menu-trigger"
|
| 26 |
+
{...props}
|
| 27 |
+
/>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function DropdownMenuContent({
|
| 32 |
+
className,
|
| 33 |
+
align = "start",
|
| 34 |
+
sideOffset = 4,
|
| 35 |
+
...props
|
| 36 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
| 37 |
+
return (
|
| 38 |
+
<DropdownMenuPrimitive.Portal>
|
| 39 |
+
<DropdownMenuPrimitive.Content
|
| 40 |
+
data-slot="dropdown-menu-content"
|
| 41 |
+
sideOffset={sideOffset}
|
| 42 |
+
align={align}
|
| 43 |
+
className={cn("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
| 44 |
+
{...props}
|
| 45 |
+
/>
|
| 46 |
+
</DropdownMenuPrimitive.Portal>
|
| 47 |
+
)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function DropdownMenuGroup({
|
| 51 |
+
...props
|
| 52 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
| 53 |
+
return (
|
| 54 |
+
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
| 55 |
+
)
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function DropdownMenuItem({
|
| 59 |
+
className,
|
| 60 |
+
inset,
|
| 61 |
+
variant = "default",
|
| 62 |
+
...props
|
| 63 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
| 64 |
+
inset?: boolean
|
| 65 |
+
variant?: "default" | "destructive"
|
| 66 |
+
}) {
|
| 67 |
+
return (
|
| 68 |
+
<DropdownMenuPrimitive.Item
|
| 69 |
+
data-slot="dropdown-menu-item"
|
| 70 |
+
data-inset={inset}
|
| 71 |
+
data-variant={variant}
|
| 72 |
+
className={cn(
|
| 73 |
+
"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
| 74 |
+
className
|
| 75 |
+
)}
|
| 76 |
+
{...props}
|
| 77 |
+
/>
|
| 78 |
+
)
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
function DropdownMenuCheckboxItem({
|
| 82 |
+
className,
|
| 83 |
+
children,
|
| 84 |
+
checked,
|
| 85 |
+
inset,
|
| 86 |
+
...props
|
| 87 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {
|
| 88 |
+
inset?: boolean
|
| 89 |
+
}) {
|
| 90 |
+
return (
|
| 91 |
+
<DropdownMenuPrimitive.CheckboxItem
|
| 92 |
+
data-slot="dropdown-menu-checkbox-item"
|
| 93 |
+
data-inset={inset}
|
| 94 |
+
className={cn(
|
| 95 |
+
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 96 |
+
className
|
| 97 |
+
)}
|
| 98 |
+
checked={checked}
|
| 99 |
+
{...props}
|
| 100 |
+
>
|
| 101 |
+
<span
|
| 102 |
+
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
| 103 |
+
data-slot="dropdown-menu-checkbox-item-indicator"
|
| 104 |
+
>
|
| 105 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 106 |
+
<CheckIcon
|
| 107 |
+
/>
|
| 108 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 109 |
+
</span>
|
| 110 |
+
{children}
|
| 111 |
+
</DropdownMenuPrimitive.CheckboxItem>
|
| 112 |
+
)
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
function DropdownMenuRadioGroup({
|
| 116 |
+
...props
|
| 117 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
| 118 |
+
return (
|
| 119 |
+
<DropdownMenuPrimitive.RadioGroup
|
| 120 |
+
data-slot="dropdown-menu-radio-group"
|
| 121 |
+
{...props}
|
| 122 |
+
/>
|
| 123 |
+
)
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
function DropdownMenuRadioItem({
|
| 127 |
+
className,
|
| 128 |
+
children,
|
| 129 |
+
inset,
|
| 130 |
+
...props
|
| 131 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {
|
| 132 |
+
inset?: boolean
|
| 133 |
+
}) {
|
| 134 |
+
return (
|
| 135 |
+
<DropdownMenuPrimitive.RadioItem
|
| 136 |
+
data-slot="dropdown-menu-radio-item"
|
| 137 |
+
data-inset={inset}
|
| 138 |
+
className={cn(
|
| 139 |
+
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 140 |
+
className
|
| 141 |
+
)}
|
| 142 |
+
{...props}
|
| 143 |
+
>
|
| 144 |
+
<span
|
| 145 |
+
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
| 146 |
+
data-slot="dropdown-menu-radio-item-indicator"
|
| 147 |
+
>
|
| 148 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 149 |
+
<CheckIcon
|
| 150 |
+
/>
|
| 151 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 152 |
+
</span>
|
| 153 |
+
{children}
|
| 154 |
+
</DropdownMenuPrimitive.RadioItem>
|
| 155 |
+
)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
function DropdownMenuLabel({
|
| 159 |
+
className,
|
| 160 |
+
inset,
|
| 161 |
+
...props
|
| 162 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
| 163 |
+
inset?: boolean
|
| 164 |
+
}) {
|
| 165 |
+
return (
|
| 166 |
+
<DropdownMenuPrimitive.Label
|
| 167 |
+
data-slot="dropdown-menu-label"
|
| 168 |
+
data-inset={inset}
|
| 169 |
+
className={cn(
|
| 170 |
+
"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
|
| 171 |
+
className
|
| 172 |
+
)}
|
| 173 |
+
{...props}
|
| 174 |
+
/>
|
| 175 |
+
)
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
function DropdownMenuSeparator({
|
| 179 |
+
className,
|
| 180 |
+
...props
|
| 181 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
| 182 |
+
return (
|
| 183 |
+
<DropdownMenuPrimitive.Separator
|
| 184 |
+
data-slot="dropdown-menu-separator"
|
| 185 |
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
| 186 |
+
{...props}
|
| 187 |
+
/>
|
| 188 |
+
)
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
function DropdownMenuShortcut({
|
| 192 |
+
className,
|
| 193 |
+
...props
|
| 194 |
+
}: React.ComponentProps<"span">) {
|
| 195 |
+
return (
|
| 196 |
+
<span
|
| 197 |
+
data-slot="dropdown-menu-shortcut"
|
| 198 |
+
className={cn(
|
| 199 |
+
"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
|
| 200 |
+
className
|
| 201 |
+
)}
|
| 202 |
+
{...props}
|
| 203 |
+
/>
|
| 204 |
+
)
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function DropdownMenuSub({
|
| 208 |
+
...props
|
| 209 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
| 210 |
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
function DropdownMenuSubTrigger({
|
| 214 |
+
className,
|
| 215 |
+
inset,
|
| 216 |
+
children,
|
| 217 |
+
...props
|
| 218 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
| 219 |
+
inset?: boolean
|
| 220 |
+
}) {
|
| 221 |
+
return (
|
| 222 |
+
<DropdownMenuPrimitive.SubTrigger
|
| 223 |
+
data-slot="dropdown-menu-sub-trigger"
|
| 224 |
+
data-inset={inset}
|
| 225 |
+
className={cn(
|
| 226 |
+
"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 227 |
+
className
|
| 228 |
+
)}
|
| 229 |
+
{...props}
|
| 230 |
+
>
|
| 231 |
+
{children}
|
| 232 |
+
<ChevronRightIcon className="ml-auto" />
|
| 233 |
+
</DropdownMenuPrimitive.SubTrigger>
|
| 234 |
+
)
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
function DropdownMenuSubContent({
|
| 238 |
+
className,
|
| 239 |
+
...props
|
| 240 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
| 241 |
+
return (
|
| 242 |
+
<DropdownMenuPrimitive.SubContent
|
| 243 |
+
data-slot="dropdown-menu-sub-content"
|
| 244 |
+
className={cn("z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
| 245 |
+
{...props}
|
| 246 |
+
/>
|
| 247 |
+
)
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
export {
|
| 251 |
+
DropdownMenu,
|
| 252 |
+
DropdownMenuPortal,
|
| 253 |
+
DropdownMenuTrigger,
|
| 254 |
+
DropdownMenuContent,
|
| 255 |
+
DropdownMenuGroup,
|
| 256 |
+
DropdownMenuLabel,
|
| 257 |
+
DropdownMenuItem,
|
| 258 |
+
DropdownMenuCheckboxItem,
|
| 259 |
+
DropdownMenuRadioGroup,
|
| 260 |
+
DropdownMenuRadioItem,
|
| 261 |
+
DropdownMenuSeparator,
|
| 262 |
+
DropdownMenuShortcut,
|
| 263 |
+
DropdownMenuSub,
|
| 264 |
+
DropdownMenuSubTrigger,
|
| 265 |
+
DropdownMenuSubContent,
|
| 266 |
+
}
|
code/web/src/components/ui/hover-card.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cn } from "cn"
|
| 3 |
+
import { HoverCard as HoverCardPrimitive } from "radix-ui"
|
| 4 |
+
|
| 5 |
+
function HoverCard({
|
| 6 |
+
...props
|
| 7 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
|
| 8 |
+
return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function HoverCardTrigger({
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
|
| 14 |
+
return (
|
| 15 |
+
<HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
|
| 16 |
+
)
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function HoverCardContent({
|
| 20 |
+
className,
|
| 21 |
+
align = "center",
|
| 22 |
+
sideOffset = 4,
|
| 23 |
+
...props
|
| 24 |
+
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
|
| 25 |
+
return (
|
| 26 |
+
<HoverCardPrimitive.Portal data-slot="hover-card-portal">
|
| 27 |
+
<HoverCardPrimitive.Content
|
| 28 |
+
data-slot="hover-card-content"
|
| 29 |
+
align={align}
|
| 30 |
+
sideOffset={sideOffset}
|
| 31 |
+
className={cn(
|
| 32 |
+
"z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
| 33 |
+
className
|
| 34 |
+
)}
|
| 35 |
+
{...props}
|
| 36 |
+
/>
|
| 37 |
+
</HoverCardPrimitive.Portal>
|
| 38 |
+
)
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
code/web/src/components/ui/input.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cn } from "cn"
|
| 3 |
+
|
| 4 |
+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
| 5 |
+
return (
|
| 6 |
+
<input
|
| 7 |
+
type={type}
|
| 8 |
+
data-slot="input"
|
| 9 |
+
className={cn(
|
| 10 |
+
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
| 11 |
+
className
|
| 12 |
+
)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
)
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
export { Input }
|
code/web/src/components/ui/separator.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import { cn } from "cn"
|
| 5 |
+
import { Separator as SeparatorPrimitive } from "radix-ui"
|
| 6 |
+
|
| 7 |
+
function Separator({
|
| 8 |
+
className,
|
| 9 |
+
orientation = "horizontal",
|
| 10 |
+
decorative = true,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<SeparatorPrimitive.Root
|
| 15 |
+
data-slot="separator"
|
| 16 |
+
decorative={decorative}
|
| 17 |
+
orientation={orientation}
|
| 18 |
+
className={cn(
|
| 19 |
+
"shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
|
| 20 |
+
className
|
| 21 |
+
)}
|
| 22 |
+
{...props}
|
| 23 |
+
/>
|
| 24 |
+
)
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
export { Separator }
|
code/web/src/components/ui/table.tsx
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cn } from "cn"
|
| 3 |
+
|
| 4 |
+
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
| 5 |
+
return (
|
| 6 |
+
<div
|
| 7 |
+
data-slot="table-container"
|
| 8 |
+
className="relative w-full overflow-x-auto"
|
| 9 |
+
>
|
| 10 |
+
<table
|
| 11 |
+
data-slot="table"
|
| 12 |
+
className={cn("w-full caption-bottom text-sm", className)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
</div>
|
| 16 |
+
)
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
| 20 |
+
return (
|
| 21 |
+
<thead
|
| 22 |
+
data-slot="table-header"
|
| 23 |
+
className={cn("[&_tr]:border-b", className)}
|
| 24 |
+
{...props}
|
| 25 |
+
/>
|
| 26 |
+
)
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
| 30 |
+
return (
|
| 31 |
+
<tbody
|
| 32 |
+
data-slot="table-body"
|
| 33 |
+
className={cn("[&_tr:last-child]:border-0", className)}
|
| 34 |
+
{...props}
|
| 35 |
+
/>
|
| 36 |
+
)
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
| 40 |
+
return (
|
| 41 |
+
<tfoot
|
| 42 |
+
data-slot="table-footer"
|
| 43 |
+
className={cn(
|
| 44 |
+
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
| 45 |
+
className
|
| 46 |
+
)}
|
| 47 |
+
{...props}
|
| 48 |
+
/>
|
| 49 |
+
)
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
| 53 |
+
return (
|
| 54 |
+
<tr
|
| 55 |
+
data-slot="table-row"
|
| 56 |
+
className={cn(
|
| 57 |
+
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
|
| 58 |
+
className
|
| 59 |
+
)}
|
| 60 |
+
{...props}
|
| 61 |
+
/>
|
| 62 |
+
)
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
| 66 |
+
return (
|
| 67 |
+
<th
|
| 68 |
+
data-slot="table-head"
|
| 69 |
+
className={cn(
|
| 70 |
+
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
|
| 71 |
+
className
|
| 72 |
+
)}
|
| 73 |
+
{...props}
|
| 74 |
+
/>
|
| 75 |
+
)
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
| 79 |
+
return (
|
| 80 |
+
<td
|
| 81 |
+
data-slot="table-cell"
|
| 82 |
+
className={cn(
|
| 83 |
+
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
|
| 84 |
+
className
|
| 85 |
+
)}
|
| 86 |
+
{...props}
|
| 87 |
+
/>
|
| 88 |
+
)
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
function TableCaption({
|
| 92 |
+
className,
|
| 93 |
+
...props
|
| 94 |
+
}: React.ComponentProps<"caption">) {
|
| 95 |
+
return (
|
| 96 |
+
<caption
|
| 97 |
+
data-slot="table-caption"
|
| 98 |
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
| 99 |
+
{...props}
|
| 100 |
+
/>
|
| 101 |
+
)
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
export {
|
| 105 |
+
Table,
|
| 106 |
+
TableHeader,
|
| 107 |
+
TableBody,
|
| 108 |
+
TableFooter,
|
| 109 |
+
TableHead,
|
| 110 |
+
TableRow,
|
| 111 |
+
TableCell,
|
| 112 |
+
TableCaption,
|
| 113 |
+
}
|
code/web/src/components/ui/toggle-group.tsx
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import { type VariantProps } from "class-variance-authority"
|
| 5 |
+
import { cn } from "cn"
|
| 6 |
+
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"
|
| 7 |
+
|
| 8 |
+
import { toggleVariants } from "@/components/ui/toggle"
|
| 9 |
+
|
| 10 |
+
const ToggleGroupContext = React.createContext<
|
| 11 |
+
VariantProps<typeof toggleVariants> & {
|
| 12 |
+
spacing?: number
|
| 13 |
+
orientation?: "horizontal" | "vertical"
|
| 14 |
+
}
|
| 15 |
+
>({
|
| 16 |
+
size: "default",
|
| 17 |
+
variant: "default",
|
| 18 |
+
spacing: 2,
|
| 19 |
+
orientation: "horizontal",
|
| 20 |
+
})
|
| 21 |
+
|
| 22 |
+
function ToggleGroup({
|
| 23 |
+
className,
|
| 24 |
+
variant,
|
| 25 |
+
size,
|
| 26 |
+
spacing = 2,
|
| 27 |
+
orientation = "horizontal",
|
| 28 |
+
children,
|
| 29 |
+
...props
|
| 30 |
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
| 31 |
+
VariantProps<typeof toggleVariants> & {
|
| 32 |
+
spacing?: number
|
| 33 |
+
orientation?: "horizontal" | "vertical"
|
| 34 |
+
}) {
|
| 35 |
+
return (
|
| 36 |
+
<ToggleGroupPrimitive.Root
|
| 37 |
+
data-slot="toggle-group"
|
| 38 |
+
data-variant={variant}
|
| 39 |
+
data-size={size}
|
| 40 |
+
data-spacing={spacing}
|
| 41 |
+
data-orientation={orientation}
|
| 42 |
+
style={{ "--gap": spacing } as React.CSSProperties}
|
| 43 |
+
className={cn(
|
| 44 |
+
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",
|
| 45 |
+
className
|
| 46 |
+
)}
|
| 47 |
+
{...props}
|
| 48 |
+
>
|
| 49 |
+
<ToggleGroupContext.Provider
|
| 50 |
+
value={{ variant, size, spacing, orientation }}
|
| 51 |
+
>
|
| 52 |
+
{children}
|
| 53 |
+
</ToggleGroupContext.Provider>
|
| 54 |
+
</ToggleGroupPrimitive.Root>
|
| 55 |
+
)
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function ToggleGroupItem({
|
| 59 |
+
className,
|
| 60 |
+
children,
|
| 61 |
+
variant = "default",
|
| 62 |
+
size = "default",
|
| 63 |
+
...props
|
| 64 |
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
| 65 |
+
VariantProps<typeof toggleVariants>) {
|
| 66 |
+
const context = React.useContext(ToggleGroupContext)
|
| 67 |
+
|
| 68 |
+
return (
|
| 69 |
+
<ToggleGroupPrimitive.Item
|
| 70 |
+
data-slot="toggle-group-item"
|
| 71 |
+
data-variant={context.variant || variant}
|
| 72 |
+
data-size={context.size || size}
|
| 73 |
+
data-spacing={context.spacing}
|
| 74 |
+
className={cn(
|
| 75 |
+
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
| 76 |
+
toggleVariants({
|
| 77 |
+
variant: context.variant || variant,
|
| 78 |
+
size: context.size || size,
|
| 79 |
+
}),
|
| 80 |
+
className
|
| 81 |
+
)}
|
| 82 |
+
{...props}
|
| 83 |
+
>
|
| 84 |
+
{children}
|
| 85 |
+
</ToggleGroupPrimitive.Item>
|
| 86 |
+
)
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
export { ToggleGroup, ToggleGroupItem }
|
code/web/src/components/ui/toggle.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 3 |
+
import { cn } from "cn"
|
| 4 |
+
import { Toggle as TogglePrimitive } from "radix-ui"
|
| 5 |
+
|
| 6 |
+
const toggleVariants = cva(
|
| 7 |
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default: "bg-transparent",
|
| 12 |
+
outline: "border border-input bg-transparent hover:bg-muted",
|
| 13 |
+
},
|
| 14 |
+
size: {
|
| 15 |
+
default:
|
| 16 |
+
"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
| 17 |
+
sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
| 18 |
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
| 19 |
+
},
|
| 20 |
+
},
|
| 21 |
+
defaultVariants: {
|
| 22 |
+
variant: "default",
|
| 23 |
+
size: "default",
|
| 24 |
+
},
|
| 25 |
+
}
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
function Toggle({
|
| 29 |
+
className,
|
| 30 |
+
variant = "default",
|
| 31 |
+
size = "default",
|
| 32 |
+
...props
|
| 33 |
+
}: React.ComponentProps<typeof TogglePrimitive.Root> &
|
| 34 |
+
VariantProps<typeof toggleVariants>) {
|
| 35 |
+
return (
|
| 36 |
+
<TogglePrimitive.Root
|
| 37 |
+
data-slot="toggle"
|
| 38 |
+
className={cn(toggleVariants({ variant, size, className }))}
|
| 39 |
+
{...props}
|
| 40 |
+
/>
|
| 41 |
+
)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
export { Toggle, toggleVariants }
|
code/web/src/components/ui/tooltip.tsx
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import { cn } from "cn"
|
| 5 |
+
import { Tooltip as TooltipPrimitive } from "radix-ui"
|
| 6 |
+
|
| 7 |
+
function TooltipProvider({
|
| 8 |
+
delayDuration = 0,
|
| 9 |
+
...props
|
| 10 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
| 11 |
+
return (
|
| 12 |
+
<TooltipPrimitive.Provider
|
| 13 |
+
data-slot="tooltip-provider"
|
| 14 |
+
delayDuration={delayDuration}
|
| 15 |
+
{...props}
|
| 16 |
+
/>
|
| 17 |
+
)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function Tooltip({
|
| 21 |
+
...props
|
| 22 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
| 23 |
+
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function TooltipTrigger({
|
| 27 |
+
...props
|
| 28 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
| 29 |
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function TooltipContent({
|
| 33 |
+
className,
|
| 34 |
+
sideOffset = 0,
|
| 35 |
+
children,
|
| 36 |
+
...props
|
| 37 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
| 38 |
+
return (
|
| 39 |
+
<TooltipPrimitive.Portal>
|
| 40 |
+
<TooltipPrimitive.Content
|
| 41 |
+
data-slot="tooltip-content"
|
| 42 |
+
sideOffset={sideOffset}
|
| 43 |
+
className={cn(
|
| 44 |
+
"z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-sm text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
| 45 |
+
className
|
| 46 |
+
)}
|
| 47 |
+
{...props}
|
| 48 |
+
>
|
| 49 |
+
{children}
|
| 50 |
+
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
|
| 51 |
+
</TooltipPrimitive.Content>
|
| 52 |
+
</TooltipPrimitive.Portal>
|
| 53 |
+
)
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }
|
code/web/src/components/who.tsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
| 2 |
+
import type { Author } from "@/lib/types"
|
| 3 |
+
|
| 4 |
+
export function Who({ name, authors, size = "size-8" }: { name: string; authors: Record<string, Author>; size?: string }) {
|
| 5 |
+
const a = authors[name]
|
| 6 |
+
return (
|
| 7 |
+
<Avatar className={`${size} shrink-0`}>
|
| 8 |
+
{a?.a && <AvatarImage src={a.a} alt="" loading="lazy" />}
|
| 9 |
+
<AvatarFallback className="text-sm">{name.slice(0, 1).toUpperCase()}</AvatarFallback>
|
| 10 |
+
</Avatar>
|
| 11 |
+
)
|
| 12 |
+
}
|
code/web/src/index.css
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import "tailwindcss";
|
| 2 |
+
@import "tw-animate-css";
|
| 3 |
+
@import "shadcn/tailwind.css";
|
| 4 |
+
/* Outfit for display and numbers, as on minimax.io and Hailuo; DM Sans for text. Both OFL. */
|
| 5 |
+
@import "@fontsource-variable/outfit/index.css";
|
| 6 |
+
@import "@fontsource-variable/dm-sans/index.css";
|
| 7 |
+
|
| 8 |
+
@custom-variant dark (&:is(.dark *));
|
| 9 |
+
|
| 10 |
+
@theme inline {
|
| 11 |
+
--font-heading: var(--font-sans);
|
| 12 |
+
--font-sans: "DM Sans Variable", system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif;
|
| 13 |
+
--font-display: "Outfit Variable", "DM Sans Variable", system-ui, sans-serif;
|
| 14 |
+
--color-sidebar-ring: var(--sidebar-ring);
|
| 15 |
+
--color-sidebar-border: var(--sidebar-border);
|
| 16 |
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
| 17 |
+
--color-sidebar-accent: var(--sidebar-accent);
|
| 18 |
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
| 19 |
+
--color-sidebar-primary: var(--sidebar-primary);
|
| 20 |
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
| 21 |
+
--color-sidebar: var(--sidebar);
|
| 22 |
+
--color-chart-5: var(--chart-5);
|
| 23 |
+
--color-chart-4: var(--chart-4);
|
| 24 |
+
--color-chart-3: var(--chart-3);
|
| 25 |
+
--color-chart-2: var(--chart-2);
|
| 26 |
+
--color-chart-1: var(--chart-1);
|
| 27 |
+
--color-ring: var(--ring);
|
| 28 |
+
--color-input: var(--input);
|
| 29 |
+
--color-border: var(--border);
|
| 30 |
+
--color-destructive: var(--destructive);
|
| 31 |
+
--color-accent-foreground: var(--accent-foreground);
|
| 32 |
+
--color-accent: var(--accent);
|
| 33 |
+
--color-muted-foreground: var(--muted-foreground);
|
| 34 |
+
--color-muted: var(--muted);
|
| 35 |
+
--color-secondary-foreground: var(--secondary-foreground);
|
| 36 |
+
--color-secondary: var(--secondary);
|
| 37 |
+
--color-primary-foreground: var(--primary-foreground);
|
| 38 |
+
--color-primary: var(--primary);
|
| 39 |
+
--color-popover-foreground: var(--popover-foreground);
|
| 40 |
+
--color-popover: var(--popover);
|
| 41 |
+
--color-card-foreground: var(--card-foreground);
|
| 42 |
+
--color-card: var(--card);
|
| 43 |
+
--color-foreground: var(--foreground);
|
| 44 |
+
--color-background: var(--background);
|
| 45 |
+
--radius-sm: calc(var(--radius) * 0.6);
|
| 46 |
+
--radius-md: calc(var(--radius) * 0.8);
|
| 47 |
+
--radius-lg: var(--radius);
|
| 48 |
+
--radius-xl: calc(var(--radius) * 1.4);
|
| 49 |
+
--radius-2xl: calc(var(--radius) * 1.8);
|
| 50 |
+
--radius-3xl: calc(var(--radius) * 2.2);
|
| 51 |
+
--radius-4xl: calc(var(--radius) * 2.6);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/* MiniMax neutrals (minimax.io --product-* tokens), H3 violet for H3 only, and the relation
|
| 55 |
+
palette checked with the dataviz validator in this order on #fff and #171717. */
|
| 56 |
+
:root {
|
| 57 |
+
--background: #ffffff;
|
| 58 |
+
--foreground: #171717;
|
| 59 |
+
--card: #ffffff;
|
| 60 |
+
--card-foreground: #171717;
|
| 61 |
+
--popover: #ffffff;
|
| 62 |
+
--popover-foreground: #171717;
|
| 63 |
+
--primary: #171717;
|
| 64 |
+
--primary-foreground: #ffffff;
|
| 65 |
+
--secondary: #f5f5f5;
|
| 66 |
+
--secondary-foreground: #171717;
|
| 67 |
+
--muted: #f5f5f5;
|
| 68 |
+
--muted-foreground: #666666;
|
| 69 |
+
--accent: #f5f5f5;
|
| 70 |
+
--accent-foreground: #171717;
|
| 71 |
+
--destructive: #ef4d3e;
|
| 72 |
+
--border: #e9e9e9;
|
| 73 |
+
--input: #e9e9e9;
|
| 74 |
+
--ring: #0094fc;
|
| 75 |
+
--radius: 12px;
|
| 76 |
+
--chart-1: #7657ff; --chart-2: #a09afb; --chart-3: #b7bacc; --chart-4: #666666; --chart-5: #171717;
|
| 77 |
+
--sidebar: #ffffff; --sidebar-foreground: #171717; --sidebar-primary: #171717; --sidebar-primary-foreground: #ffffff;
|
| 78 |
+
--sidebar-accent: #f5f5f5; --sidebar-accent-foreground: #171717; --sidebar-border: #e9e9e9; --sidebar-ring: #0094fc;
|
| 79 |
+
|
| 80 |
+
--brand: #7657ff;
|
| 81 |
+
--brand-from: #7426f7;
|
| 82 |
+
--brand-to: #a05efa;
|
| 83 |
+
--brand-deep: #450cd1;
|
| 84 |
+
--rel-adapter: #e81a7f;
|
| 85 |
+
--rel-finetune: #e4743b;
|
| 86 |
+
--rel-quantized: #00969b;
|
| 87 |
+
--rel-repackage: #b58800;
|
| 88 |
+
--rel-merge: #0077d9;
|
| 89 |
+
--rel-mirror: #b7bacc;
|
| 90 |
+
--rel-component: #008635;
|
| 91 |
+
--neutral-series: #b7bacc;
|
| 92 |
+
--galaxy-bg: #f7f8fc;
|
| 93 |
+
--ring-band: rgba(118, 87, 255, 0.055);
|
| 94 |
+
|
| 95 |
+
/* modalities, in stack order (validated light and dark) */
|
| 96 |
+
--cat-language: #f5433c; --cat-language-from: #ff3a6c; --cat-language-to: #ff7a62;
|
| 97 |
+
--cat-video: #7657ff; --cat-video-from: #7426f7; --cat-video-to: #a05efa;
|
| 98 |
+
--cat-music: #b58800; --cat-music-from: #b58800; --cat-music-to: #f0b429;
|
| 99 |
+
--cat-image: #00969b; --cat-image-from: #00878c; --cat-image-to: #2cc5bf;
|
| 100 |
+
--stage: #0b0b10;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.dark {
|
| 104 |
+
--background: #171717;
|
| 105 |
+
--foreground: #ededed;
|
| 106 |
+
--card: #1c1c1c;
|
| 107 |
+
--card-foreground: #ededed;
|
| 108 |
+
--popover: #262626;
|
| 109 |
+
--popover-foreground: #ededed;
|
| 110 |
+
--primary: #ffffff;
|
| 111 |
+
--primary-foreground: #171717;
|
| 112 |
+
--secondary: #262626;
|
| 113 |
+
--secondary-foreground: #ededed;
|
| 114 |
+
--muted: #262626;
|
| 115 |
+
--muted-foreground: #949494;
|
| 116 |
+
--accent: #262626;
|
| 117 |
+
--accent-foreground: #ededed;
|
| 118 |
+
--destructive: #d34137;
|
| 119 |
+
--border: #2c2c2c;
|
| 120 |
+
--input: #2c2c2c;
|
| 121 |
+
--ring: #0077d9;
|
| 122 |
+
--chart-1: #8173ff; --chart-2: #a09afb; --chart-3: #6b6f80; --chart-4: #949494; --chart-5: #ededed;
|
| 123 |
+
--sidebar: #1c1c1c; --sidebar-foreground: #ededed; --sidebar-primary: #ffffff; --sidebar-primary-foreground: #171717;
|
| 124 |
+
--sidebar-accent: #262626; --sidebar-accent-foreground: #ededed; --sidebar-border: #2c2c2c; --sidebar-ring: #0077d9;
|
| 125 |
+
|
| 126 |
+
--brand: #8173ff;
|
| 127 |
+
--rel-adapter: #e81a7f;
|
| 128 |
+
--rel-finetune: #d9652c;
|
| 129 |
+
--rel-quantized: #00969b;
|
| 130 |
+
--rel-repackage: #b58800;
|
| 131 |
+
--rel-merge: #0077d9;
|
| 132 |
+
--rel-mirror: #6b6f80;
|
| 133 |
+
--rel-component: #009c3d;
|
| 134 |
+
--neutral-series: #6b6f80;
|
| 135 |
+
--galaxy-bg: #1c1c1c;
|
| 136 |
+
--ring-band: rgba(129, 115, 255, 0.08);
|
| 137 |
+
--cat-language: #e8453c;
|
| 138 |
+
--cat-video: #8173ff;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
@layer base {
|
| 142 |
+
* {
|
| 143 |
+
@apply border-border outline-ring/50;
|
| 144 |
+
}
|
| 145 |
+
body {
|
| 146 |
+
@apply bg-background text-foreground;
|
| 147 |
+
}
|
| 148 |
+
button:not(:disabled), [role="button"]:not(:disabled) {
|
| 149 |
+
cursor: pointer;
|
| 150 |
+
}
|
| 151 |
+
html {
|
| 152 |
+
@apply font-sans;
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/* The landing stage and the galaxy are always dark; they carry the .dark class themselves. */
|
| 157 |
+
.stage {
|
| 158 |
+
background-color: var(--stage);
|
| 159 |
+
color: #ededed;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
@keyframes rise {
|
| 163 |
+
from { opacity: 0; transform: translateY(14px); }
|
| 164 |
+
to { opacity: 1; transform: none; }
|
| 165 |
+
}
|
| 166 |
+
@keyframes wipe {
|
| 167 |
+
from { clip-path: inset(0 100% 0 0); }
|
| 168 |
+
to { clip-path: inset(0 0 0 0); }
|
| 169 |
+
}
|
| 170 |
+
@keyframes draw {
|
| 171 |
+
from { stroke-dashoffset: 1; }
|
| 172 |
+
to { stroke-dashoffset: 0; }
|
| 173 |
+
}
|
| 174 |
+
@keyframes pop {
|
| 175 |
+
from { opacity: 0; transform: scale(0.3); }
|
| 176 |
+
to { opacity: 1; transform: none; }
|
| 177 |
+
}
|
| 178 |
+
@keyframes fade {
|
| 179 |
+
from { opacity: 0; }
|
| 180 |
+
to { opacity: 1; }
|
| 181 |
+
}
|
| 182 |
+
@keyframes breathe {
|
| 183 |
+
0%, 100% { opacity: 0.55; transform: scale(1); }
|
| 184 |
+
50% { opacity: 0.9; transform: scale(1.06); }
|
| 185 |
+
}
|
| 186 |
+
@keyframes unfold {
|
| 187 |
+
from { opacity: 0; transform: rotate(-14deg) scale(0.86); }
|
| 188 |
+
to { opacity: 1; transform: none; }
|
| 189 |
+
}
|
| 190 |
+
@keyframes octo-swim {
|
| 191 |
+
0%, 100% { transform: translateY(0) scale(1, 1) rotate(-2deg); }
|
| 192 |
+
50% { transform: translateY(-7%) scale(1.04, 0.95) rotate(2deg); }
|
| 193 |
+
}
|
| 194 |
+
.anim-rise { animation: rise 700ms cubic-bezier(.22,.61,.36,1) both; }
|
| 195 |
+
|
| 196 |
+
@media (prefers-reduced-motion: reduce) {
|
| 197 |
+
*, *::before, *::after {
|
| 198 |
+
animation-duration: 1ms !important;
|
| 199 |
+
animation-delay: 0ms !important;
|
| 200 |
+
animation-iteration-count: 1 !important;
|
| 201 |
+
transition-duration: 1ms !important;
|
| 202 |
+
}
|
| 203 |
+
}
|
code/web/src/lib/category.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** Each modality keeps one colour everywhere (validated in this stack order, light and dark).
|
| 2 |
+
* Video is H3's violet; language takes the M-series red; image teal; music amber. */
|
| 3 |
+
export const CAT_ORDER = ["language", "video", "music", "image", "audio"]
|
| 4 |
+
|
| 5 |
+
export const catColor = (c: string) => `var(--cat-${c}, var(--neutral-series))`
|
| 6 |
+
export const catFrom = (c: string) => `var(--cat-${c}-from, var(--neutral-series))`
|
| 7 |
+
export const catTo = (c: string) => `var(--cat-${c}-to, var(--neutral-series))`
|
| 8 |
+
|
| 9 |
+
/** "MiniMax-M2.7" -> "M2.7" for tight places. */
|
| 10 |
+
export const shortName = (name: string) => name.replace(/^MiniMax-/, "")
|