圖表與數字卡改成閱讀向排版(Notion 風):色板、直接標數、排序、手機原生圖

研究依據(2026-10 Supernova 11 設計系統調查、IBM Carbon 資料視覺化規範、
Atlassian chart tokens、shadcn/ui chart、Tufte data-ink、EEA/Sheffield 準則):
預設單色、分類色≤6固定序、只留淡水平參考線、直接標數取代圖例與座標軸、
長條按大小排序(自有順序的標籤不排)、顏色只給意義(漲綠跌紅附箭頭)。

- theme.rs:新增 chart_cat 六色(明暗各一組,低飽和藍紫青橙粉灰)、grid、up
- 桌面圖表卡:網格只剩淡水平線;單系列長條把數字標在條上、不畫 y 軸;
  長條自動由大到小排序(月/季/年/W1/Q1/數字等自然序標籤不排);
  多條線在線尾標系列名(取代圖例);stats 數字卡大字、↑/+綠 ↓/−紅
- Mermaid:白底卡節點、細灰連線、同套六色圓餅(house_theme)
- 手機:```chart 原本掉成純文字——現在畫原生 SVG,規則與色板和桌面同款;
  stats 卡改白卡描邊、大字、漲綠跌紅;代幣進 :root/dark
- write_page 說明:排版由渲染器接手,Bot 專心把圖標題寫成結論
- 功能地圖 pages.md/FEATURES.md 同步;layout_audit 新增「頁面(圖表)」場景

已驗證: cargo test 501 全綠;layout_audit 全綠(新場景含長條排序/多線/圓餅/stats,
664/1000/1440 三寬度無出界無疊字);手機 chartMd 用 node 跑 8 個案例(排序、
自然序不排、線尾標名、圓餅佔比、tooltip、千分位、壞輸入回空)全過;
ANYBOT_SHOT=page 截圖肉眼確認
未驗證: 手機端只在 node 驗證圖表產生器,未實機開網頁看 SVG 渲染;
Mermaid 新主題未逐圖型(gantt/gitGraph)目視;深色模式截圖未拍
This commit is contained in:
daniel wang 2026-11-16 16:43:55 +08:00
parent ec73947133
commit e03ec4a90c
8 changed files with 285 additions and 49 deletions

View File

@ -1562,7 +1562,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
### 頁面(Bot 做、Bot 持續更新的報告)
- 你請 Bot 追蹤、整理、比較一件之後還會回來看的事(例如「幫我追蹤一下台灣 FSD 狀況」),它用 `write_page` 做成一頁:先寫現況,再寫細節和來源(附日期)。回答裡用「[標題](page:ID)」連到它,回答下面出現頁面卡片(標題、開頭幾行、頁面圖示、「頁面 · 更新時間」、最近一次更新了什麼),點一下打開。
- 頁面可以放表格、Mermaid 圖表(圓餅、長條、折線、時間軸…),以及頁面專用的區塊:```stats 數字卡片、```steps 進度(✓ 完成、◉ 進行中、○ 還沒到)、```chart 原生圖表(bar 長條、line 折線、pie 圓餅;egui_plot 繪製:座標軸、网格、懸停看數值、拖曳平移、右鍵框選放大、雙擊還原,圖下自動附數據表,不會破版;多系列用 `| 1月 | 2月` 當表頭)、`> [!NOTE]`/`[!TIP]`/`[!WARNING]`/`[!IMPORTANT]` 提示框。這些區塊在聊天裡也能用。
- 頁面可以放表格、Mermaid 圖表(圓餅、長條、折線、時間軸…白底卡節點、細灰連線),以及頁面專用的區塊:```stats 數字卡片(數字大字;值開頭 ↑/+ 綠色、↓/− 紅色)、```steps 進度(✓ 完成、◉ 進行中、○ 還沒到)、```chart 原生圖表(bar 長條、line 折線、pie 圓餅;只畫淡水平參考線,長條自動由大到小排序——月份/年份等自有順序的標籤不排;單系列把數字直接標在圖上、不畫 y 軸;多條線在線尾標系列名;懸停看數值、拖曳平移、右鍵框選放大、雙擊還原,圖下自動附數據表,不會破版;多系列用 `| 1月 | 2月` 當表頭;手機看同一頁也畫同樣樣式的原生 SVG 圖)、`> [!NOTE]`/`[!TIP]`/`[!WARNING]`/`[!IMPORTANT]` 提示框。這些區塊在聊天裡也能用。所有圖表(含 Mermaid 圓餅)共用同一套低飽和六色色板,深淺兩主題各一組。
- 頁面是「閱讀排版」:內文排在置中的 720 像素欄位裡,行高 1.55 倍、段落有呼吸空間,不會貼著視窗邊緣;聊天室保持原本的緊湊排版。頁面上的數字表格(2–3 欄、資料不超過 8 列)在寬度夠時會自動左表右圖併排。
- 標題超過 4 個的頁面,頂部有「目錄」卡:每條標題可點,點了直接跳到那一節;上面的搜尋框可以篩標題(⌘F 光標進搜尋框,Esc 離開)。
- 寫頁面時 Bot 會選一種「種類」(data 數據分析/compare 比較評測/decision 決策備忘/howto 教學步驟/timeline 時間線/prose 長文/notes 筆記),第一屏跟著內容走:data 頁頂部放 2–4 張 KPI 數字卡(附漲跌,漲綠跌紅),compare/decision 頁先給一行「結論」卡;種類顯示在頁面標題和聊天卡片的列中。字段全部可省略——沒有數字就不硬湊卡片。

View File

@ -4,7 +4,7 @@ Bot 把要追蹤、整理、比較的事寫成一頁,之後一直更新同一
## 子功能
- 寫頁面:標題和整頁 Markdown(標題、表格、連結、Mermaid 圖),加上頁面區塊:```stats 數字卡、```steps 進度([x] 完成、[>] 進行中、[ ] 還沒到)、```chart 圖表(bar/line/pie,可以多系列)、`> [!NOTE]`/`[!TIP]`/`[!WARNING]`/`[!IMPORTANT]` 提示框。
- 寫頁面:標題和整頁 Markdown(標題、表格、連結、Mermaid 圖),加上頁面區塊:```stats 數字卡(數字大字顯示;值開頭是 ↑/+ 綠色、↓/− 紅色)、```steps 進度([x] 完成、[>] 進行中、[ ] 還沒到)、```chart 圖表(bar/line/pie,可以多系列;長條圖自動由大到小排序,月份/年份等自有順序的標籤不排;單系列把數字直接標在圖上不畫 y 軸;多條線在線尾標系列名;手機也畫原生圖,樣式相同)、`> [!NOTE]`/`[!TIP]`/`[!WARNING]`/`[!IMPORTANT]` 提示框。
- 種類(kind):data 數據分析、compare 比較評測、decision 決策備忘、howto 教學步驟、timeline 時間線、prose 長文、notes 筆記。種類決定第一屏:data 頁上面放 2–4 個 KPI 數字(kpis),compare/decision 頁先給一行「結論」(verdict)。沒給種類就是一般頁面。
- 更新:帶 id(或同一個標題)就換掉內容,上一版留著,最多留 10 版;note 寫這次改了什麼,頁面上顯示「這一版更新了:…」。內容一模一樣就不更新。
- 一直留著:跨聊天、跨例行任務都在。例行任務每一輪從新的開始,要接著上次做就先讀頁面。
@ -21,7 +21,7 @@ Bot 把要追蹤、整理、比較的事寫成一頁,之後一直更新同一
## 怎麼操作
- Bot:使用者要你追蹤、整理、比較、研究一件之後還會回來看的事,用 `write_page`(title、content;summary 一行現況;kind;kpis、verdict 只放真的資料;更新時帶 id 和 note),回覆裡用 [標題](page:ID) 連過去。更新前先 `read_page`(id 或 title)看現在的內容。要查的事同事可能已經在追,先 `list_pages`、`read_page` 讀它的,不要重查一遍。要定期追蹤就配一條例行任務([routines](routines.md)):每次讀頁面、查新消息,有實質進展才更新,沒有就說「沒有新消息」。這三個工具屬於「頁面」能力。
- 驗證:請 Bot「幫我追蹤某件事,整理成一頁」,回覆下面要出現頁面卡片,右側面板 資料庫 › 頁面 要列出它;再請它更新,卡片寫「已更新」,打開頁面的「版本紀錄」有上一版。請另一個 Bot 改這一頁,要被擋下並說是誰的頁面。自動測試:`cargo test pages::`、`cargo test appctl::`。
- 驗證:請 Bot「幫我追蹤某件事,整理成一頁」,回覆下面要出現頁面卡片,右側面板 資料庫 › 頁面 要列出它;再請它更新,卡片寫「已更新」,打開頁面的「版本紀錄」有上一版。請另一個 Bot 改這一頁,要被擋下並說是誰的頁面。頁裡的 ```chart:長條要按大小排序(月份圖不排)、單系列數字在條上;手機同頁看同一張圖要是同一套樣式。自動測試:`cargo test pages::`、`cargo test appctl::`。
## 陷阱

View File

@ -26,6 +26,9 @@
--danger:#e72e3b;--ok:#10ab61;--warn:#da830e;
--bubble-user:#1c1c1c;--bubble-user-ink:#fff;--bubble-bot:#1c1c1c0f;--card:#fff;--attention:#ffc83d;--attention-bg:#fff6d6;
--spec:#ffffff59;--shadow:0 2px 8px -1px #0000000d,0 1px 2px #00000008,0 0 0 1px #e4e4e40a;
/* 圖表色板(與桌面版 theme.rs chart_cat 同序): 藍紫青橙粉灰,低飽和 */
--cat1:#2383e2;--cat2:#9065b0;--cat3:#0f7b6c;--cat4:#d9730d;--cat5:#e06b9e;--cat6:#6e6c68;
--grid:#1c1c1c12;--up:#0f7b6c;
--font:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang TC","Noto Sans TC","Segoe UI",system-ui,sans-serif;
--mono:ui-monospace,SFMono-Regular,Menlo,monospace;
--safe-b:env(safe-area-inset-bottom);--safe-t:env(safe-area-inset-top);
@ -36,6 +39,7 @@
--line:#f5f5f51a;--line2:#f5f5f514;--focus:#1884fc;--accent:#1884fc;--accent-ink:#4d9bff;
--danger:#fc2c3e;--bubble-user:#f5f5f52e;--bubble-user-ink:#f5f5f5;--bubble-bot:#f5f5f50a;--card:#252525;--attention:#ffc83d;--attention-bg:#3a3212;
--spec:#ffffff0d;--shadow:none;
--cat1:#529cca;--cat2:#b493e5;--cat3:#4dab9a;--cat4:#e3a062;--cat5:#f291c0;--cat6:#a09e9a;--grid:#f5f5f514;--up:#4dab9a;
}}
:root[data-theme="dark"]{
--pane:#161616;--chrome:#121212;--side:#0e0e0e;--elev:#1f1f1f;--hover:#f5f5f50f;--active:#f5f5f514;
@ -43,6 +47,7 @@
--line:#f5f5f51a;--line2:#f5f5f514;--focus:#1884fc;--accent:#1884fc;--accent-ink:#4d9bff;
--danger:#fc2c3e;--bubble-user:#f5f5f52e;--bubble-user-ink:#f5f5f5;--bubble-bot:#f5f5f50a;--card:#252525;--attention:#ffc83d;--attention-bg:#3a3212;
--spec:#ffffff0d;--shadow:none;
--cat1:#529cca;--cat2:#b493e5;--cat3:#4dab9a;--cat4:#e3a062;--cat5:#f291c0;--cat6:#a09e9a;--grid:#f5f5f514;--up:#4dab9a;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;background:var(--pane);color:var(--text);font:15px/1.47 var(--font);-webkit-font-smoothing:antialiased;overscroll-behavior:none}
@ -437,17 +442,22 @@ textarea.field{min-height:96px;line-height:1.5}
.page .call.tip{background:color-mix(in srgb,var(--ok) 12%,transparent)}
.page .call.important{background:color-mix(in srgb,var(--accent) 12%,transparent)}
.page .stats{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px;margin:12px 0}
.page .stat{border-radius:12px;background:var(--hover);padding:10px 12px}
.page .stat .k{font-size:12px;color:var(--text3)}.page .stat .v{font-size:22px;font-weight:600}.page .stat .v.long{font-size:16px}.page .stat .s{font-size:12px;color:var(--text3)}
.page .stat{border:.5px solid var(--line);border-radius:12px;background:var(--elev);padding:11px 13px}
.page .stat .k{font-size:11px;color:var(--text3)}.page .stat .v{font-size:26px;font-weight:650;line-height:1.2}.page .stat .v.long{font-size:16px;font-weight:600}.page .stat .s{font-size:12px;color:var(--text2)}
.page .stat .v.up{color:var(--up)}.page .stat .v.dn{color:var(--danger)}
.page ul.steps{list-style:none;padding:0}
.page ul.steps li{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:6px 0}
.page ul.steps .dot{width:18px;height:18px;border-radius:50%;border:2px solid var(--line);display:grid;place-items:center;font-size:11px}
.page ul.steps li.done .dot{background:var(--ok);border-color:var(--ok);color:#fff}
.page ul.steps li.now .dot{border-color:var(--accent)}
.page ul.steps .nt{flex-basis:100%;padding-left:26px;font-size:13px;color:var(--text3)}
.page .chart{margin:12px 0;border-radius:12px;overflow:hidden;background:var(--hover)}
.page .chart{margin:12px 0;border:.5px solid var(--line);border-radius:12px;overflow:hidden;background:var(--elev)}
.page .chart img{width:100%;display:block}
.page .chart .wait{padding:18px;font-size:13px;color:var(--text3)}
/* ```chart 原生 SVG 卡(與桌面版圖表卡同款) */
.page .chartcard{margin:12px 0;border:.5px solid var(--line);border-radius:12px;background:var(--elev);padding:12px 12px 8px}
.page .chartcard .ct2{font-size:14px;font-weight:600;margin:2px 2px 6px}
.page .chartcard svg{width:100%;height:auto;display:block}
.page li.task{list-style:none;margin-left:-18px}
/* ---- this Mac's screen ---- */
@ -2609,6 +2619,101 @@ function inl(s) {
const CALL = {note: "說明", tip: "提示", warning: "注意", important: "重要"};
// Markdown as the desktop draws it (pages and chat replies): headings, lists and tasks, tables,
// quotes and call-outs, code, Mermaid charts (pages: drawn by AnyBot), ```stats and ```steps.
/* ```chart 頁面板塊 → 原生 SVG,和桌面版同一套規則:長條依大小排序(標籤本身有順序
(月/季/年/數字)時不排);單系列把數字直接標在條上(不畫 y 軸);多線把系列名放在
線尾;只留淡水平參考線;色板用 --cat1..6(同桌面版 theme.rs)。 */
function chartMd(lines) {
const cells = (l) => l.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
const num = (v) => Math.abs(v) >= 10000 ? Math.round(v).toLocaleString("en-US") : String(Math.round(v * 100) / 100);
const clean = (s) => Number(String(s).replace(/[,\s]/g, "").replace(/[%元個次人台]$/, ""));
const rows = lines.map((l) => l.trim()).filter(Boolean);
if (!rows.length) return "";
let kind = "bar", title = "", body = rows;
const m = rows[0].match(/^(bar|line|pie)\s+(.*)$/i);
if (m) { kind = m[1].toLowerCase(); title = m[2]; body = rows.slice(1); }
let labels = [], series = [];
if (body[0] && body[0].trim().startsWith("|")) {
labels = cells(body[0]);
for (const r of body.slice(1)) { const c = cells(r); const v = c.slice(1).map(clean); if (!c[0] || v.length !== labels.length || v.some((x) => !isFinite(x))) return ""; series.push([c[0], v]); }
} else {
const vals = [];
for (const r of body) { const c = cells(r); const v = clean(c[1]); if (c.length < 2 || !c[0] || !isFinite(v)) return ""; labels.push(c[0]); vals.push(v); }
series = [["", vals]];
}
const n = labels.length, ns = series.length, single = ns === 1;
if (!n || !ns || labels.length * (kind === "pie" ? 1 : 1) === 0) return "";
const W = 620, H = 240, L = 10, R0 = 10;
const nat = labels.every((l) => /月|年|周|週|日|季|Q[1-4]|q[1-4]|W[1-4]|今|去年|今年|明年/.test(l) || /^\d/.test(l.trim()));
const tot = (i) => series.reduce((a, s) => a + (s[1][i] || 0), 0);
const idx = labels.map((_, i) => i);
if (kind === "bar" && n > 1 && !nat) idx.sort((a, b) => tot(b) - tot(a) || a - b);
const esc2 = (s) => esc(String(s));
const cut7 = (s) => (String(s).length > 7 ? String(s).slice(0, 7) + "…" : String(s));
const cat = (i) => `var(--cat${i % 6 + 1})`;
const svg = [];
if (kind === "pie") {
const multi = ns > 1;
const pl = multi ? series.map((s) => s[0]) : labels;
const pv = multi ? series.map((s) => Math.max(0, s[1][0] || 0)) : series[0][1].map((v) => Math.max(0, v));
const order = pl.map((_, i) => i).sort((a, b) => pv[b] - pv[a]);
const total = pv.reduce((a, b) => a + b, 0);
if (total <= 0) return "";
const cx = 92, cy = H / 2, Rr = 84;
let a0 = -Math.PI / 2;
order.forEach((i, k) => {
const sweep = pv[i] / total * Math.PI * 2;
if (sweep > 0) {
const a1 = a0 + sweep, big = sweep > Math.PI ? 1 : 0;
svg.push(`<path d="M${cx},${cy} L${(cx + Rr * Math.cos(a0)).toFixed(1)},${(cy + Rr * Math.sin(a0)).toFixed(1)} A${Rr},${Rr} 0 ${big} 1 ${(cx + Rr * Math.cos(a1)).toFixed(1)},${(cy + Rr * Math.sin(a1)).toFixed(1)} Z" fill="${cat(multi ? i : k)}" stroke="var(--elev)" stroke-width="2"><title>${esc2(pl[i])} · ${num(pv[i])} (${Math.round(pv[i] / total * 100)}%)</title></path>`);
}
a0 += sweep;
});
const rows2 = order.map((i, k) => `<g><rect x="212" y="${28 + k * 26 - 5}" width="9" height="9" rx="2" fill="${cat(multi ? i : k)}"/><text x="228" y="${28 + k * 26 + 3}" font-size="12" fill="var(--text2)">${esc2(cut7(pl[i]))} · ${num(pv[i])} (${Math.round(pv[i] / total * 100)}%)</text></g>`).join("");
svg.push(rows2);
} else {
const valsAll = series.flatMap((s) => s[1]);
const vmax = Math.max(0, ...valsAll), vmin = Math.min(0, ...valsAll), span = (vmax - vmin) || 1;
const padT = (single ? 26 : 40), padB = 30;
const R = kind === "line" && !single ? 130 : 12;
const Y = (v) => padT + (H - padT - padB) * (1 - (v - vmin) / span);
const Xc = (k) => L + (W - L - R) * (n === 1 ? 0.5 : k / (n - 1));
// 只留淡水平參考線(max、mid、0),不畫框不畫直格線。
const marks = [vmax, vmin + (vmax - vmin) / 2, 0].filter((v, i, a) => a.findIndex((u) => Math.abs(u - v) < 1e-9) === i);
for (const v of marks) if (!(v === vmin && vmin < 0)) svg.push(`<line x1="${L}" y1="${Y(v).toFixed(1)}" x2="${W - R}" y2="${Y(v).toFixed(1)}" stroke="var(--grid)" stroke-width="1"/>`);
if (kind === "bar") {
const gw = (W - L - R) / n, bw = Math.min(56, gw * 0.66 / ns);
idx.forEach((i, k) => {
series.forEach((s, si) => {
const v = s[1][i], cx = L + gw * (k + 0.5) + (si - (ns - 1) / 2) * (bw + 2);
const y0 = Y(0), yv = Y(v);
svg.push(`<rect x="${(cx - bw / 2).toFixed(1)}" y="${Math.min(y0, yv).toFixed(1)}" width="${bw.toFixed(1)}" height="${Math.max(1, Math.abs(y0 - yv)).toFixed(1)}" rx="4" fill="${cat(si)}"><title>${esc2(labels[i])}${s[0] ? " · " + esc2(s[0]) : ""} · ${num(v)}</title></rect>`);
});
svg.push(`<text x="${(L + gw * (k + 0.5)).toFixed(1)}" y="${H - 10}" text-anchor="middle" font-size="11" fill="var(--text3)">${esc2(cut7(labels[i]))}</text>`);
});
if (single) idx.forEach((i, k) => {
const v = series[0][1][i];
const cx = L + gw * (k + 0.5), yv = Y(v);
svg.push(`<text x="${cx.toFixed(1)}" y="${(v >= 0 ? yv - 6 : yv + 14).toFixed(1)}" text-anchor="middle" font-size="11" fill="var(--text2)">${num(v)}</text>`);
});
if (!single) series.forEach((s, si) => {
const lx = L + si * 110;
svg.push(`<rect x="${lx}" y="10" width="9" height="9" rx="2" fill="${cat(si)}"/><text x="${lx + 14}" y="18" font-size="11" fill="var(--text2)">${esc2(cut7(s[0]))}</text>`);
});
} else {
idx.forEach((i, k) => svg.push(`<text x="${Xc(k).toFixed(1)}" y="${H - 10}" text-anchor="middle" font-size="11" fill="var(--text3)">${esc2(cut7(labels[i]))}</text>`));
series.forEach((s, si) => {
const pts = idx.map((i, k) => [Xc(k), Y(s[1][i])]);
svg.push(`<polyline points="${pts.map((p) => p.map((q) => q.toFixed(1)).join(",")).join(" ")}" fill="none" stroke="${cat(si)}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`);
pts.forEach((p, k) => svg.push(`<circle cx="${p[0].toFixed(1)}" cy="${p[1].toFixed(1)}" r="3" fill="${cat(si)}"><title>${esc2(labels[idx[k]])}${s[0] ? " · " + esc2(s[0]) : ""} · ${num(s[1][idx[k]])}</title></circle>`));
if (!single && s[0]) {
const last = pts[pts.length - 1];
svg.push(`<text x="${(last[0] + 8).toFixed(1)}" y="${(last[1] + 4).toFixed(1)}" font-size="12" font-weight="600" fill="${cat(si)}">${esc2(cut7(s[0]))}</text>`);
}
});
}
}
return `<div class="chartcard">${title ? `<div class="ct2">${esc2(title)}</div>` : ""}<svg viewBox="0 0 ${W} ${H}" role="img" aria-label="${esc2(title || "chart")}">${svg.join("")}</svg></div>`;
}
function pageMd(text, id, rev) {
const L = String(text || "").replace(/\r/g, "").split("\n");
const out = []; let i = 0, chart = 0;
@ -2622,8 +2727,9 @@ function pageMd(text, id, rev) {
while (i < L.length && !L[i].trim().startsWith("```")) body.push(L[i++]);
i++;
if (lang === "mermaid" && id) { out.push(`<div class="chart" data-src="api/pages/${id}/chart/${chart++}${rev ? "?rev=" + rev : ""}"><div class="wait">圖表載入中…</div></div>`); continue; }
if (lang === "chart") { const html = chartMd(body); if (html) { out.push(html); continue; } }
if (lang === "stats") {
const tiles = body.map(cells).filter((c) => c.length >= 2 && c[0]).map((c) => `<div class="stat"><div class="k">${inl(c[0])}</div><div class="v${c[1].length > 10 ? " long" : ""}">${inl(c[1])}</div>${c[2] ? `<div class="s">${inl(c[2])}</div>` : ""}</div>`);
const tiles = body.map(cells).filter((c) => c.length >= 2 && c[0]).map((c) => { const dir = /^[↑+]/.test(c[1]) ? " up" : /^[↓−-]/.test(c[1]) ? " dn" : ""; return `<div class="stat"><div class="k">${inl(c[0])}</div><div class="v${dir}${c[1].length > 10 ? " long" : ""}">${inl(c[1])}</div>${c[2] ? `<div class="s">${inl(c[2])}</div>` : ""}</div>`; });
if (tiles.length) { out.push(`<div class="stats">${tiles.join("")}</div>`); continue; }
}
if (lang === "steps") {

View File

@ -199,6 +199,19 @@ fn scenes() -> Vec<(&'static str, Open)> {
a.show_routines = Some(id);
}),
),
(
"頁面(圖表:長條排序、多線、圓餅、stats)",
Box::new(|a: &mut App| {
let (pages, next, id) = crate::pages::demo(crate::model::now_ms());
a.state.pages = pages;
a.state.next_page_id = next;
if let Some(pg) = a.state.pages.iter_mut().find(|pg| pg.id == id) {
pg.body.push_str("\n\n## 圖表\n```chart\nbar 各季下載量(個)\n北部 | 940\n中部 | 620\n南部 | 780\n東部 | 90\n```\n\n```chart\nline 月度下載(個)\n| 1月 | 2月 | 3月 | 4月\n去年 | 120 | 180 | 150 | 210\n今年 | 200 | 260 | 320 | 390\n```\n\n```chart\npie 裝置\n手機 | 550\n桌面 | 300\n平板 | 150\n```\n\n```stats\n本季下載 | 2,430 | ↑ 18% 較上季\n上季 | 2,060\n```\n");
}
a.state.selected = 1;
a.page_view = Some((id, None));
}),
),
]
}

View File

@ -717,16 +717,23 @@ impl App {
ui.horizontal_top(|ui| {
ui.spacing_mut().item_spacing.x = gap;
for (label, value, note) in row {
Frame::new().fill(p.hover).corner_radius(10).inner_margin(Margin::symmetric(12, 10)).show(ui, |ui| {
ui.set_width(tile_w - 24.0);
Frame::new().fill(p.muted).stroke(Stroke::new(1.0, p.border)).corner_radius(12).inner_margin(Margin { left: 14, right: 14, top: 12, bottom: 12 }).show(ui, |ui| {
ui.set_width(tile_w - 28.0);
ui.vertical(|ui| {
ui.spacing_mut().item_spacing.y = 2.0;
ui.add(egui::Label::new(RichText::new(label).size(12.0).color(p.text2)).wrap());
ui.spacing_mut().item_spacing.y = 3.0;
ui.add(egui::Label::new(RichText::new(label).size(11.0).color(p.text3)).wrap());
// A long value (a phrase, not a number) a size smaller, so it doesn't fill the tile.
let size = if value.chars().count() > 10 { 15.0 } else { 20.0 };
ui.add(egui::Label::new(RichText::new(value).size(size).strong().family(crate::bold()).color(p.text)).wrap());
// An arrow up front is a verdict: green up, red down (with the arrow
// itself as the non-colour signal).
let (size, col) = match value.chars().next() {
Some('↑') | Some('+') => (26.0, p.up),
Some('↓') | Some('−') => (26.0, p.danger),
_ if value.chars().count() > 10 => (16.0, p.text),
_ => (26.0, p.text),
};
ui.add(egui::Label::new(RichText::new(value).size(size).strong().family(crate::bold()).color(col)).wrap());
if !note.is_empty() {
ui.add(egui::Label::new(RichText::new(note).size(11.5).color(p.text3)).wrap());
ui.add(egui::Label::new(RichText::new(note).size(11.5).color(p.text2)).wrap());
}
});
});
@ -749,26 +756,19 @@ impl App {
/// numbers are already on screen next to the chart).
fn md_chart_card(&mut self, ui: &mut egui::Ui, c: &crate::pages::Chart, with_table: bool) {
let p = self.pal;
const SERIES: [Color32; 6] = [
Color32::from_rgb(0x4c, 0x8d, 0xff),
Color32::from_rgb(0x2e, 0xa0, 0x43),
Color32::from_rgb(0xf5, 0xa6, 0x23),
Color32::from_rgb(0x92, 0x66, 0xf9),
Color32::from_rgb(0xe5, 0x48, 0x4d),
Color32::from_rgb(0x1f, 0xb6, 0xb0),
];
let id = ui.scope_id().with(("chart", chart_key(c)));
let fp = egui::FontId::proportional(10.5);
let series_col = |i: usize| if i == 0 { p.accent } else { SERIES[i % SERIES.len()] };
let series_col = |i: usize| p.chart_cat[i % p.chart_cat.len()];
let axes = c.kind != crate::pages::ChartKind::Pie;
Frame::new().fill(p.pane).stroke(Stroke::new(1.0, p.border)).corner_radius(12).inner_margin(Margin::symmetric(16, 14)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.spacing_mut().item_spacing.y = 0.0;
if !c.title.is_empty() {
ui.add(egui::Label::new(RichText::new(&c.title).size(14.0).strong().family(crate::bold()).color(p.text)).wrap());
ui.add_space(4.0);
}
match c.kind {
crate::pages::ChartKind::Pie => self.md_chart_pie(ui, c, &SERIES, id, &fp),
crate::pages::ChartKind::Pie => self.md_chart_pie(ui, c, &p.chart_cat, id, &fp),
_ => self.md_chart_plot(ui, c, id, &series_col),
}
if with_table {
@ -782,11 +782,14 @@ impl App {
});
}
/// Bar and line on egui_plot: the x ticks are the category labels, the y axis carries the
/// numbers (tabular, no noise), hover snaps to the nearest point and says 「label · series ·
/// value」. The first series rides in the accent colour — it is the story; the rest come
/// after it.
fn md_chart_plot(&self, ui: &mut egui::Ui, c: &crate::pages::Chart, id: egui::Id, series_col: &dyn Fn(usize) -> Color32) {
/// Bar and line on egui_plot, drawn the way the current data-viz practice says (Tufte's
/// data-ink; Carbon/Atlassian/shadcn conventions): the grid is one faint line on the value
/// axis only, a bar chart sorts by size unless the labels carry their own order (months,
/// quarters…), a single series is labelled with its numbers directly and drops the y-axis,
/// and lines say their name at their end instead of a legend. The first series rides first
/// in the palette. Hover snaps to the nearest point and says 「label · series · value」;
/// pan/zoom and double-click reset stay.
fn md_chart_plot(&mut self, ui: &mut egui::Ui, c: &crate::pages::Chart, id: egui::Id, series_col: &dyn Fn(usize) -> Color32) {
use egui_plot::{uniform_grid_spacer, Bar, BarChart, Corner, HoverPosition, Legend, Line, Plot, PlotPoints, Points};
let p = self.pal;
if c.labels.is_empty() {
@ -800,33 +803,56 @@ impl App {
format!("{}…", s.chars().take(max).collect::<String>())
}
};
let labels = c.labels.clone();
let labels2 = c.labels.clone();
let line = c.kind == crate::pages::ChartKind::Line;
// A bar chart shows ranking, so bars go big → small — unless the labels have a natural
// order of their own (months, quarters, weeks, years, plain numbers), which stays.
let temporal = |s: &str| {
["月", "年", "週", "周", "季", "Q1", "Q2", "Q3", "Q4", "q1", "q2", "q3", "q4", "W1", "W2", "W3", "W4", "今", "上週", "上季", "去年", "今年", "明年"]
.iter()
.any(|k| s.contains(k))
|| s.trim().starts_with(|ch: char| ch.is_ascii_digit())
};
let mut order: Vec<usize> = (0..c.labels.len()).collect();
if !line && c.labels.len() >= 2 && !c.labels.iter().all(|l| temporal(l)) {
let total = |k: usize| -> f64 { c.series.iter().map(|(_, v)| v.get(k).copied().unwrap_or(0.0)).sum() };
order.sort_by(|a, b| total(*b).total_cmp(&total(*a)).then(a.cmp(b)));
}
let labels = c.labels.clone();
let order2 = order.clone();
let labels3 = labels.clone();
let order3 = order.clone();
let single = c.series.len() == 1;
// Direct labels replace the axis: a single-series bar chart writes its numbers.
let label_bars = single && !line;
let hide_y = label_bars;
Plot::new(id)
.height(230.0)
.grid_color(p.border.gamma_multiply(0.6))
.grid_color(p.grid)
.show_grid(egui::Vec2b::new(false, true))
.x_grid_spacer(uniform_grid_spacer(category_steps))
.allow_scroll(false)
.include_y(0.0)
.y_axis_min_width(30.0)
.y_axis_formatter(move |mark, _| crate::pages::chart_num(mark.value))
// Lines with names at their ends need room past the last point for the name.
.include_x(if line && !single { c.labels.len() as f64 } else { 0.0 })
.y_axis_min_width(if hide_y { 2.0 } else { 30.0 })
.y_axis_formatter(move |mark, _| if hide_y { String::new() } else { crate::pages::chart_num(mark.value) })
.x_axis_formatter(move |mark, _| {
let i = mark.value.round();
if i < 0.0 || i as usize >= labels2.len() {
if i < 0.0 || i as usize >= order2.len() {
String::new()
} else {
cut(&labels2[i as usize], 7)
cut(&labels[order2[i as usize]], 7)
}
})
.label_formatter(move |pos| match pos {
HoverPosition::NearDataPoint { plot_name, position, .. } => {
let i = position.x.round().clamp(0.0, (labels.len() - 1) as f64) as usize;
let k = position.x.round().clamp(0.0, (labels3.len() - 1) as f64) as usize;
let i = order3.get(k).copied().unwrap_or(k);
let v = crate::pages::chart_num(position.y);
Some(if plot_name.is_empty() {
format!("{} · {v}", labels[i])
format!("{} · {v}", labels3[i])
} else {
format!("{} · {plot_name} · {v}", labels[i])
format!("{} · {plot_name} · {v}", labels3[i])
})
}
HoverPosition::Elsewhere { .. } => None,
@ -836,17 +862,38 @@ impl App {
if line {
for (si, (name, vals)) in c.series.iter().enumerate() {
let col = series_col(si);
let pts: Vec<[f64; 2]> = vals.iter().enumerate().map(|(i, v)| [i as f64, *v]).collect();
plot_ui.line(Line::new(name.clone(), PlotPoints::new(pts.clone())).color(col).width(2.0));
let pts: Vec<[f64; 2]> = order.iter().enumerate().map(|(x, &k)| [x as f64, vals.get(k).copied().unwrap_or(0.0)]).collect();
let last = pts.last().copied();
plot_ui.line(Line::new(if single { String::new() } else { name.clone() }, PlotPoints::new(pts.clone())).color(col).width(2.0));
plot_ui.points(Points::new("", PlotPoints::new(pts)).color(col).radius(2.4).filled(true));
// The name rides at the line's end — the reader never walks to a legend.
if !single && !name.trim().is_empty() {
if let Some(last) = last {
plot_ui.text(egui_plot::Text::new("", egui_plot::PlotPoint::new(last[0] + 0.3, last[1]), name.clone()).color(col).anchor(egui::Align2::LEFT_CENTER));
}
}
}
} else {
let ns = c.series.len().max(1);
let bw = (0.66 / ns as f64).max(0.06);
for (si, (name, vals)) in c.series.iter().enumerate() {
let off = (si as f64 - (ns - 1) as f64 / 2.0) * (bw + 0.02);
let bars: Vec<Bar> = vals.iter().enumerate().map(|(i, v)| Bar::new(i as f64 + off, *v).width(bw)).collect();
plot_ui.bar_chart(BarChart::new(name.clone(), bars).color(series_col(si)));
let bars: Vec<Bar> = order
.iter()
.enumerate()
.map(|(x, &k)| Bar::new(x as f64 + off, vals.get(k).copied().unwrap_or(0.0)).width(bw))
.collect();
plot_ui.bar_chart(BarChart::new(if single { String::new() } else { name.clone() }, bars).color(series_col(si)));
if label_bars {
for (x, &k) in order.iter().enumerate() {
let v = vals.get(k).copied().unwrap_or(0.0);
plot_ui.text(
egui_plot::Text::new("", egui_plot::PlotPoint::new(x as f64, v), crate::pages::chart_num(v))
.anchor(if v >= 0.0 { egui::Align2::CENTER_BOTTOM } else { egui::Align2::CENTER_TOP })
.color(p.text2),
);
}
}
}
}
});

View File

@ -24,15 +24,54 @@ fn fontdb() -> std::sync::Arc<resvg::usvg::fontdb::Database> {
.clone()
}
/// The house look for diagrams (same spirit as the chart cards, and the same six-colour
/// series palette): quiet cards, thin grey connectors, no heavy borders — Mermaid's default
/// blues are loud and read as "report software" next to the rest of the app.
fn house_theme(dark: bool) -> mermaid_rs_renderer::Theme {
let mut t = if dark { mermaid_rs_renderer::Theme::dark() } else { mermaid_rs_renderer::Theme::neutral() };
let (card, line, ink, faint, fill2, fill3, grid) = if dark {
("#252525", "#8a8a8a", "#f5f5f5", "#3a3a3a", "#2f3438", "#2b2d31", "#1f1f1f")
} else {
("#ffffff", "#9b9a97", "#1c1c1c", "#e3e2df", "#f1f1ef", "#eff5fb", "#f7f7f5")
};
t.primary_color = card.into();
t.primary_border_color = faint.into();
t.primary_text_color = ink.into();
t.line_color = line.into();
t.secondary_color = fill2.into();
t.tertiary_color = fill3.into();
t.edge_label_background = card.into();
t.cluster_background = grid.into();
t.cluster_border = faint.into();
t.background = if dark { "#1f1f1f".into() } else { "transparent".into() };
t.sequence_actor_fill = fill2.into();
t.sequence_actor_border = faint.into();
t.sequence_actor_line = line.into();
t.sequence_note_fill = if dark { "#3a3212".into() } else { "#fff8e1".into() };
t.sequence_note_border = faint.into();
t.sequence_activation_fill = fill3.into();
t.sequence_activation_border = if dark { "#529cca" } else { "#2383e2" }.into();
t.text_color = ink.into();
// Pie and git series: the house palette (theme.rs chart_cat), in order, then repeats lighter.
let cat: [&str; 6] = if dark {
["#529cca", "#b493e5", "#4dab9a", "#e3a062", "#f291c0", "#a09e9a"]
} else {
["#2383e2", "#9065b0", "#0f7b6c", "#d9730d", "#e06b9e", "#6e6c68"]
};
t.pie_colors = std::array::from_fn(|i| cat[i % 6].to_string());
t.pie_stroke_color = card.into();
t.pie_title_text_color = ink.into();
t.pie_section_text_color = ink.into();
t.pie_legend_text_color = ink.into();
t
}
/// Mermaid source → SVG text.
pub fn svg(source: &str, dark: bool) -> Result<String, String> {
if source.len() > MAX_SOURCE {
return Err("圖表太大".into());
}
let mut opts = mermaid_rs_renderer::RenderOptions::default();
if dark {
opts.theme = mermaid_rs_renderer::Theme::dark();
}
let mut opts = mermaid_rs_renderer::RenderOptions { theme: house_theme(dark), ..Default::default() };
opts.theme.font_family = "sans-serif".into();
// A panic inside the layout must not take the window down.
let src = source.to_string();

View File

@ -77,7 +77,7 @@ fn one() -> u32 {
pub fn specs() -> Vec<Value> {
vec![
json!({"name": "write_page", "description": "Make or update a page: a lasting, nicely laid-out document the person can open from the chat and that you keep up to date — a tracker (e.g. 「台灣 Tesla FSD 追蹤」), a report, a comparison, a plan, research notes. Use it whenever the person asks you to track, follow, summarise or compare something they will come back to; then link it in your reply as [標題](page:ID). With an id (or the same title) it replaces that page's content and keeps the old version. Write Markdown: headings, short paragraphs, lists, tables, links to sources, Mermaid charts (```mermaid: pie, xychart-beta bar/line, timeline, gantt, flowchart), and these page blocks:\n```stats\n狀態 | 審查中 | 第 1 步\n預計開放 | 2027 Q2 | 媒體推估\n```\n```steps\n[x] 道路測試計畫審查 | 7/9 月開過兩次會\n[>] 道路測試 | 等交通部核定\n[ ] 正式開放\n```\n```chart\nbar 標題(bar | line | pie 換圖型)\n1月 | 120\n2月 | 320\n```\n多系列:首行 `| 1月 | 2月`(第一格留空),每列 `名稱 | 120 | 320`。圖表用原生繪製(可縮放、hover 看數值,下方自動附數據表),優於 ```mermaid 的圖片。\n> [!NOTE] / [!TIP] / [!WARNING] / [!IMPORTANT] call-outs.\n\n寫法(讀者是先掃一眼、要深才細讀的人,不是讀報告的人):\n• 選 kind(data 數據分析 / compare 比較評測 / decision 決策備忘 / howto 教學步驟 / timeline 時間線 / prose 純敘述 / notes 筆記),第一屏跟著它:data → 一句結論+kpis 三個真數字+主圖表;compare → 一句取捨+verdict+對比表;decision → 結論先行(verdict)+三條證據+風險;howto → 適合誰/成品+步驟(steps);timeline → 時間軸(mermaid timeline);prose/notes → 直接內文,不準硬湊 KPI 卡。\n• kpis 只放真資料算得出的數字(附 delta,如 +12%);湊不出三個就少放或不放。verdict 只在有明確結論時寫。\n• 每段不超過 4 行;連續段落不超過 3 段,中間改用列表/表格/圖。\n• 有數字就出 ```chart,圖標題直接寫結論並帶數字(如「Q3 營收創新高 42 萬」),軸標籤帶單位;細節數字放表格。\n• 每節先一句結論再給證據;來源放最後,帶連結與日期。更新時把整頁維持成現況(不是日誌),並在 `note` 寫出改了什麼。",
json!({"name": "write_page", "description": "Make or update a page: a lasting, nicely laid-out document the person can open from the chat and that you keep up to date — a tracker (e.g. 「台灣 Tesla FSD 追蹤」), a report, a comparison, a plan, research notes. Use it whenever the person asks you to track, follow, summarise or compare something they will come back to; then link it in your reply as [標題](page:ID). With an id (or the same title) it replaces that page's content and keeps the old version. Write Markdown: headings, short paragraphs, lists, tables, links to sources, Mermaid charts (```mermaid: pie, xychart-beta bar/line, timeline, gantt, flowchart), and these page blocks:\n```stats\n狀態 | 審查中 | 第 1 步\n預計開放 | 2027 Q2 | 媒體推估\n```\n```steps\n[x] 道路測試計畫審查 | 7/9 月開過兩次會\n[>] 道路測試 | 等交通部核定\n[ ] 正式開放\n```\n```chart\nbar 標題(bar | line | pie 換圖型)\n1月 | 120\n2月 | 320\n```\n多系列:首行 `| 1月 | 2月`(第一格留空),每列 `名稱 | 120 | 320`。圖表用原生繪製(可縮放、hover 看數值,下方自動附數據表),優於 ```mermaid 的圖片。排版由渲染器接手:長條圖自動由大到小排序(月份/年份等自有順序的標籤不排);單系列把數字直接標在圖上、不畫 y 軸;多條線在線尾標系列名——你只要把圖標題寫成結論。\n> [!NOTE] / [!TIP] / [!WARNING] / [!IMPORTANT] call-outs.\n\n寫法(讀者是先掃一眼、要深才細讀的人,不是讀報告的人):\n• 選 kind(data 數據分析 / compare 比較評測 / decision 決策備忘 / howto 教學步驟 / timeline 時間線 / prose 純敘述 / notes 筆記),第一屏跟著它:data → 一句結論+kpis 三個真數字+主圖表;compare → 一句取捨+verdict+對比表;decision → 結論先行(verdict)+三條證據+風險;howto → 適合誰/成品+步驟(steps);timeline → 時間軸(mermaid timeline);prose/notes → 直接內文,不準硬湊 KPI 卡。\n• kpis 只放真資料算得出的數字(附 delta,如 +12%);湊不出三個就少放或不放。verdict 只在有明確結論時寫。\n• 每段不超過 4 行;連續段落不超過 3 段,中間改用列表/表格/圖。\n• 有數字就出 ```chart,圖標題直接寫結論並帶數字(如「Q3 營收創新高 42 萬」),軸標籤帶單位;細節數字放表格。\n• 每節先一句結論再給證據;來源放最後,帶連結與日期。更新時把整頁維持成現況(不是日誌),並在 `note` 寫出改了什麼。",
"parameters": {"type": "object", "properties": {
"title": {"type": "string", "description": "Short title, e.g. 台灣 Tesla FSD 追蹤"},
"content": {"type": "string", "description": "The whole page in Markdown (without the title)"},
@ -539,7 +539,7 @@ pub fn callout(first_line: &str) -> Option<(&'static str, String)> {
/// A sample tracking page (screenshots, and the look the bots are asked for).
pub fn demo(now: i64) -> (Vec<Page>, u64, u64) {
let body = "## 現況\n台灣 FSD **現在還不能用**:交通部把它當 L2 輔助駕駛,走「新技術駕駛系統審查」,不用修法;目前卡在第 1 步,路測計畫還沒核准。\n\n```stats\n目前階段 | 第 1 步 | 道路測試計畫審查\n預計開放 | 2027 Q2 | 媒體推估,官方未公布\n月費 | 未公布 | 網路數字是美國價換算\n你的車 | HW4 | 柏林廠,硬體不卡\n```\n\n## 審查進度\n```steps\n[x] 專家審查會議 | 7 月、9 月各開一次\n[>] 道路測試計畫審查 | 特斯拉依會議結論補件中\n[ ] 道路測試 | 計畫核定後才開始\n[ ] 正式開放\n```\n\n> [!WARNING] 你 12 月交車時多半還不能用,現在先別花錢。等正式開放後先訂閱一個月最划算。\n\n## 時間線\n| 日期 | 消息 | 來源 |\n|---|---|---|\n| 11/4 | 交通部:希望年底前完成相關審查,但不保證年底開放 | NOWnews |\n| 10/2 | 特斯拉:7–9 月完成第一輪技術審查,提出修改後的路測計畫 | 特斯拉 |\n| 6/30 | FSD 買斷停賣 | 特斯拉官網 |\n\n```mermaid\npie title 媒體預估開放時間\n \"2026 年底\" : 1\n \"2027 上半年\" : 3\n \"2027 下半年\" : 4\n```\n\n## 來源\n- [NOWnews 專訪交通部監理司](https://www.nownews.com)(11/4)\n- [車安中心 新技術駕駛系統審查流程](https://www.vscc.org.tw)\n";
let body = "## 現況\n台灣 FSD **現在還不能用**:交通部把它當 L2 輔助駕駛,走「新技術駕駛系統審查」,不用修法;目前卡在第 1 步,路測計畫還沒核准。\n\n```stats\n目前階段 | 第 1 步 | 道路測試計畫審查\n預計開放 | 2027 Q2 | 媒體推估,官方未公布\n月費 | 未公布 | 網路數字是美國價換算\n你的車 | HW4 | 柏林廠,硬體不卡\n```\n\n## 審查進度\n```steps\n[x] 專家審查會議 | 7 月、9 月各開一次\n[>] 道路測試計畫審查 | 特斯拉依會議結論補件中\n[ ] 道路測試 | 計畫核定後才開始\n[ ] 正式開放\n```\n\n> [!WARNING] 你 12 月交車時多半還不能用,現在先別花錢。等正式開放後先訂閱一個月最划算。\n\n## 時間線\n| 日期 | 消息 | 來源 |\n|---|---|---|\n| 11/4 | 交通部:希望年底前完成相關審查,但不保證年底開放 | NOWnews |\n| 10/2 | 特斯拉:7–9 月完成第一輪技術審查,提出修改後的路測計畫 | 特斯拉 |\n| 6/30 | FSD 買斷停賣 | 特斯拉官網 |\n\n```mermaid\npie title 媒體預估開放時間\n \"2026 年底\" : 1\n \"2027 上半年\" : 3\n \"2027 下半年\" : 4\n```\n\n## 各月討論熱度\n```chart\nline 新聞提及(篇)\n| 7月 | 8月 | 9月 | 10月 | 11月\n媒體報導 | 12 | 9 | 21 | 18 | 34\n官方聲明 | 2 | 1 | 3 | 2 | 5\n```\n\n```chart\npie 車主意向\n想訂閱 | 520\n觀望 | 300\n不買 | 180\n```\n\n## 來源\n- [NOWnews 專訪交通部監理司](https://www.nownews.com)(11/4)\n- [車安中心 新技術駕駛系統審查流程](https://www.vscc.org.tw)\n";
let mut pages = vec![];
let mut next = 1;
let first = body.replace("交通部:希望年底前完成相關審查,但不保證年底開放", "(還沒有新消息)");

View File

@ -27,6 +27,14 @@ pub struct Palette {
/// The quiet fill behind secondary blocks: filled inputs, list trays, segmented tracks
/// (the shadcn 'muted' layer — it is what makes groups read as groups).
pub muted: Color32,
/// Chart series colours, in fixed order (Atlassian/Carbon practice: a protocol, not a
/// preference — the same hue always means the same rank of series; max six categories).
/// Chosen low-saturation so many series never fight, with light/dark variants.
pub chart_cat: [Color32; 6],
/// The one faint gridline (value axis only; the category axis never gets one).
pub grid: Color32,
/// Up / good (charts, stat tiles). Down and bad is `danger`.
pub up: Color32,
}
const fn hexa(r: u8, g: u8, b: u8, a: u8) -> Color32 {
@ -52,6 +60,17 @@ pub const LIGHT: Palette = Palette {
attention: hexa(0xff, 0xc8, 0x3d, 0xff),
attention_bg: hexa(0xff, 0xf6, 0xd6, 0xff),
muted: hexa(0xf1, 0xf1, 0xee, 0xff),
// Notion-ish: blue, purple, teal, orange, pink, slate — all muted, all readable on white.
chart_cat: [
hexa(0x23, 0x83, 0xe2, 0xff),
hexa(0x90, 0x65, 0xb0, 0xff),
hexa(0x0f, 0x7b, 0x6c, 0xff),
hexa(0xd9, 0x73, 0x0d, 0xff),
hexa(0xe0, 0x6b, 0x9e, 0xff),
hexa(0x6e, 0x6c, 0x68, 0xff),
],
grid: hexa(0x1c, 0x1c, 0x1c, 0x12),
up: hexa(0x0f, 0x7b, 0x6c, 0xff),
};
// From the original's renderer (index.eager-common: appearance primitives dark neutral/0..6 and the
@ -78,6 +97,18 @@ pub const DARK: Palette = Palette {
attention: hexa(0xff, 0xc8, 0x3d, 0xff),
attention_bg: hexa(0x3a, 0x32, 0x12, 0xff),
muted: hexa(0x1d, 0x1d, 0x1d, 0xff),
// The same six families, lightened for a dark page (dark-theme palettes must be raised
// in lightness to keep contrast, Carbon's dark set does the same).
chart_cat: [
hexa(0x52, 0x9c, 0xca, 0xff),
hexa(0xb4, 0x93, 0xe5, 0xff),
hexa(0x4d, 0xab, 0x9a, 0xff),
hexa(0xe3, 0xa0, 0x62, 0xff),
hexa(0xf2, 0x91, 0xc0, 0xff),
hexa(0xa0, 0x9e, 0x9a, 0xff),
],
grid: hexa(0xf5, 0xf5, 0xf5, 0x14),
up: hexa(0x4d, 0xab, 0x9a, 0xff),
};
/// A bot's colour as a quiet background (its selected tile, its cards): a little of it over the